This plugin allows for Play Store inspired transitions. It can be used for many different purposes including Galleries, Online stores, Portfolios and more.
Image is translated across the screen.
Horizontal card style is supported.
Image is scaled up to fill screen.
ColorThief cannot calculate colors for external images, so GalleryExpand will use the option: defaultColor
as a fallback.
If your server is CORS enabled however, it will work if you add crossOrigin="anonymous"
to your image.
<div class="col l4 m6 s12 gallery-item gallery-expand gallery-filter bigbang">
<div class="gallery-curve-wrapper">
<a class="gallery-cover gray">
<img class="responsive-img" src="img/bigbang1.png" alt="placeholder">
</a>
<div class="gallery-header">
<span>Gallery Link</span>
</div>
<div class="gallery-body">
<div class="title-wrapper">
<h3>Grapefruit</h3>
<span class="price">$14.99</span>
</div>
</div>
<div class="gallery-action">
<a class="btn-floating btn-large waves-effect waves-light">
<i class="material-icons">favorite
</i></a>
</div>
</div>
</div>
Option | Description |
---|---|
inDuration | Transition duration for opening the gallery in ms. Default: 300 |
outDuration | Transition duration for closing the gallery in ms. Default: 200 |
responsiveThreshold | Breakpoint for full width style in pixels. Default: 992 |
contentPadding | Padding for content in the gallery in pixels. Default: 40 |
onShow | Callback function that is fired when the gallery is opened. |
defaultColor | Fallback color for when color thief fails. Default: '#444' |
fillScreen | Enable the full width image transition style. Default: false |
dynamicRouting | Enable hash URL ids to allow dynamic routing. (Do not use with frameworks like Angular, Meteor, Vue, etc.) Default: false |
You can programmatically open and close the GalleryExpand with our plugin methods.
// Open
$('.gallery-expand').galleryExpand('open');
// Close
$('.gallery-expand').galleryExpand('close');
This theme utilizes Masonry for the card layout. We recommend initializing Masonry like we do below. If you are using images in your masonry items you will need imagesLoaded.
var $masonry = $('.gallery');
$masonry.masonry({
// set itemSelector so .grid-sizer is not used in layout
itemSelector: '.gallery-item',
// use element for option
columnWidth: '.gallery-item',
// no transitions
transitionDuration: 0
});
// layout Masonry after each image loads
$masonry.imagesLoaded(function() {
$masonry.masonry('layout');
});
You can add custom filters on masonry items by adding classes. Just add the class gallery-filter
to your item and then a custom class denoting your filter. You can also add the class all
instead of a custom class and it will always show up regardless of the filter.
<!-- Visible in the custom-category filter -->
<div class="col l4 m6 s12 gallery-item gallery-expand gallery-filter custom-category">
...
</div>
<!-- Always Visible -->
<div class="col l4 m6 s12 gallery-item gallery-expand gallery-filter all">
...
</div>
<div class="categories-container">
<ul class="categories container">
<li><a href="#all">All</a></li>
<li><a href="#custom-category">Custom Category</a></li>
</ul>
</div>
Also make sure if you are using filters to initialize your Masonry on gallery-filter
instead of gallery-item
.
$masonry.masonry({
// set itemSelector so .grid-sizer is not used in layout
itemSelector: '.gallery-filter',
// use element for option
columnWidth: '.gallery-filter',
// no transitions
transitionDuration: 0
});
The GalleryExpand plugin has custom mobile styles for both the default and fillScreen transitions. This is controlled by the responsiveThreshold
option. This options is a screen width in pixels that denotes when the plugin will switch to the mobile style.
// Only desktop style
$('.gallery-expand').galleryExpand({
responsiveThreshold: 0
});
// Only mobile style
$('.gallery-expand').galleryExpand({
responsiveThreshold: Infinity
});
When using Materialize components within GalleryExpand you will probably need to reinitialize these components using the onShow callback.
$('.gallery-expand').galleryExpand({
onShow: function(el) {
// Carousel
var carousel = el.find('.carousel.initialized');
carousel.carousel({
dist: 0,
padding: 10
});
// Tabs
$('ul.tabs').tabs();
}
});