diff options
author | Pierre Frisch | 2011-12-22 07:25:50 -0800 |
---|---|---|
committer | Valerio Virgillito | 2012-01-27 11:18:17 -0800 |
commit | b89a7ee8b956c96a1dcee995ea840feddc5d4b27 (patch) | |
tree | 0f3136ab0ecdbbbed6a83576581af0a53124d6f1 /node_modules/montage/ui/scroll.js | |
parent | 2401f05d1f4b94d45e4568b81fc73e67b969d980 (diff) | |
download | ninja-b89a7ee8b956c96a1dcee995ea840feddc5d4b27.tar.gz |
First commit of Ninja to ninja-internal
Signed-off-by: Valerio Virgillito <rmwh84@motorola.com>
Diffstat (limited to 'node_modules/montage/ui/scroll.js')
-rwxr-xr-x | node_modules/montage/ui/scroll.js | 820 |
1 files changed, 820 insertions, 0 deletions
diff --git a/node_modules/montage/ui/scroll.js b/node_modules/montage/ui/scroll.js new file mode 100755 index 00000000..f59ff9bb --- /dev/null +++ b/node_modules/montage/ui/scroll.js | |||
@@ -0,0 +1,820 @@ | |||
1 | /* <copyright> | ||
2 | This file contains proprietary software owned by Motorola Mobility, Inc.<br/> | ||
3 | No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> | ||
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | ||
5 | </copyright> */ | ||
6 | |||
7 | var Montage = require("montage").Montage, | ||
8 | defaultEventManager = require("core/event/event-manager").defaultEventManager; | ||
9 | |||
10 | var Scroll = exports.Scroll = Montage.create(Montage, { | ||
11 | |||
12 | _externalUpdate: { | ||
13 | enumerable: false, | ||
14 | value: true | ||
15 | }, | ||
16 | |||
17 | isAnimating: { | ||
18 | enumerable: false, | ||
19 | value: false | ||
20 | }, | ||
21 | |||
22 | component: { | ||
23 | value: {} | ||
24 | }, | ||
25 | |||
26 | _needsDraw: { | ||
27 | enumerable: false, | ||
28 | value: false | ||
29 | }, | ||
30 | |||
31 | needsDraw: { | ||
32 | get: function () { | ||
33 | return this._needsDraw; | ||
34 | }, | ||
35 | set: function (value) { | ||
36 | this._needsDraw = value; | ||
37 | if (this.component) { | ||
38 | this.component.needsDraw = true; | ||
39 | } | ||
40 | } | ||
41 | }, | ||
42 | |||
43 | draw: { | ||
44 | value: function () { | ||
45 | this._needsDraw = false; | ||
46 | if (this.isAnimating) { | ||
47 | this._animationInterval(); | ||
48 | } | ||
49 | this._externalUpdate = false; | ||
50 | } | ||
51 | }, | ||
52 | |||
53 | deserializedFromTemplate: { | ||
54 | value: function () { | ||
55 | var oldComponentDraw = this.component.draw, | ||
56 | self = this; | ||
57 | |||
58 | this.component.draw = function () { | ||
59 | self.draw(); | ||
60 | oldComponentDraw.call(self.component); | ||
61 | }; | ||
62 | } | ||
63 | }, | ||
64 | |||
65 | _pointerSpeedMultiplier: { | ||
66 | enumerable: false, | ||
67 | value: 1 | ||
68 | }, | ||
69 | |||
70 | pointerSpeedMultiplier: { | ||
71 | get: function () { | ||
72 | return this._pointerSpeedMultiplier; | ||
73 | }, | ||
74 | set: function (value) { | ||
75 | this._pointerSpeedMultiplier = value; | ||
76 | } | ||
77 | }, | ||
78 | |||
79 | pointerStartEventPosition: { | ||
80 | value: null | ||
81 | }, | ||
82 | |||
83 | _isSelfUpdate: { | ||
84 | enumerable: false, | ||
85 | value: false | ||
86 | }, | ||
87 | |||
88 | _scrollX: { | ||
89 | enumerable: false, | ||
90 | value: 0 | ||
91 | }, | ||
92 | |||
93 | scrollX: { | ||
94 | get: function () { | ||
95 | return this._scrollX; | ||
96 | }, | ||
97 | set: function (value) { | ||
98 | if (this._axis==="vertical") { | ||
99 | this._scrollX=0; | ||
100 | } else { | ||
101 | var tmp=isNaN(value)?0:value>>0; | ||
102 | |||
103 | if ((!this._hasBouncing)||(!this._isSelfUpdate)) { | ||
104 | if (tmp<0) { | ||
105 | tmp=0; | ||
106 | } | ||
107 | if (tmp>this._maxScrollX) { | ||
108 | tmp=this._maxScrollX; | ||
109 | } | ||
110 | if (!this._isSelfUpdate) { | ||
111 | this.isAnimating = false; | ||
112 | } | ||
113 | } | ||
114 | this._scrollX=tmp; | ||
115 | } | ||
116 | } | ||
117 | }, | ||
118 | |||
119 | _scrollY: { | ||
120 | enumerable: false, | ||
121 | value: 0 | ||
122 | }, | ||
123 | |||
124 | scrollY: { | ||
125 | get: function () { | ||
126 | return this._scrollY; | ||
127 | }, | ||
128 | set: function (value) { | ||
129 | if (this._axis==="horizontal") { | ||
130 | this._scrollY=0; | ||
131 | } else { | ||
132 | var tmp=isNaN(value)?0:value>>0; | ||
133 | |||
134 | if ((!this._hasBouncing)||(!this._isSelfUpdate)) { | ||
135 | if (tmp<0) { | ||
136 | tmp=0; | ||
137 | } | ||
138 | if (tmp>this._maxScrollY) { | ||
139 | tmp=this._maxScrollY; | ||
140 | } | ||
141 | if (!this._isSelfUpdate) { | ||
142 | this.isAnimating = false; | ||
143 | } | ||
144 | } | ||
145 | this._scrollY=tmp; | ||
146 | } | ||
147 | } | ||
148 | }, | ||
149 | |||
150 | _maxScrollX: { | ||
151 | enumerable: false, | ||
152 | value: 0 | ||
153 | }, | ||
154 | |||
155 | maxScrollX: { | ||
156 | get: function () { | ||
157 | return this._maxScrollX; | ||
158 | }, | ||
159 | set: function (value) { | ||
160 | var tmp=isNaN(value)?0:value>>0; | ||
161 | |||
162 | if (tmp<0) { | ||
163 | tmp=0; | ||
164 | } | ||
165 | if (this._maxScrollX!=tmp) { | ||
166 | if (this._scrollX>this._maxScrollX) { | ||
167 | this.scrollX=this._maxScrollX; | ||
168 | } | ||
169 | this._maxScrollX=tmp; | ||
170 | } | ||
171 | } | ||
172 | }, | ||
173 | |||
174 | _maxScrollY: { | ||
175 | enumerable: false, | ||
176 | value: 0 | ||
177 | }, | ||
178 | |||
179 | maxScrollY: { | ||
180 | get: function () { | ||
181 | return this._maxScrollY; | ||
182 | }, | ||
183 | set: function (value) { | ||
184 | var tmp=isNaN(value)?0:value>>0; | ||
185 | |||
186 | if (tmp<0) { | ||
187 | tmp=0; | ||
188 | } | ||
189 | if (this._maxScrollY!=tmp) { | ||
190 | if (this._scrollY>this._maxScrollY) { | ||
191 | this.scrollY=this._maxScrollY; | ||
192 | } | ||
193 | this._maxScrollY=tmp; | ||
194 | } | ||
195 | } | ||
196 | }, | ||
197 | |||
198 | _element: { | ||
199 | enumerable: false, | ||
200 | value: null | ||
201 | }, | ||
202 | |||
203 | element: { | ||
204 | get: function () { | ||
205 | return this._element; | ||
206 | }, | ||
207 | set: function (element) { | ||
208 | if (this._element !== element) { | ||
209 | this._element = element; | ||
210 | this.prepareForActivationEvents(); | ||
211 | } | ||
212 | } | ||
213 | }, | ||
214 | |||
215 | _axis: { | ||
216 | enumerable: false, | ||
217 | value: "both" | ||
218 | }, | ||
219 | |||
220 | axis: { | ||
221 | get: function () { | ||
222 | return this._axis; | ||
223 | }, | ||
224 | set: function (value) { | ||
225 | switch (value) { | ||
226 | case "vertical": | ||
227 | case "horizontal": | ||
228 | this._axis=value; | ||
229 | break; | ||
230 | default: | ||
231 | this._axis="both"; | ||
232 | break; | ||
233 | } | ||
234 | } | ||
235 | }, | ||
236 | |||
237 | _hasMomentum: { | ||
238 | enumerable: false, | ||
239 | value: true | ||
240 | }, | ||
241 | |||
242 | hasMomentum: { |