only check pdf page visibility on scroll every 50ms

This commit is contained in:
Brian Gough 2014-12-04 16:49:24 +00:00
parent a15a6d877f
commit 44057a9632

View file

@ -258,16 +258,28 @@ define [
#scope.$apply()
element.on 'scroll', () ->
# console.log 'scroll detected', scope.adjustingScroll
updateContainer()
scope.$apply()
#console.log 'pdfposition', element.parent().scrollTop()
if scope.adjustingScroll
updateContainer()
scope.$apply()
scope.adjustingScroll = false
return
#console.log 'not from auto scroll'
scope.scrolled = true
return if scope.handler?
scope.handler = requestAnimationFrame(scrollHandler)
scrollStart = null
SCROLL_TIMEOUT = 50
scrollHandler = (timestamp) ->
scrollStart = timestamp if !scrollStart?
progress = timestamp - scrollStart
if (progress < SCROLL_TIMEOUT)
scope.handler = requestAnimationFrame(scrollHandler)
return
scrollStart = null
scope.handler = null
updateContainer()
scope.$apply()
scope.position = ctrl.getPdfPosition()
# console.log 'position is', scope.position.page, scope.position.offset
scope.$apply()
scope.$watch 'pdfSrc', (newVal, oldVal) ->