Brian Gough 12 лет назад
Родитель
Сommit
d8e07731e0

+ 2 - 2
services/web/public/coffee/ide/pdfng/directives/pdfJs.coffee

@@ -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

+ 5 - 0
services/web/public/coffee/ide/pdfng/directives/pdfPage.coffee

@@ -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'
+
 	}
 ]

+ 2 - 1
services/web/public/coffee/ide/pdfng/directives/pdfViewer.coffee

@@ -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