mirror of
https://github.com/overleaf/overleaf.git
synced 2025-01-11 19:53:06 +00:00
handle destroy event in pdf page view and remove pending timeouts
This commit is contained in:
parent
f8c1c5b025
commit
4faac88065
1 changed files with 10 additions and 2 deletions
|
@ -89,6 +89,11 @@ define [
|
||||||
scope.$watch 'highlights', (highlights, oldVal) ->
|
scope.$watch 'highlights', (highlights, oldVal) ->
|
||||||
return unless highlights?
|
return unless highlights?
|
||||||
return unless highlights.length > 0
|
return unless highlights.length > 0
|
||||||
|
if scope.timeoutHandler
|
||||||
|
$timeout.cancel(scope.timeoutHandler)
|
||||||
|
highlightsLayer.clearHighlights()
|
||||||
|
scope.timeoutHandler
|
||||||
|
|
||||||
# console.log 'got highlight watch in pdfPage', scope.page
|
# console.log 'got highlight watch in pdfPage', scope.page
|
||||||
pageHighlights = (h for h in highlights when h.page == scope.page.pageNum)
|
pageHighlights = (h for h in highlights when h.page == scope.page.pageNum)
|
||||||
return unless pageHighlights.length
|
return unless pageHighlights.length
|
||||||
|
@ -97,12 +102,15 @@ define [
|
||||||
# console.log 'adding highlight', h, viewport
|
# console.log 'adding highlight', h, viewport
|
||||||
top = viewport.viewBox[3] - hl.v
|
top = viewport.viewBox[3] - hl.v
|
||||||
highlightsLayer.addHighlight viewport, hl.h, top, hl.width, hl.height
|
highlightsLayer.addHighlight viewport, hl.h, top, hl.width, hl.height
|
||||||
$timeout () ->
|
scope.timeoutHandler = $timeout () ->
|
||||||
highlightsLayer.clearHighlights()
|
highlightsLayer.clearHighlights()
|
||||||
|
scope.timeoutHandler = null
|
||||||
, 1000
|
, 1000
|
||||||
|
|
||||||
scope.$on "$destroy", () ->
|
scope.$on "$destroy", () ->
|
||||||
console.log 'in destroy handler, TODO need to clean up timeout/highlights'
|
if scope.timeoutHandler
|
||||||
|
$timeout.cancel(scope.timeoutHandler)
|
||||||
|
highlightsLayer.clearHighlights()
|
||||||
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in a new issue