Sha256: 8613bc0387af6ecc7d2060b94ed62255d9ea579597c2ccc3599753a678438d25

Contents?: true

Size: 1.07 KB

Versions: 19

Compression:

Stored size: 1.07 KB

Contents

$(document).ready ->
  touchOriginX = touchOriginY = 0
  $('body').on 'touchstart', (e) ->
    touchOriginX = e.originalEvent.touches[0].clientX
    touchOriginY = e.originalEvent.touches[0].clientY

  $('body').on 'touchmove', (e) ->
    directionX = e.originalEvent.touches[0].clientX - touchOriginX # <0 = left, >0 = right
    directionY = e.originalEvent.touches[0].clientY - touchOriginY # <0 = up, >0 = down

    $target = $(e.target)
    scrollables = $target.closest('.scroll, .scroll-y, .scroll-x')
    isTouchable = $target.closest('.touch').length
    isScrollable = scrollables.length and
      # Remove iOS rubber band effect - vertical
      ((not (directionY > 0 and scrollables.scrollTop() <= 0) and
      not (directionY < 0 and (scrollables.scrollTop() + scrollables.innerHeight()) >= scrollables[0].scrollHeight)) or
      # horizontal
      (not (directionX > 0 and scrollables.scrollLeft() <= 0) and
      not (directionX < 0 and (scrollables.scrollLeft() + scrollables.innerWidth()) >= scrollables[0].scrollWidth)))
    e.preventDefault() if isTouchable or !isScrollable

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
ela-4.1.6 app/js/vendor/poised/poised.general.coffee
ela-4.1.5 app/js/vendor/poised/poised.general.coffee
ela-4.1.4 app/js/vendor/poised/poised.general.coffee
ela-4.1.3 app/js/vendor/poised/poised.general.coffee
ela-4.1.2 app/js/vendor/poised/poised.general.coffee
ela-4.1.1 app/js/vendor/poised/poised.general.coffee
ela-4.1.0 app/js/vendor/poised/poised.general.coffee
ela-4.0.0 app/js/vendor/poised/poised.general.coffee
ela-3.4.3 app/js/vendor/poised/poised.general.coffee
ela-3.4.2 app/js/vendor/poised/poised.general.coffee
ela-3.4.0 app/js/vendor/poised/poised.general.coffee
ela-3.3.1 app/js/vendor/poised/poised.general.coffee
ela-3.3.0 app/js/vendor/poised/poised.general.coffee
ela-3.2.0 app/js/vendor/poised/poised.general.coffee
ela-3.1.1 app/js/vendor/poised/poised.general.coffee
ela-3.1.0 app/js/vendor/poised/poised.general.coffee
ela-3.0.0 app/js/vendor/poised/poised.general.coffee
ela-2.0.0 app/js/vendor/poised/poised.general.coffee
ela-1.1.0 app/js/vendor/poised/poised.general.coffee