summaryrefslogtreecommitdiff
path: root/StoneIsland/platforms/android/assets/www/js/lib/etc/scroll.js
blob: 253921e15b1885fc36f04318adce5c894680cc56 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// stub for native scroller when in voiceover mode
function NativeScroll(el) {
  var Scroller = {
    x: 0,
    y: 0,
    $el: $(el),
  }

  Scroller.refresh = function(){}
  Scroller.on = function(){}
  Scroller.off = function(){}

  Scroller.scrollTo = function(x, y) {
    Scroller.$el.scrollTop(y)
  }
  Scroller.scrollToElement = function(selector) {
    var y = $(selector).offset().top
    Scroller.$el.scrollTop(y)
  }

  return Scroller
}

function ScrollFactory (el, opt) {
  if (accessibility.voiceOver) {
    return NativeScroll(el)
  }
  return new IScroll(el, opt)
}