Fixed camera zoom killing coordinate hover unnecessarily.

This commit is contained in:
Nick Winter 2014-11-20 11:37:10 -08:00
parent 46c4601ac6
commit df51e28a1d
3 changed files with 18 additions and 5 deletions

View file

@ -283,8 +283,9 @@ module.exports = class Camera extends CocoClass
target = @boundTarget @target, @zoom
return if not force and _.isEqual target, @currentTarget
@currentTarget = target
@updateViewports target
Backbone.Mediator.publish 'camera:zoom-updated', camera: @, zoom: @zoom, surfaceViewport: @surfaceViewport
viewportDifference = @updateViewports target
if viewportDifference > 0.1 # Roughly 0.1 pixel difference in what we can see
Backbone.Mediator.publish 'camera:zoom-updated', camera: @, zoom: @zoom, surfaceViewport: @surfaceViewport
boundTarget: (pos, zoom) ->
# Given an {x, y} in Surface coordinates, return one that will keep our viewport on the Surface.
@ -303,6 +304,11 @@ module.exports = class Camera extends CocoClass
sv = width: @canvasWidth / @zoom, height: @canvasHeight / @zoom, cx: target.x, cy: target.y
sv.x = sv.cx - sv.width / 2
sv.y = sv.cy - sv.height / 2
if @surfaceViewport
# Calculate how different this viewport is. (If it's basically not different, we can avoid visualizing the update.)
viewportDifference = Math.abs(@surfaceViewport.x - sv.x) + 1.01 * Math.abs(@surfaceViewport.y - sv.y) + 1.02 * Math.abs(@surfaceViewport.width - sv.width)
else
viewportDifference = 9001
@surfaceViewport = sv
wv = @surfaceToWorld sv # get x and y
@ -312,6 +318,8 @@ module.exports = class Camera extends CocoClass
wv.cy = wv.y + wv.height / 2
@worldViewport = wv
viewportDifference
lock: ->
@target = @currentTarget
@locked = true

View file

@ -16,6 +16,7 @@ module.exports = class CoordinateDisplay extends createjs.Container
console.error @toString(), 'needs a camera.' unless @camera
console.error @toString(), 'needs a layer.' unless @layer
@build()
@performShow = @show
@show = _.debounce @show, 125
Backbone.Mediator.subscribe(channel, @[func], @) for channel, func of @subscriptions
@ -46,6 +47,7 @@ module.exports = class CoordinateDisplay extends createjs.Container
wop.y = Math.round(wop.y)
return if wop.x is @lastPos?.x and wop.y is @lastPos?.y
@lastPos = wop
@lastScreenPos = x: e.x, y: e.y
@hide()
@show() # debounced
@ -58,8 +60,11 @@ module.exports = class CoordinateDisplay extends createjs.Container
Backbone.Mediator.publish 'surface:coordinate-selected', wop
onZoomUpdated: (e) ->
@hide()
@show()
return unless @lastPos
wop = @camera.screenToWorld @lastScreenPos
@lastPos.x = Math.round wop.x
@lastPos.y = Math.round wop.y
@performShow() if @label.parent
onFlagColorSelected: (e) ->
@placingFlag = Boolean e.color

View file

@ -10,7 +10,7 @@ hipchat = require '../hipchat'
deltasLib = require '../../app/lib/deltas'
PROJECT = {original: 1, name: 1, version: 1, description: 1, slug: 1, kind: 1, created: 1, permissions: 1}
FETCH_LIMIT = 500
FETCH_LIMIT = 1000 # So many ThangTypes
module.exports = class Handler
# subclasses should override these properties