jqmobi-rails 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. data/.gitignore +17 -0
  2. data/Gemfile +8 -0
  3. data/LICENSE +22 -0
  4. data/README.md +29 -0
  5. data/Rakefile +68 -0
  6. data/jqmobi-rails.gemspec +17 -0
  7. data/lib/jqmobi/rails/engine.rb +6 -0
  8. data/lib/jqmobi/rails/version.rb +7 -0
  9. data/lib/jqmobi/rails.rb +7 -0
  10. data/lib/jqmobi-rails.rb +1 -0
  11. data/vendor/assets/javascripts/jq.mobi.js +1894 -0
  12. data/vendor/assets/javascripts/jq.mobi_ujs.js +393 -0
  13. data/vendor/assets/javascripts/jq.ui.js +3396 -0
  14. data/vendor/assets/javascripts/plugins/jq.actionsheet.js +99 -0
  15. data/vendor/assets/javascripts/plugins/jq.alphatable.js +136 -0
  16. data/vendor/assets/javascripts/plugins/jq.carousel.js +415 -0
  17. data/vendor/assets/javascripts/plugins/jq.css3animate.js +155 -0
  18. data/vendor/assets/javascripts/plugins/jq.drawer.js +224 -0
  19. data/vendor/assets/javascripts/plugins/jq.fx.js +110 -0
  20. data/vendor/assets/javascripts/plugins/jq.passwordBox.js +45 -0
  21. data/vendor/assets/javascripts/plugins/jq.popup.js +201 -0
  22. data/vendor/assets/javascripts/plugins/jq.scroller.js +540 -0
  23. data/vendor/assets/javascripts/plugins/jq.selectBox.js +315 -0
  24. data/vendor/assets/javascripts/plugins/jq.shake.js +39 -0
  25. data/vendor/assets/javascripts/plugins/jq.social.js +113 -0
  26. data/vendor/assets/javascripts/plugins/jq.swipe.js +121 -0
  27. data/vendor/assets/javascripts/plugins/jq.template.js +26 -0
  28. data/vendor/assets/javascripts/plugins/jq.web.min.js +66 -0
  29. data/vendor/assets/stylesheets/plugins/jq.actionsheet.css +57 -0
  30. data/vendor/assets/stylesheets/plugins/jq.popup.css +73 -0
  31. data/vendor/assets/stylesheets/plugins/jq.scroller.css +10 -0
  32. data/vendor/assets/stylesheets/plugins/jq.selectBox.css +35 -0
  33. metadata +77 -0
@@ -0,0 +1,540 @@
1
+ /**
2
+ * jq.scroller - a scrolling library for jqMobi apps
3
+ * Copyright 2011 - AppMobi
4
+ */
5
+ (function($) {
6
+ var cache = [];
7
+ $.fn["scroller"] = function(opts) {
8
+ var tmp;
9
+ if (opts === undefined && this.length > 0)
10
+ {
11
+ return cache[this[0].id] ? cache[this[0].id] : null;
12
+ }
13
+ for (var i = 0; i < this.length; i++) {
14
+ tmp = new scroller(this[i], opts);
15
+ if (this[i].id)
16
+ cache[this[i].id] = tmp;
17
+ }
18
+ return this.length == 1 ? tmp : this;
19
+ };
20
+ var scroller = (function() {
21
+ if (!window.WebKitCSSMatrix)
22
+ return;
23
+ var translateOpen = 'm11' in new WebKitCSSMatrix() ? "3d(" : "(";
24
+ var translateClose = 'm11' in new WebKitCSSMatrix() ? ",0)" : ")";
25
+ var touchStarted = false;
26
+
27
+ var scroller = function(elID, opts) {
28
+
29
+ if (typeof elID == "string" || elID instanceof String) {
30
+ this.el = document.getElementById(elID);
31
+ } else {
32
+ this.el = elID;
33
+ }
34
+ if (!this.el) {
35
+ alert("Could not find element for scroller " + elID);
36
+ return;
37
+ }
38
+
39
+ if (this instanceof scroller) {
40
+ for (j in opts) {
41
+ this[j] = opts[j];
42
+ }
43
+ } else {
44
+ return new scroller(elID, opts);
45
+ }
46
+ try {
47
+ this.container = this.el.parentNode;
48
+ this.initEvents();
49
+ var windowHeight = window.innerHeight;
50
+ var windowWidth = window.innerWidth;
51
+
52
+
53
+ if (this.verticalScroll && this.verticalScroll == true && this.scrollBars == true) {
54
+ var scrollDiv = createScrollBar(5, 20);
55
+ scrollDiv.style.top = "0px";
56
+ if (this.vScrollCSS)
57
+ scrollDiv.className = this.vScrollCSS;
58
+ scrollDiv.style.opacity = "0";
59
+ this.container.appendChild(scrollDiv);
60
+ this.vscrollBar = scrollDiv;
61
+ scrollDiv = null;
62
+ }
63
+ if (this.horizontalScroll && this.horizontalScroll == true && this.scrollBars == true) {
64
+ var scrollDiv = createScrollBar(20, 5);
65
+ scrollDiv.style.bottom = "0px";
66
+
67
+ if (this.hScrollCSS)
68
+ scrollDiv.className = this.hScrollCSS;
69
+ scrollDiv.style.opacity = "0";
70
+ this.container.appendChild(scrollDiv);
71
+ this.hscrollBar = scrollDiv;
72
+ scrollDiv = null;
73
+ }
74
+ if (this.horizontalScroll)
75
+ this.el.style['float'] = "left";
76
+
77
+ $(this.el).addClass("jq-scrollable");
78
+ this.el.hasScroller=true;
79
+ } catch (e) {
80
+ alert("error adding scroller" + e);
81
+ }
82
+
83
+ };
84
+
85
+ function createScrollBar(width, height) {
86
+ var scrollDiv = document.createElement("div");
87
+ scrollDiv.style.position = 'absolute';
88
+ scrollDiv.style.width = width + "px";
89
+ scrollDiv.style.height = height + "px";
90
+ scrollDiv.style.webkitBorderRadius = "2px";
91
+ scrollDiv.style.opacity = 0;
92
+ scrollDiv.className = 'scrollBar';
93
+ scrollDiv.style.background = "black";
94
+ return scrollDiv;
95
+ }
96
+
97
+ scroller.prototype = {
98
+ lockX: 0,
99
+ lockY: 0,
100
+ boolScrollLock: false,
101
+ currentScrollingObject: null,
102
+ bottomMargin: 0,
103
+ maxTop: 0,
104
+ startTop: 0,
105
+ verticalScroll: true,
106
+ horizontalScroll: false,
107
+ scrollBars: true,
108
+ vscrollBar: null,
109
+ hscrollBar: null,
110
+ hScrollCSS: "scrollBar",
111
+ vScrollCSS: "scrollBar",
112
+ divHeight: 0,
113
+ lastScrollbar: "",
114
+ timeMoved: 0,
115
+ vdistanceMoved: 0,
116
+ hdistanceMoved: 0,
117
+ prevTime: 0,
118
+ finishScrollingObject: null,
119
+ container: null,
120
+ maxLeft: 0,
121
+ startLeft: 0,
122
+ rightMargin: 0,
123
+ divWidth: 0,
124
+ refresh: false,
125
+ refreshFunction: null,
126
+ listeners: {
127
+ start: "",
128
+ move: "",
129
+ end: ""
130
+ },
131
+ elementScrolling:false,
132
+ scrollingFinishCB:false,
133
+ handleEvent: function(e) {
134
+ switch(e.type) {
135
+ case 'touchstart': this.touchStart(e); break;
136
+ case 'touchmove': this.touchMove(e); break;
137
+ case 'touchend': this.touchEnd(e); break;
138
+ }
139
+ },
140
+ initEvents: function () {
141
+ this.el.addEventListener('touchstart', this, false);
142
+ this.el.addEventListener('touchmove', this, false);
143
+ this.el.addEventListener('touchend', this, false);
144
+ },
145
+ removeEvents: function () {
146
+ this.el.removeEventListener('touchstart', this);
147
+ this.el.removeEventListener('touchmove', this);
148
+ this.el.removeEventListener('touchend', this);
149
+ },
150
+ hideScrollbars: function() {
151
+ if (this.hscrollBar)
152
+ {
153
+ this.hscrollBar.style.opacity = 0
154
+ this.hscrollBar.style.webkitTransitionDuration = "0ms";
155
+ }
156
+ if (this.vscrollBar){
157
+ this.vscrollBar.style.opacity = 0
158
+ this.vscrollBar.style.webkitTransitionDuration = "0ms";
159
+ }
160
+ },
161
+ touchStart: function(event) {
162
+ var container = this.container;
163
+ var eleScrolling = this.el;
164
+ that=this;
165
+ if (!container)
166
+ return;
167
+ if(this.elementScrolling){
168
+ clearTimeout(that.scrollingFinishCB);
169
+ }
170
+ touchStarted = true
171
+ if( $(this.el).hasClass("blockscroll"))
172
+ return;
173
+ try {
174
+ // Allow interaction to legit calls, like select boxes, etc.
175
+ if (event.touches[0].target && event.touches[0].target.type != undefined) {
176
+ var tagname = event.touches[0].target.tagName.toLowerCase();
177
+ if (tagname == "select" || tagname == "input" || tagname == "button") // stuff we need to allow
178
+ // access to
179
+ return;
180
+ }
181
+ //Add the pull to refresh text. Not optimal but keeps from others overwriting the content and worrying about italics
182
+ if (this.refresh && this.refresh == true && document.getElementById(this.el.id + "_pulldown") == null) {
183
+ //add the refresh div
184
+ var text = jq("<div id='" + this.el.id + "_pulldown' class='jqscroll_refresh' style='border-radius:.6em;border: 1px solid #2A2A2A;background-image: -webkit-gradient(linear,left top,left bottom,color-stop(0,#666666),color-stop(1,#222222));background:#222222;margin:0px;height:60px;top:0px;margin-left:5px;margin-right:5px;position:absolute;-webkit-transform: translate3d(0, -65px, 0);top:0,left:0,right:0;text-align:center;line-height:60px;color:white;'>Pull to Refresh</div>").get();
185
+ text.style.width = this.container.clientWidth + "px";
186
+ $(this.el).prepend(text);
187
+ }
188
+
189
+
190
+ this.timeMoved = 0;
191
+ this.vdistanceMoved = 0;
192
+ this.hdistanceMoved = 0;
193
+ this.prevTime = null;
194
+ this.finishScrollingObject = null;
195
+ var cnt=$(container);
196
+ this.bottomMargin = container.clientHeight > window.innerHeight ? window.innerHeight : container.clientHeight-numOnly(cnt.css("marginTop"))-numOnly(cnt.css("paddingTop"))-numOnly(cnt.css("marginBottom"))-numOnly(cnt.css("paddingBottom")); //handle css offsets
197
+ this.maxTop = eleScrolling.clientHeight - this.bottomMargin;
198
+ this.divHeight = eleScrolling.clientHeight;
199
+ this.rightMargin = container.clientWidth > window.innerWidth ? window.innerWidth : container.clientWidth-numOnly(cnt.css("marginLeft"))-numOnly(cnt.css("paddingLeft"))-numOnly(cnt.css("marginRight"))-numOnly(cnt.css("paddingRight"));
200
+ this.maxLeft = eleScrolling.clientWidth - this.rightMargin;
201
+ this.divWidth = eleScrolling.clientWidth;
202
+ if (this.maxTop < 0 && this.maxLeft < 0)
203
+ return;
204
+
205
+ this.lockX = event.touches[0].pageX;
206
+ this.lockY = event.touches[0].pageY;
207
+ if (event.touches.length == 1 && this.boolScrollLock == false) {
208
+ try {
209
+ this.startTop = numOnly(new WebKitCSSMatrix(window.getComputedStyle(eleScrolling).webkitTransform).f) - numOnly(this.container.scrollTop);
210
+ this.startLeft = numOnly(new WebKitCSSMatrix(window.getComputedStyle(eleScrolling).webkitTransform).e) - numOnly(this.container.scrollLeft);
211
+
212
+ } catch (e) {
213
+ this.startTop = 0 + this.container.scrollTop;
214
+ this.startLeft = 0 + this.container.scrollLeft;
215
+ console.log("error scroller touchstart " + e);
216
+ }
217
+ this.container.scrollTop = this.container.scrollLeft = 0;
218
+ this.currentScrollingObject = eleScrolling;
219
+ this.scrollerMoveCSS(eleScrolling, {
220
+ x: this.startLeft,
221
+ y: this.startTop
222
+ }, 0);
223
+ if (this.vscrollBar && this.maxTop > 0) {
224
+ this.vscrollBar.style.height = (parseFloat(this.bottomMargin / this.divHeight) * this.bottomMargin) + "px";
225
+ var pos = (this.bottomMargin - numOnly(this.vscrollBar.style.height)) - (((this.maxTop + this.startTop) / this.maxTop) * (this.bottomMargin - numOnly(this.vscrollBar.style.height)));
226
+ this.scrollerMoveCSS(this.vscrollBar, {
227
+ x: 0,
228
+ y: pos
229
+ }, 0);
230
+
231
+
232
+ if (this.container.clientWidth > window.innerWidth)
233
+ this.vscrollBar.style.left = (window.innerWidth - numOnly(this.vscrollBar.style.width) * 3) + "px";
234
+ else
235
+ this.vscrollBar.style.right = "0px";
236
+ this.vscrollBar.webkitTransition = '';
237
+ // this.vscrollBar.style.opacity = 1;
238
+ }
239
+
240
+ if (this.hscrollBar && this.maxLeft > 0) {
241
+ this.hscrollBar.style.width = (parseFloat(this.rightMargin / this.divWidth) * this.rightMargin) + "px";
242
+ var pos = (this.rightMargin - numOnly(this.hscrollBar.style.width)) - (((this.maxTop + this.startLeft) / this.maxtLeft) * (this.rightMargin - numOnly(this.hscrollBar.style.width)));
243
+ this.scrollerMoveCSS(this.hscrollBar, {
244
+ x: pos,
245
+ y: 0
246
+ }, 0);
247
+ if (this.container.clientHeight > window.innerHeight)
248
+ this.hscrollBar.style.top = (window.innerHeight - numOnly(this.hscrollBar.style.height)) + "px";
249
+ else
250
+ this.hscrollBar.style.bottom = numOnly(this.hscrollBar.style.height);
251
+ this.vscrollBar.webkitTransition = '';
252
+
253
+ // this.hscrollBar.style.opacity = 1;
254
+ }
255
+
256
+ //event.preventDefault();
257
+ // get the scrollbar
258
+ }
259
+ } catch (e) {
260
+ alert("error in scrollStart: " + e);
261
+ }
262
+ },
263
+ touchMove: function(event) {
264
+ try {
265
+ if( $(this.el).hasClass("blockscroll"))
266
+ return;
267
+ if (this.currentScrollingObject != null) {
268
+ event.preventDefault();
269
+ var scrollPoints = {
270
+ x: 0,
271
+ y: 0
272
+ };
273
+ var scrollbarPoints = {
274
+ x: 0,
275
+ y: 0
276
+ };
277
+ var newTop = 0,
278
+ prevTop = 0,
279
+ newLeft = 0,
280
+ prevLeft = 0;
281
+
282
+ if (this.verticalScroll && this.maxTop > 0) {
283
+ var deltaY = this.lockY - event.touches[0].pageY;
284
+ deltaY = -deltaY;
285
+ var newTop = this.startTop + deltaY;
286
+ var top = -newTop;
287
+ try {
288
+ var prevTop = numOnly(new WebKitCSSMatrix(window.getComputedStyle(this.el).webkitTransform).f);
289
+ } catch (prevTopE) {
290
+ var prevTop = 0;
291
+ }
292
+
293
+ scrollPoints.y = newTop;
294
+ }
295
+ if (this.horizontalScroll && this.maxLeft > 0) {
296
+ var deltaX = this.lockX - event.touches[0].pageX;
297
+ deltaX = -deltaX;
298
+ var newLeft = this.startLeft + deltaX;
299
+ var left = newLeft;
300
+ try {
301
+ var prevLeft = -numOnly((new WebKitCSSMatrix(window.getComputedStyle(this.el).webkitTransform).e));
302
+ } catch (prevLeftE) {
303
+ var prevLeft = 0;
304
+ }
305
+ scrollPoints.x = left;
306
+
307
+ }
308
+ var time = 0;
309
+ if ((this.maxTop > 0) && (scrollPoints.y > 0 || scrollPoints.y < -1 * this.maxTop))
310
+ {
311
+
312
+ var overflow = scrollPoints.y > 0 ? (scrollPoints.y) : -1 * (scrollPoints.y + this.maxTop);
313
+ var height = (this.container.clientHeight - overflow) / this.container.clientHeight;
314
+ if (height < .5)
315
+ height = .5;
316
+ if (scrollPoints.y > 0)
317
+ scrollPoints.y = scrollPoints.y * height;
318
+ else {
319
+ scrollPoints.y = scrollPoints.y - ((scrollPoints.y + this.maxTop) * height);
320
+
321
+ }
322
+ }
323
+ this.scrollerMoveCSS(this.currentScrollingObject, scrollPoints, time);
324
+
325
+ if (this.vscrollBar) {
326
+ // We must calculate the position. Since we don't allow
327
+ // the page to scroll to the full content height, we use
328
+ // maxTop as height to work with.
329
+ var pos = (this.bottomMargin - numOnly(this.vscrollBar.style.height)) - (((this.maxTop + newTop) / this.maxTop) * (this.bottomMargin - numOnly(this.vscrollBar.style.height)));
330
+ this.scrollerMoveCSS(this.vscrollBar, {
331
+ x: 0,
332
+ y: pos
333
+ }, 0);
334
+ this.vscrollBar.style.opacity=1;
335
+ }
336
+ if (this.hscrollBar) {
337
+ // We must calculate the position. Since we don't allow
338
+ // the page to scroll to the full content height, we use
339
+ // maxTop as height to work with.
340
+ var pos = (this.rightMargin - numOnly(this.hscrollBar.style.width)) - (((this.maxLeft + newLeft) / this.maxLeft) * (this.rightMargin - numOnly(this.hscrollBar.style.width)));
341
+ this.scrollerMoveCSS(this.hscrollBar, {
342
+ x: pos,
343
+ y: 0
344
+ }, 0);
345
+ this.hscrollBar.style.opacity=1;
346
+ }
347
+
348
+ if (this.prevTime) {
349
+ var tmpDistanceY = Math.abs(prevTop) - Math.abs(newTop);
350
+ var tmpDistanceX = Math.abs(prevLeft) - Math.abs(newLeft);
351
+ var tmpTime = event.timeStamp - this.prevTime;
352
+ if (tmpTime < 500) { // movement is under a second,
353
+ // keep adding the differences
354
+ this.timeMoved += tmpTime;
355
+ this.vdistanceMoved += tmpDistanceY;
356
+ this.hdistanceMoved += tmpDistanceX;
357
+ } else { // We haven't moved in a second, lets reset
358
+ // the variables
359
+ this.timeMoved = 0;
360
+ this.vdistanceMoved = 0;
361
+ this.hdistanceMoved = 0;
362
+ }
363
+ }
364
+ this.prevTime = event.timeStamp;
365
+ }
366
+ } catch (e) {
367
+ alert("error in scrollMove: " + e);
368
+ }
369
+ },
370
+ touchEnd: function(event) {
371
+
372
+ if (this.currentScrollingObject != null) {
373
+ //if (this.timeMoved == 0)
374
+ //{
375
+ //event.preventDefault();
376
+ // if (this.onclick !== undefined)
377
+ // this.onclick();
378
+ // return false;
379
+ // }
380
+
381
+ event.preventDefault();
382
+ this.finishScrollingObject = this.currentScrollingObject;
383
+ this.currentScrollingObject = null;
384
+ var scrollPoints = {
385
+ x: 0,
386
+ y: 0
387
+ };
388
+ var time = 300;
389
+ var moveY;
390
+ if (this.verticalScroll && this.maxTop > 0) {
391
+ var myDistance = -this.vdistanceMoved;
392
+ var time = this.timeMoved;
393
+
394
+
395
+ var move = numOnly(new WebKitCSSMatrix(window.getComputedStyle(this.el).webkitTransform).f);
396
+ moveY = move;
397
+
398
+ var data = this.calculateMomentum(myDistance, time);
399
+ time = data.time;
400
+ if (move < 0)
401
+ move = move - data.dist;
402
+
403
+ if (move > 0) {
404
+ move = 0;
405
+ time = 200;
406
+ }
407
+
408
+ if (move < (-this.maxTop)) {
409
+ move = -this.maxTop;
410
+ time = 200;
411
+ }
412
+
413
+ scrollPoints.y = move;
414
+ }
415
+ if (this.horizontalScroll && this.maxLeft > 0) {
416
+ var myDistance = -this.hdistanceMoved;
417
+ var time = this.timeMoved;
418
+
419
+ var move = (new WebKitCSSMatrix(window.getComputedStyle(this.el).webkitTransform).e);
420
+ var data = this.calculateMomentum(myDistance, time);
421
+ time = data.time;
422
+ if (move < 0)
423
+ move = move - data.dist;
424
+
425
+ if (move > 0) {
426
+ move = 0;
427
+ time = 200;
428
+ }
429
+
430
+ if (move < (-this.maxLeft)) {
431
+ move = -this.maxLeft;
432
+ time = 200;
433
+ }
434
+ scrollPoints.x = move;
435
+ }
436
+ var that = this;
437
+ if (this.refresh && moveY > 60) {
438
+ if (this.refreshFunction) {
439
+ this.refreshFunction.call();
440
+ }
441
+ }
442
+ if (time < 300)
443
+ time = 300
444
+ this.scrollerMoveCSS(this.finishScrollingObject, scrollPoints, time, "cubic-bezier(0.33,0.66,0.66,1)");
445
+ if (this.vscrollBar) {
446
+ var pos = (this.bottomMargin - numOnly(this.vscrollBar.style.height)) - (((this.maxTop + scrollPoints.y) / this.maxTop) * (this.bottomMargin - numOnly(this.vscrollBar.style.height)));
447
+ if (pos > this.bottomMargin)
448
+ pos = this.bottomMargin;
449
+ if (pos < 0)
450
+ pos = 0;
451
+ this.scrollerMoveCSS(this.vscrollBar, {
452
+ x: 0,
453
+ y: pos
454
+ }, time, "cubic-bezier(0.33,0.66,0.66,1)");
455
+ }
456
+ if (this.hscrollBar) {
457
+ var pos = (this.rightMargin - numOnly(this.hscrollBar.style.width)) - (((this.maxLeft + scrollPoints.x) / this.maxLeft) * (this.rightMargin - numOnly(this.hscrollBar.style.width)));
458
+ if (pos > this.rightMargin)
459
+ pos = this.rightMargin;
460
+ if (pos < 0)
461
+ pos = 0;
462
+ this.scrollerMoveCSS(this.hscrollBar, {
463
+ x: pos,
464
+ y: 0
465
+ }, time, "cubic-bezier(0.33,0.66,0.66,1)");
466
+ }
467
+
468
+ if(isNaN(time))
469
+ that.hideScrollbars(),that.elementScrolling=false
470
+ else
471
+ this.scrollingFinishCB=setTimeout(function(){that.hideScrollbars();that.elementScrolling=false},time);
472
+ this.elementScrolling=true;
473
+ }
474
+ this.hdistanceMoved = 0;
475
+ this.vdistanceMoved = 0;
476
+ touchStarted = false;
477
+ },
478
+
479
+ scrollerMoveCSS: function(el, distanceToMove, time, timingFunction) {
480
+ if (!time)
481
+ time = 0;
482
+ if (!timingFunction)
483
+ timingFunction = "linear";
484
+
485
+ el.style.webkitTransform = "translate" + translateOpen + distanceToMove.x + "px," + distanceToMove.y + "px" + translateClose;
486
+ el.style.webkitTransitionDuration = time + "ms";
487
+ el.style.webkitBackfaceVisiblity = "hidden";
488
+ el.style.webkitTransitionTimingFunction = timingFunction;
489
+ },
490
+
491
+ scrollTo: function(pos, time) {
492
+ if (!time)
493
+ time = 0;
494
+ this.scrollerMoveCSS(this.el, pos, time);
495
+ if (this.vscrollBar) {
496
+ var pos = (this.bottomMargin - numOnly(this.vscrollBar.style.height)) - (((this.maxTop + pos.y) / this.maxTop) * (this.bottomMargin - numOnly(this.vscrollBar.style.height)));
497
+ if (pos > this.bottomMargin)
498
+ pos = this.bottomMargin;
499
+ if (pos < 0)
500
+ pos = 0;
501
+ this.scrollerMoveCSS(this.vscrollBar, {
502
+ x: 0,
503
+ y: pos
504
+ }, time, "ease-out");
505
+ this.vscrollBar.style.opacity = '0';
506
+
507
+ }
508
+ if (this.hscrollBar) {
509
+ var pos = (this.rightMargin - numOnly(this.hscrollBar.style.width)) - (((this.maxLeft + pos.x) / this.maxLeft) * (this.rightMargin - numOnly(this.hscrollBar.style.width)));
510
+ if (pos > this.rightMargin)
511
+ pos = this.rightMargin;
512
+ if (pos < 0)
513
+ pos = 0;
514
+ this.scrollerMoveCSS(this.hscrollBar, {
515
+ x: pos,
516
+ y: 0
517
+ }, time, "ease-out");
518
+ this.hscrollBar.style.opacity = '0';
519
+ }
520
+ },
521
+ scrollBy:function(pos,time) {
522
+ this.startTop = numOnly(new WebKitCSSMatrix(window.getComputedStyle(this.el).webkitTransform).f) - numOnly(this.container.scrollTop);
523
+ this.startLeft = numOnly(new WebKitCSSMatrix(window.getComputedStyle(this.el).webkitTransform).e) - numOnly(this.container.scrollLeft);
524
+ this.scrollTo({y:this.startTop-pos.y,x:this.startLeft-pos.x},time);
525
+ },
526
+
527
+ //Momentum adapted from iscroll4 http://www.cubiq.org
528
+ calculateMomentum: function(dist, time) {
529
+ var deceleration = 0.0012,
530
+ speed = Math.abs(dist) / time,
531
+ newDist = (speed * speed) / (2 * deceleration), newTime = 0
532
+
533
+ newDist = newDist * (dist < 0 ? -1 : 1);
534
+ newTime = speed / deceleration;
535
+ return {dist: newDist,time: newTime};
536
+ }
537
+ };
538
+ return scroller;
539
+ })();
540
+ })(jq);