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