Skip to content

Commit

Permalink
Added loader hooks, fixed tholman#10
Browse files Browse the repository at this point in the history
  • Loading branch information
panstav committed Jul 2, 2016
1 parent 58db4b8 commit 110d916
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions intense.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ var Intense = (function() {

var active = false;

var loader = {
start: function(){},
stop: function(){}
};

/* -------------------------
/* UTILS
/* -------------------------*/
Expand Down Expand Up @@ -299,8 +304,12 @@ var Intense = (function() {
loop();

setState(element, 'viewing');

loader.stop();
}

loader.start();

img.src = imageSource;
}

Expand Down Expand Up @@ -383,6 +392,22 @@ var Intense = (function() {

function config(options){
if ('invertInteractionDirection' in options) invertInteractionDirection = options.invertInteractionDirection;

if ('loader' in options){
if (invalidProperties()){
throw 'You need to pass callback functions under "start" and "stop" properties!';
}

loader = options.loader;
}

function invalidProperties(){
if (options.loader.start && typeof(options.loader.start) === 'function'
&& options.loader.stop && typeof(options.loader.stop) === 'function') return false;

return true;
}

}

function main( element, configOptions ) {
Expand Down

0 comments on commit 110d916

Please sign in to comment.