]>
git.proxmox.com Git - sencha-touch.git/blob - src/src/fx/layout/card/Scroll.js
4 Ext
.define('Ext.fx.layout.card.Scroll', {
5 extend
: 'Ext.fx.layout.card.Abstract',
11 alias
: 'fx.layout.card.scroll',
17 constructor: function(config
) {
18 this.initConfig(config
);
21 getEasing: function() {
22 var easing
= this.easing
;
25 this.easing
= easing
= new Ext
.fx
.easing
.Linear();
31 updateDuration: function(duration
) {
32 this.getEasing().setDuration(duration
);
35 onActiveItemChange: function(cardLayout
, newItem
, oldItem
, options
, controller
) {
36 var direction
= this.getDirection(),
37 easing
= this.getEasing(),
38 containerElement
, inElement
, outElement
, containerWidth
, containerHeight
, reverse
;
40 if (newItem
&& oldItem
) {
41 if (this.isAnimating
) {
45 newItem
.setWidth('100%');
46 newItem
.setHeight('100%');
48 containerElement
= this.getLayout().container
.innerElement
;
49 containerWidth
= containerElement
.getWidth();
50 containerHeight
= containerElement
.getHeight();
52 inElement
= newItem
.renderElement
;
53 outElement
= oldItem
.renderElement
;
55 this.oldItem
= oldItem
;
56 this.newItem
= newItem
;
57 this.currentEventController
= controller
;
58 this.containerElement
= containerElement
;
59 this.isReverse
= reverse
= this.getReverse();
63 if (direction
== 'right') {
65 this.isReverse
= reverse
= !reverse
;
67 else if (direction
== 'down') {
69 this.isReverse
= reverse
= !reverse
;
72 if (direction
== 'left') {
75 startValue
: containerWidth
,
79 containerElement
.dom
.scrollLeft
= containerWidth
;
80 outElement
.setLeft(containerWidth
);
85 endValue
: containerWidth
88 inElement
.setLeft(containerWidth
);
94 startValue
: containerHeight
,
98 containerElement
.dom
.scrollTop
= containerHeight
;
99 outElement
.setTop(containerHeight
);
104 endValue
: containerHeight
107 inElement
.setTop(containerHeight
);
111 this.startAnimation();
117 startAnimation: function() {
118 this.isAnimating
= true;
119 this.getEasing().setStartTime(Date
.now());
120 Ext
.AnimationQueue
.start(this.doAnimationFrame
, this);
123 doAnimationFrame: function() {
124 var easing
= this.getEasing(),
125 direction
= this.getDirection(),
126 scroll
= 'scrollTop',
129 if (direction
== 'left' || direction
== 'right') {
130 scroll
= 'scrollLeft';
133 if (easing
.isEnded
) {
134 this.stopAnimation();
137 value
= easing
.getValue();
138 this.containerElement
.dom
[scroll
] = value
;
142 stopAnimation: function() {
144 direction
= me
.getDirection(),
146 oldItem
= me
.oldItem
,
147 newItem
= me
.newItem
;
149 if (direction
== 'left' || direction
== 'right') {
153 me
.currentEventController
.resume();
155 if (me
.isReverse
&& oldItem
&& oldItem
.renderElement
&& oldItem
.renderElement
.dom
) {
156 oldItem
.renderElement
[scroll
](null);
158 else if (newItem
&& newItem
.renderElement
&& newItem
.renderElement
.dom
) {
159 newItem
.renderElement
[scroll
](null);
162 Ext
.AnimationQueue
.stop(this.doAnimationFrame
, this);
163 me
.isAnimating
= false;
164 me
.fireEvent('animationend', me
);