mirror of
https://github.com/overleaf/overleaf.git
synced 2025-02-24 11:05:04 +00:00
only check pdf page visibility on scroll every 50ms
This commit is contained in:
parent
a15a6d877f
commit
44057a9632
1 changed files with 18 additions and 6 deletions
|
@ -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) ->
|
||||
|
|
Loading…
Reference in a new issue