| 1 |
define(["dojo/_base/fx", |
| 2 |
"dojo/fx", |
| 3 |
"dojo/_base/lang", |
| 4 |
"dojo/fx/easing", |
| 5 |
"dojox/fx"], |
| 6 |
function(baseFx, coreFx, lang, easingUtil, dojoxFx){ |
| 7 |
|
| 8 |
var reverseApi = { |
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
_reversed: false, |
| 20 |
reverse: function(keepPaused, reverseEase){ |
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
var playing = this.status() == "playing"; |
| 33 |
this.pause(); |
| 34 |
this._reversed = !this._reversed; |
| 35 |
var d = this.duration, |
| 36 |
sofar = d * this._percent, |
| 37 |
togo = d - sofar, |
| 38 |
curr = new Date().valueOf(), |
| 39 |
cp = this.curve._properties, |
| 40 |
p = this.properties, |
| 41 |
nm |
| 42 |
; |
| 43 |
this._endTime = curr + sofar; |
| 44 |
this._startTime = curr - togo; |
| 45 |
|
| 46 |
if(playing){ |
| 47 |
this.gotoPercent(togo / d) |
| 48 |
} |
| 49 |
for(nm in p){ |
| 50 |
var tmp = p[nm].start; |
| 51 |
p[nm].start = cp[nm].start = p[nm].end; |
| 52 |
p[nm].end = cp[nm].end = tmp; |
| 53 |
} |
| 54 |
|
| 55 |
if(this._reversed){ |
| 56 |
if(!this.rEase){ |
| 57 |
this.fEase = this.easing; |
| 58 |
if(reverseEase){ |
| 59 |
this.rEase = reverseEase; |
| 60 |
}else{ |
| 61 |
|
| 62 |
var de = easingUtil, found, eName; |
| 63 |
for(nm in de){ |
| 64 |
if(this.easing == de[nm]){ |
| 65 |
|
| 66 |
found = nm; break; |
| 67 |
} |
| 68 |
} |
| 69 |
|
| 70 |
if(found){ |
| 71 |
|
| 72 |
if(/InOut/.test(nm) || !/In|Out/i.test(nm)){ |
| 73 |
this.rEase = this.easing; |
| 74 |
}else if(/In/.test(nm)){ |
| 75 |
eName = nm.replace("In", "Out"); |
| 76 |
}else{ |
| 77 |
eName = nm.replace("Out", "In"); |
| 78 |
} |
| 79 |
if(eName){ |
| 80 |
this.rEase = easingUtil[eName]; |
| 81 |
} |
| 82 |
}else{ |
| 83 |
|
| 84 |
console.info("ease function to reverse not found"); |
| 85 |
this.rEase = this.easing; |
| 86 |
} |
| 87 |
} |
| 88 |
|
| 89 |
} |
| 90 |
this.easing = this.rEase; |
| 91 |
}else{ |
| 92 |
this.easing = this.fEase; |
| 93 |
} |
| 94 |
if(!keepPaused && this.status() != "playing"){ |
| 95 |
this.play(); |
| 96 |
} |
| 97 |
|
| 98 |
return this; |
| 99 |
} |
| 100 |
}; |
| 101 |
lang.extend( baseFx.Animation, reverseApi); |
| 102 |
return baseFx.Animation; |
| 103 |
}); |