Jquery "this" overriding my objects "this"
I have the following code
- //Vanilla version
for(;i>=0; i--){
- squezeTimeLine.add( TweenLite.to(b[i], this.settings.firstStageSpeed, {scaleX:0.05, transformOrigin:"50 50"}),
- this.curve.getRatio(i/b.length) * 0.4);
- }
-
- //Jquery version
- $(b.get().reverse()).each(function(index){
- squezeTimeLine.add( TweenLite.to(this, myClass.settings.firstStageSpeed, {scaleX:0.05, transformOrigin:"50 50"}),
- myClass.curve.getRatio(index/b.length) * 10);
- })
Both functions do the same thing, the only difference is that in the Jquery version the list of objects "b" is inverted first so that iterator (index in the jquery versions, i in the vanilla version) is appears in the oposite order relative to the "b" objects being iterated over.
This is necessary in order to make the getRatio() function work properly.
Both functions are embedded in a objected called myClass
In the vanilla version i have been able to use
this.settings.firstStageSpeed
In the jquery version i have had to change this to
myClass.settings.firstStageSpeed
because this has been changed to refer to the current object being iterated over.
My question is this
Is there any way to preserve the original meaning of "this" inside the jquery each loop?
if not
Is there any other way to refer to
myClass.settings.firstStageSpeed in a way that is relative to the current instance of the myClass object?