mirror of
https://github.com/paradoxxxzero/butterfly.git
synced 2026-05-30 08:59:39 +00:00
25 lines
654 B
CoffeeScript
25 lines
654 B
CoffeeScript
|
|
document.addEventListener 'DOMContentLoaded', ->
|
|
return
|
|
|
|
req = null
|
|
|
|
butterfly.native_scroll_to = (scroll=-1) ->
|
|
e = butterfly.parent
|
|
cancelAnimationFrame req if req
|
|
if scroll is -1 or (
|
|
scroll > e.scrollHeight - e.getBoundingClientRect().height)
|
|
scroll = e.scrollHeight - e.getBoundingClientRect().height
|
|
|
|
diff = scroll - e.scrollTop
|
|
return if diff is 0
|
|
step = diff / 25
|
|
scroll_step = ->
|
|
if Math.abs(e.scrollTop - scroll) < Math.abs(step)
|
|
e.scrollTop = scroll
|
|
else
|
|
e.scrollTop += step
|
|
req = requestAnimationFrame scroll_step
|
|
|
|
req = requestAnimationFrame scroll_step
|