clean up unnecessary redraws

This commit is contained in:
Brian Gough 2014-11-28 15:08:24 +00:00
parent 7485b564bc
commit d8e07731e0
3 changed files with 9 additions and 3 deletions

View file

@ -50,8 +50,8 @@ define [
# pdfListView.listView.pageHeightOffset = 20
scope.loading = false
scope.pleaseJumpTo = {}
scope.scale = {}
scope.pleaseJumpTo = null
scope.scale = null
initializedPosition = false
initializePosition = () ->
return if initializedPosition

View file

@ -83,6 +83,8 @@ app.directive 'pdfPage', ['$timeout', 'pdfHighlights', ($timeout, pdfHighlights)
})
scope.$watch 'highlights', (highlights, oldVal) ->
return unless highlights?
return unless highlights.length > 0
console.log 'got highlight watch in pdfPage', scope.page
pageHighlights = (h for h in highlights when h.page == scope.page.pageNum)
return unless pageHighlights.length
@ -95,5 +97,8 @@ app.directive 'pdfPage', ['$timeout', 'pdfHighlights', ($timeout, pdfHighlights)
highlightsLayer.clearHighlights()
, 1000
scope.$on "$destroy", () ->
console.log 'in destroy handler, TODO need to clean up timeout/highlights'
}
]

View file

@ -251,7 +251,8 @@ app.directive 'pdfViewer', ['$q', '$timeout', ($q, $timeout) ->
console.log 'loading pdf', newVal, oldVal
return unless newVal?
ctrl.load()
doRescale scope.scale
# trigger a redraw
scope.scale = angular.copy (scope.scale)
scope.$watch 'scale', (newVal, oldVal) ->
# no need to set scale when initialising, done in pdfSrc