Last active
June 28, 2017 11:27
-
-
Save addrummond/2dbc8e935f70aab99c2b099bf86ea4f0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ========== START OF CODE TO COPY INTO YOUR DATA FILE ========== | |
var IMAGES_TO_PRELOAD = [ | |
// CHANGE THESE TO THE URLS OF THE IMAGES THAT YOU WANT TO PRELOAD | |
"https://upload.wikimedia.org/wikipedia/commons/thumb/e/ea/Capra_ibex_nubiana_near_Mitzpe_Ramon_in_summer_2011_%284%29.JPG/1200px-Capra_ibex_nubiana_near_Mitzpe_Ramon_in_summer_2011_%284%29.JPG", | |
"http://elelur.com/data_images/mammals/alpine-ibex/alpine-ibex-01.jpg" | |
]; | |
define_ibex_controller({ | |
name: "Preloader", | |
jqueryWidget: { | |
_init: function () { | |
this.element.append("Loading images..."); | |
this.preloadedImages = [ ]; | |
var numToPreload = IMAGES_TO_PRELOAD.length; | |
for (var i = 0; i < IMAGES_TO_PRELOAD.length; ++i) { | |
var img = new Image(); | |
img.src = IMAGES_TO_PRELOAD[i]; | |
var self = this; | |
img.onload = function () { | |
--numToPreload; | |
if (numToPreload == 0) { | |
self.options._finishedCallback([ ]); | |
} | |
} | |
this.preloadedImages.push(img); | |
} | |
} | |
}, | |
properties: { | |
countsForProgressBar: false | |
} | |
}); | |
// ========= END OF CODE TO COPY INTO YOUR DATA FILE ========== | |
// 'preload' should be the first item in the shuffle sequence so that images are preloaded | |
// before any other items are displayed. | |
var shuffleSequence = seq("preload", "img1", "img2"); | |
var items = [ | |
// Define the 'preload' item. | |
["preload", "Preloader", { }], | |
["img1", "Form", { html: "<img width='300px' src='http://elelur.com/data_images/mammals/alpine-ibex/alpine-ibex-01.jpg'>" } ], | |
["img2", "Form", { html: "<img width='300px' src='https://upload.wikimedia.org/wikipedia/commons/thumb/e/ea/Capra_ibex_nubiana_near_Mitzpe_Ramon_in_summer_2011_%284%29.JPG/1200px-Capra_ibex_nubiana_near_Mitzpe_Ramon_in_summer_2011_%284%29.JPG'>" } ] | |
]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment