1
Fork 0

Add wait for for lightgallery setup too

This commit is contained in:
Jake Howard 2018-12-01 20:06:31 +00:00
parent e51f08c83a
commit 1ff9567ba2
Signed by: jake
GPG key ID: 57AFB45680EDD477

View file

@ -2,10 +2,10 @@
var Clipboard = require('clipboard'); var Clipboard = require('clipboard');
function waitFor(global, callback) { function waitFor(obj, property, callback) {
// Wait for a property to exist on window before runnig callback // Wait for a property to exist on window before runnig callback
var intervalId = setInterval(function () { var intervalId = setInterval(function () {
if (window[global]) { if (obj.hasOwnProperty(property)) {
clearInterval(intervalId); clearInterval(intervalId);
callback(); callback();
} }
@ -24,12 +24,14 @@ $('.image').each(function () { // setup div-image hybrids
$(document).ready(function () { $(document).ready(function () {
$('#light-gallery').lightGallery({ waitFor($.fn, 'lightGallery', function () {
thumbnail:true, $('#light-gallery').lightGallery({
animateThumb: false, thumbnail:true,
showThumbByDefault: false, animateThumb: false,
preload: 2, showThumbByDefault: false,
download: false preload: 2,
download: false
});
}); });
// HACK: ToC has blank li if no initial header // HACK: ToC has blank li if no initial header
@ -42,7 +44,7 @@ $(document).ready(function () {
} }
}); });
waitFor('mermaid', function () { waitFor(window, 'mermaid', function () {
mermaid.initialize({ mermaid.initialize({
startOnLoad: true startOnLoad: true
}); });