diff --git a/client/scripts/20-comp-BigCard.coffee b/client/scripts/20-comp-BigCard.coffee index 099a2b3..9df11c1 100644 --- a/client/scripts/20-comp-BigCard.coffee +++ b/client/scripts/20-comp-BigCard.coffee @@ -24,10 +24,17 @@ Crafty.c 'BigCard', h: @target._h alpha: 0.5 } + @origin 'center' return # transition into zoom version Enlarge: -> + # set new origin on finished animation + @one 'TweenEnd', -> + @origin 'center' + return + + # start animation @tween { x: bcConf.x y: bcConf.y @@ -39,13 +46,12 @@ Crafty.c 'BigCard', # fade out and destroy Fade: -> - # remove this on finished animation @one 'TweenEnd', -> @destroy() return - # transition back to attributes of target card + # transition back to target card @tween { x: @target._x y: @target._y @@ -61,7 +67,7 @@ Crafty.c 'BigCard', when Crafty.mouseButtons.RIGHT @trigger 'Fade' when Crafty.mouseButtons.MIDDLE - # reset intermediate config, then re-zoom this + # reset intermediate config, then reset zoom bcConf = Crafty.clone CONF.bigcard @trigger 'Enlarge' return @@ -69,15 +75,29 @@ Crafty.c 'BigCard', # zoom in and out MouseWheelScroll: (e) -> if e.target == @ + # save origin + origin = + x: @ox + y: @oy + # new attributes @attr { w: @_w * (1 + e.direction * 0.1) h: @_h * (1 + e.direction * 0.1) } + @origin 'center' + + # restore origin + @attr { + ox: origin.x + oy: origin.y + } + # update intermediate config + bcConf.x = @_x + bcConf.y = @_y bcConf.w = @_w bcConf.h = @_h - return return StopDrag: ->