Permalink
Browse files

Made value exportable to let it better work with states

  • Loading branch information...
nvh committed Jul 20, 2017
1 parent a30cfcb commit 4198d50a829f134d65232f0aaf8cba9b50ede496
Showing with 14 additions and 2 deletions.
  1. +3 −2 framer/TextLayer.coffee
  2. +11 −0 test/tests/TextLayerTest.coffee
View
@@ -233,10 +233,11 @@ class exports.TextLayer extends Layer
@renderText()
@emit("change:text", value)
@define "value", layerProperty(@, "value", null, null, null, null, {exportable: false}, (layer, value) ->
@define "value", layerProperty(@, "value", null, null, null, null, {}, (layer, value) ->
if layer.transform?
value = layer.transform(value)
layer.text = "#{value}"
if value?
layer.text = "#{value}"
)
@define "transform", layerProperty(@, "transform", null, null, _.isFunction, null, {exportable: false}, (layer, transform) ->
@@ -630,3 +630,14 @@ describe "TextLayer", ->
done()
l.animate "test"
it "should be able to animate back to the value of the default state", ->
l = new TextLayer
value: 3
l.states.test = value: 10
l.stateSwitch "test"
l.text.should.equal "10"
l.stateSwitch "default"
l.text.should.equal "3"
l.stateSwitch "test"
l.text.should.equal "10"

0 comments on commit 4198d50

Please sign in to comment.