]> git.proxmox.com Git - sencha-touch.git/blame - src/src/fx/animation/Slide.js
import Sencha Touch 2.4.2 source
[sencha-touch.git] / src / src / fx / animation / Slide.js
CommitLineData
c4685c84
TL
1/**
2 * @private
3 */
4Ext.define('Ext.fx.animation.Slide', {
5
6 extend: 'Ext.fx.animation.Abstract',
7
8 alternateClassName: 'Ext.fx.animation.SlideIn',
9
10 alias: ['animation.slide', 'animation.slideIn'],
11
12 config: {
13 /**
14 * @cfg {String} direction The direction of which the slide animates
15 * @accessor
16 */
17 direction: 'left',
18
19 /**
20 * @cfg {Boolean} out True if you want to make this animation slide out, instead of slide in.
21 * @accessor
22 */
23 out: false,
24
25 /**
26 * @cfg {Number} offset The offset that the animation should go offscreen before entering (or when exiting)
27 * @accessor
28 */
29 offset: 0,
30
31 /**
32 * @cfg
33 * @inheritdoc
34 */
35 easing: 'auto',
36
37 containerBox: 'auto',
38
39 elementBox: 'auto',
40
41 isElementBoxFit: true,
42
43 useCssTransform: true
44 },
45
46 reverseDirectionMap: {
47 up: 'down',
48 down: 'up',
49 left: 'right',
50 right: 'left'
51 },
52
53 applyEasing: function(easing) {
54 if (easing === 'auto') {
55 return 'ease-' + ((this.getOut()) ? 'in' : 'out');
56 }
57
58 return easing;
59 },
60
61 getContainerBox: function() {
62 var box = this._containerBox;
63
64 if (box === 'auto') {
65 box = this.getElement().getParent().getPageBox();
66 }
67
68 return box;
69 },
70
71 getElementBox: function() {
72 var box = this._elementBox;
73
74 if (this.getIsElementBoxFit()) {
75 return this.getContainerBox();
76 }
77
78 if (box === 'auto') {
79 box = this.getElement().getPageBox();
80 }
81
82 return box;
83 },
84
85 getData: function() {
86 var elementBox = this.getElementBox(),
87 containerBox = this.getContainerBox(),
88 box = elementBox ? elementBox : containerBox,
89 from = this.getFrom(),
90 to = this.getTo(),
91 out = this.getOut(),
92 offset = this.getOffset(),
93 direction = this.getDirection(),
94 useCssTransform = this.getUseCssTransform(),
95 reverse = this.getReverse(),
96 translateX = 0,
97 translateY = 0,
98 fromX, fromY, toX, toY;
99
100 if (reverse) {
101 direction = this.reverseDirectionMap[direction];
102 }
103
104 switch (direction) {
105 case this.DIRECTION_UP:
106 if (out) {
107 translateY = containerBox.top - box.top - box.height - offset;
108 }
109 else {
110 translateY = containerBox.bottom - box.bottom + box.height + offset;
111 }
112
113 break;
114
115 case this.DIRECTION_DOWN:
116 if (out) {
117 translateY = containerBox.bottom - box.bottom + box.height + offset;
118 }
119 else {
120 translateY = containerBox.top - box.height - box.top - offset;
121 }
122
123 break;
124
125 case this.DIRECTION_RIGHT:
126 if (out) {
127 translateX = containerBox.right - box.right + box.width + offset;
128 }
129 else {
130 translateX = containerBox.left - box.left - box.width - offset;
131 }
132
133 break;
134
135 case this.DIRECTION_LEFT:
136 if (out) {
137 translateX = containerBox.left - box.left - box.width - offset;
138 }
139 else {
140 translateX = containerBox.right - box.right + box.width + offset;
141 }
142
143 break;
144 }
145
146 fromX = (out) ? 0 : translateX;
147 fromY = (out) ? 0 : translateY;
148
149 if (useCssTransform) {
150 from.setTransform({
151 translateX: fromX,
152 translateY: fromY
153 });
154 }
155 else {
156 from.set('left', fromX);
157 from.set('top', fromY);
158 }
159
160 toX = (out) ? translateX : 0;
161 toY = (out) ? translateY : 0;
162
163 if (useCssTransform) {
164 to.setTransform({
165 translateX: toX,
166 translateY: toY
167 });
168 }
169 else {
170 to.set('left', toX);
171 to.set('top', toY);
172 }
173
174 return this.callParent(arguments);
175 }
176});