1.0.1 • Published 6 years ago

responsive-image-gallery v1.0.1

Weekly downloads
6
License
MIT
Repository
github
Last release
6 years ago

Responsive Image Gallery

Responsive image gallery that supports category system for web and mobile browsers. For more information you can take a look at the demo: Demo

NPM

npm install --save-dev responsive-image-gallery

Installation

You can simply import Responsive Image Gallery and create a new object.

import Gallery from 'responsive-image-gallery';

const gallery = new Gallery({
    el: '#gallery'
});

You can also add the script file into your html.

<script src="/node_modules/responsive-image-gallery/dist/responsive-image-gallery.min.js"></script>
<script>
var gallery = new ResponsiveImageGallery({
    el: '#gallery'
});
</script>
<div>
    <ul id="bar">
        <li category="*">ALL</li>
        <li category="abstract">Abstract</li>
        <li category="space">Space</li>
    </ul>
    <div id="gallery”>
        <img src="abstract01.jpg" category="abstract" />
        <img src="space01.jpg" category="space" />
        <img src="abstract02.jpg" category="abstract" />
        <img src="space02.jpg" category="space" />
        <img src="abstract03.jpg" category="abstract" />
        <img src="space03.jpg" category="space" />
    </div>
</div>

<script src="/node_modules/responsive-image-gallery/dist/responsive-image-gallery.min.js"></script>
<script>
var gallery = new Gallery({
    el: '#gallery',
    bar: '#bar'
});
</script>

Configuration

Options

OptionTypeDefaultDescription
elstring | HTMLElement*nullContainer element.
barstring | HTMLElement*nullBar element.
activestring“*”Specifies the initial active category.
timingstring“ease”Specifies the speed curve of an animation. Takes all the values CSS3 can take. (like ease, linear, cubic-bezier, step)
durationnumber500Defines how long an animation should take to complete one cycle. (as milliseconds)
minWidthnumber250Specifies the minimum width of a gallery element.
maxWidthnumber500Specifies the maximum width of a gallery element.
heightnumber80Sets the height according to the width. (as percent)
horizontalSpacenumber10Specifies the horizontal space between gallery elements.
verticalSpacenumber10Specifies the vertical space between gallery elements.
overflowbooleanfalseAllows elements to overflow if the container element's width is smaller than minWidth.
gridbooleantrueEnables grid view.

*: You can give an HTML element or a CSS selector (like #gallery, .container > div:first-child)

Methods

MethodParamsReturnDescription
getstringReturns the active category.
setcategory: string, animate: booleanvoidSets the active category.
getTimingstringReturns timing value.
setTimingtiming:stringvoidSets timing value.
getDurationnumberReturns duration.
setDurationduration:numbervoidSets duration.
destroyvoidDestroys the gallery.

IE Support

IE 10 is not supported and patches to fix problems will not be accepted.

License

Responsive Image Gallery is provided under the MIT License.

Related Projects