 					# return unless oldVal?
 					# console.log 'XXX calling setScale in parentSize watcher'
 					return unless newVal?
-					doRescale scope.scale
+					queueRescale scope.scale
 				, true)
 
 				# scope.$watch 'elementWidth', (newVal, oldVal) ->

						]
						console.log 'resolving layoutReady with', scope.parentSize
						$timeout () ->
							spinner.add(element)
							layoutReady.resolve scope.parentSize
							scope.$emit 'flash-controls'

				updateLayout()

				scope.$on 'layout:main:resize', () ->
					console.log 'GOT LAYOUT-MAIN-RESIZE EVENT'
					updateLayout()

				scope.$on 'layout:pdf:resize', () ->
					# FIXME we get this event twice
					# also we need to start a new layout when we get it
					console.log 'GOT LAYOUT-PDF-RESIZE EVENT'
					updateLayout()

				scope.$on 'pdf:error', (event, error) ->
					return if error == 'cancelled'

						console.log 'in promise', h, w
						ctrl.setScale(scale, h, w).then () ->
							console.log 'in setscale then', scale, h, w
							scope.$evalAsync () ->
								if spinnerTimer
									clearTimeout spinnerTimer
								else
									spinner.remove(element)
								ctrl.redraw(origposition)
								$timeout renderVisiblePages

				elementTimer = null
				spinnerTimer = null
				updateLayout = () ->
					# if element is zero-sized keep checking until it is ready
					console.log 'checking element ready', element.height(), element.width()
