var example1 = new mjGallery({ selector: ".example1__link" //items with source (with href or data-mjg-src attribute) });
var example2 = new mjGallery({ selector: ".example2__link", //items with source (with href or data-mjg-src attribute) gallery: false, //images will not be grouped to gallery zoomBtn: false, //zoom button will be hidden fullscreenBtn: false, //fullscreen button will be hidden info: false //info will be hidden, but can be turned on (infoBtn is not set to false), if there is something to show (see itam #5) });
var example3 = new mjGallery({ openBy: ".example3__button", //button for opening the gallery fullSize: true, //items can be as big as window cover: window.innerWidth > window.innerHeight, //items will cover the whole view/window (on landscape) maxWidth: "calc(100% - 20px)", //10px border around maxHeight: "calc(100% - 20px)", //10px border around title: ".title", //selector for title (not necesary — it will be detected automatically, because it has "title" in class attribute) description: function () { //generates description return this.getSrc(); } }); //use cover only on landscape $(window).on("orientationchange", function () { example3.refresh({ cover: window.innerWidth > window.innerHeight }, true); //true = merge options });
var example4 = new mjGallery({ selector: ".example4__button", //items with source (with href or data-mjg-src attribute) counter: false, //current position and total count of items will be hidden info: false //info will be hidden, but can be turned on (infoBtn is not set to false), if there is something to show });
var example5 = new mjGallery({ selector: ".example5__button" //items with source (with href or data-mjg-src attribute) });
A markup for the video must be provided in the document. The <video>
will be selected according to the data-mg-src="selector"
attribute.
var example6 = new mjGallery({ selector: ".example6__button", //items with source (with data-mjg-src attribute) autoplay: true //videos will be played automatically });
var example7 = new mjGallery({ selector: ".example7__button" //items with source (with data-mjg-src attribute) });
var example8 = new mjGallery({ selector: ".example8__button", //items html: function (done, item) { //generates the html content var req = $.get("api.openweathermap.org/data/2.5/weather?q=Prague&units=metric&APPID=699e0132d2f7e3fea7a91128af7959e1"); req.done(function (result) { var template = "<h1 class=\"example8__weather\"><div>Prague</div> <div>" + result.main.temp.toFixed(1) + " °C</div> <div>" + result.weather[0].description + "</div></h1>", sunrise = new Date(result.sys.sunrise), sunset = new Date(result.sys.sunset); item.setTitle("Weather In Prague") .setDescription("Sunrise: " + sunrise.toLocaleTimeString() + "; Sunset: " + sunset.toLocaleTimeString() + ";"); done(template); //function done must be called with html content (selectable with jQuery or jQuery object) }); }, counter: false //current position and total count of items will be hidden });
The default behavior on some events can be prevented by returning false
or by calling preventDefault()
on event object.
construct
init
open
beforeopen
beforefirstopen
afteropen
close
beforeclose
afterclose
change
next
or prev
method), but before the animation is done.beforechange
next
or prev
method). The default behavior can be prevented.afterchange
next
or prev
method) and the animation is done.currentitemchanged
beforedestroy
afterdestroy
beforerefresh
afterrefresh
load
youtubeready
vimeoready
videoready
event
scroll
, mousemove
, …) will be prevented. If this event (event
) is prevented, the original event won't be used.zoom
resize