Created
March 8, 2015 17:27
Revisions
-
watert created this gist
Mar 8, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,43 @@ $.fn.pullBounce = ()-> $(this).each -> $dom = $(this) isPulling = no start = 0 top = ()-> $dom.scrollTop() touchTop = (e)-> oEv = e.originalEvent (oEv.touches[0] or oEv.changedTouches[0]).pageY setTranslate = (x,y,animated=no)-> # $dom.attr("style",""" # """) style = "-webkit-transform":"translate3d(#{x}px,#{y}px,0px)", # "-ms-transform":"translate3d(#{x}px,#{y}px,0px)", "transform":"translate3d(#{x}px,#{y}px,0px)" if animated then $dom.animate(style,400); else $dom.css(style) $dom.on "touchstart":(e)=> if top() is 0 isPulling = yes start = touchTop(e) "touchmove":(e)=> if not isPulling then return offset = touchTop(e) - start setTranslate(0,offset) $dom.trigger("pullmove",offset) e.preventDefault() # console.log touchTop(e),start,offset "touchend":(e)-> if not isPulling then return console.log "touchend",e offset = touchTop(e) - start endEvents = "webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend" $dom.css("transition","all 200ms ease").one endEvents,()-> $dom.css("transition","none") $dom.trigger("pulltransitionend",offset) setTranslate(0,0) isPulling = no $dom.trigger("pullend",offset)