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