| 1 |
define([ |
| 2 |
"dojo/_base/lang", |
| 3 |
"dojo/_base/fx", |
| 4 |
"dojo/dom-style" |
| 5 |
], function(lang, fx, domStyle) { |
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
var DOWN = 2, |
| 10 |
RIGHT = 3, |
| 11 |
UP = 0, |
| 12 |
LEFT = 1; |
| 13 |
|
| 14 |
function _clipArray(type, w, h, x){ |
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
var a = [0, w, 0, 0]; |
| 20 |
if(type == RIGHT){ |
| 21 |
a = [0, w, h, w]; |
| 22 |
}else if(type == UP){ |
| 23 |
a = [h, w, h, 0]; |
| 24 |
}else if(type == LEFT){ |
| 25 |
a = [0, 0, h, 0]; |
| 26 |
} |
| 27 |
if(x != null){ |
| 28 |
a[type] = type == DOWN || type == LEFT ? x : (type % 2 ? w : h) - x; |
| 29 |
} |
| 30 |
return a; |
| 31 |
} |
| 32 |
|
| 33 |
function _setClip(n, type, w, h, x){ |
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
domStyle.set(n, "clip", type == null ? "auto" : "rect(" + _clipArray(type, w, h, x).join("px,") + "px)"); |
| 38 |
} |
| 39 |
|
| 40 |
function _wipe(type, args){ |
| 41 |
|
| 42 |
|
| 43 |
var node = args.next.node, |
| 44 |
w = args.rotatorBox.w, |
| 45 |
h = args.rotatorBox.h; |
| 46 |
|
| 47 |
domStyle.set(node, { |
| 48 |
display: "", |
| 49 |
zIndex: (domStyle.get(args.current.node, "zIndex") || 1) + 1 |
| 50 |
}); |
| 51 |
|
| 52 |
_setClip(node, type, w, h); |
| 53 |
|
| 54 |
return new fx.Animation(lang.mixin({ |
| 55 |
node: node, |
| 56 |
curve: [0, type % 2 ? w : h], |
| 57 |
onAnimate: function(x){ |
| 58 |
_setClip(node, type, w, h, parseInt(x)); |
| 59 |
} |
| 60 |
}, args)); |
| 61 |
} |
| 62 |
|
| 63 |
var exports = { |
| 64 |
wipeDown: function(args){ |
| 65 |
|
| 66 |
|
| 67 |
return _wipe(DOWN, args); |
| 68 |
}, |
| 69 |
|
| 70 |
wipeRight: function(args){ |
| 71 |
|
| 72 |
|
| 73 |
return _wipe(RIGHT, args); |
| 74 |
}, |
| 75 |
|
| 76 |
wipeUp: function(args){ |
| 77 |
|
| 78 |
|
| 79 |
return _wipe(UP, args); |
| 80 |
}, |
| 81 |
|
| 82 |
wipeLeft: function(args){ |
| 83 |
|
| 84 |
|
| 85 |
return _wipe(LEFT, args); |
| 86 |
} |
| 87 |
}; |
| 88 |
|
| 89 |
|
| 90 |
lang.mixin(lang.getObject("dojox.widget.rotator"), exports); |
| 91 |
|
| 92 |
return exports; |
| 93 |
}); |