samedi 14 février 2015

Checking the value of a variable inside unslider.js


i have a question about a plugin that i have been trying to debug for sometime . it a simple carousel plugin . heres what i wanna know.


there is this function ,



_this.play = function() {
// console.log('Inside _play function');
_this.t = setInterval(function() {
// console.log(_this.i);
_this.to(_this.i + 1);
}, _this.o.delay | 0);
};


the first time the above function executes it calls another function caled _this.to(_this.i + 1) , notice how it calls the function with a parameter _this.i .


_this.i is basically the following :



_this.i = 0;


now as soon as the _this.to function is called , the following happens :



_this.to = function (){


// alot of code , but that's irrelevant

_this.i = index;

}


ok so heres my difficulty and heres my question :


So the first time _this.play() calls _this.to() , _this.i = 0 , then _this.i enters _this.to() and now _this.i = index ?? Am i right . that would be my first question .


consider _this.play() is gonna call _this.to() more than once , lets say 3 time , does that mean , _this.i = 0 only the 1st time _this.to() is called and then on _this.i = index ?? so say the second time we say :



_this.play = function() {
_this.t = setInterval(function() {
_this.to(_this.i + 1);
}, _this.o.delay | 0);
};


What we are really saying on line 3 of the above function is



_this.to(index + 1)


?


am i right ?


I know its a twisted question , but i'am sure someone on here can answer it .


Thank you.


Alexander.





Aucun commentaire:

Enregistrer un commentaire