BigCard zooming
This commit is contained in:
parent
28abdc5fae
commit
1c30720348
1 changed files with 24 additions and 4 deletions
|
@ -24,10 +24,17 @@ Crafty.c 'BigCard',
|
||||||
h: @target._h
|
h: @target._h
|
||||||
alpha: 0.5
|
alpha: 0.5
|
||||||
}
|
}
|
||||||
|
@origin 'center'
|
||||||
return
|
return
|
||||||
|
|
||||||
# transition into zoom version
|
# transition into zoom version
|
||||||
Enlarge: ->
|
Enlarge: ->
|
||||||
|
# set new origin on finished animation
|
||||||
|
@one 'TweenEnd', ->
|
||||||
|
@origin 'center'
|
||||||
|
return
|
||||||
|
|
||||||
|
# start animation
|
||||||
@tween {
|
@tween {
|
||||||
x: bcConf.x
|
x: bcConf.x
|
||||||
y: bcConf.y
|
y: bcConf.y
|
||||||
|
@ -39,13 +46,12 @@ Crafty.c 'BigCard',
|
||||||
|
|
||||||
# fade out and destroy
|
# fade out and destroy
|
||||||
Fade: ->
|
Fade: ->
|
||||||
|
|
||||||
# remove this on finished animation
|
# remove this on finished animation
|
||||||
@one 'TweenEnd', ->
|
@one 'TweenEnd', ->
|
||||||
@destroy()
|
@destroy()
|
||||||
return
|
return
|
||||||
|
|
||||||
# transition back to attributes of target card
|
# transition back to target card
|
||||||
@tween {
|
@tween {
|
||||||
x: @target._x
|
x: @target._x
|
||||||
y: @target._y
|
y: @target._y
|
||||||
|
@ -61,7 +67,7 @@ Crafty.c 'BigCard',
|
||||||
when Crafty.mouseButtons.RIGHT
|
when Crafty.mouseButtons.RIGHT
|
||||||
@trigger 'Fade'
|
@trigger 'Fade'
|
||||||
when Crafty.mouseButtons.MIDDLE
|
when Crafty.mouseButtons.MIDDLE
|
||||||
# reset intermediate config, then re-zoom this
|
# reset intermediate config, then reset zoom
|
||||||
bcConf = Crafty.clone CONF.bigcard
|
bcConf = Crafty.clone CONF.bigcard
|
||||||
@trigger 'Enlarge'
|
@trigger 'Enlarge'
|
||||||
return
|
return
|
||||||
|
@ -69,16 +75,30 @@ Crafty.c 'BigCard',
|
||||||
# zoom in and out
|
# zoom in and out
|
||||||
MouseWheelScroll: (e) ->
|
MouseWheelScroll: (e) ->
|
||||||
if e.target == @
|
if e.target == @
|
||||||
|
# save origin
|
||||||
|
origin =
|
||||||
|
x: @ox
|
||||||
|
y: @oy
|
||||||
|
|
||||||
# new attributes
|
# new attributes
|
||||||
@attr {
|
@attr {
|
||||||
w: @_w * (1 + e.direction * 0.1)
|
w: @_w * (1 + e.direction * 0.1)
|
||||||
h: @_h * (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
|
# update intermediate config
|
||||||
|
bcConf.x = @_x
|
||||||
|
bcConf.y = @_y
|
||||||
bcConf.w = @_w
|
bcConf.w = @_w
|
||||||
bcConf.h = @_h
|
bcConf.h = @_h
|
||||||
return
|
return
|
||||||
return
|
|
||||||
|
|
||||||
StopDrag: ->
|
StopDrag: ->
|
||||||
# update intermediate config
|
# update intermediate config
|
||||||
|
|
Reference in a new issue