Permalink
Browse files

delete TextLayer.value/.transform

  • Loading branch information...
onnlucky committed Jul 27, 2017
1 parent 6bc3024 commit 25a34cf14faed1d803c078b33958e277ae8a589c
Showing with 0 additions and 81 deletions.
  1. +0 −12 framer/TextLayer.coffee
  2. +0 −69 test/tests/TextLayerTest.coffee
View
@@ -247,18 +247,6 @@ class exports.TextLayer extends Layer
@renderText()
@emit("change:text", value)
@define "value", layerProperty(@, "value", null, null, null, null, {}, (layer, value) ->
if layer.transform?
value = layer.transform(value)
if value?
layer.text = "#{value}"
)
@define "transform", layerProperty(@, "transform", null, null, _.isFunction, null, {exportable: false}, (layer, transform) ->
if layer.transform? and layer.value?
layer.text = layer.transform(layer.value) + ''
)
renderText: =>
return if @__constructor
@_styledText.render()
@@ -696,72 +696,3 @@ describe "TextLayer", ->
throw new Error("change:text event should not be emitted")
subject.textReplace("e", "e")
done()
describe "value transformer", ->
it "should set a value property", ->
l = new TextLayer
value: 123
l.value.should.equal 123
it "should set the text when setting the value property", ->
l = new TextLayer
value: 456
l.text.should.equal "456"
it "should only allow function for the transform property", ->
(-> new TextLayer transform: 3).should.throw "Layer.transform: value '3' of type 'number' is not valid"
it "should transform the value if the transform function is set", ->
l = new TextLayer
value: 123
transform: (value) -> value + 456
l.value.should.equal 123
l.text.should.equal "579"
it "should be able to animate text through the transform function", (done) ->
l = new TextLayer
value: 75
transform: (value) ->
minutes = Math.floor(value / 60)
seconds = Math.round(value - (minutes * 60))
return "#{minutes}:#{seconds}"
l.onAnimationStart ->
l.text.should.equal "1:15"
l.onAnimationEnd ->
l.text.should.equal "1:50"
done()
Utils.delay 0.1, ->
l.text.substring(0, 3).should.equal "1:3"
a = l.animate
value: 110
options:
curve: Bezier.linear
time: 0.2
it "should treat non-numeric values as-is when states", (done) ->
l = new TextLayer
value: "hiep hiep"
l.text.should.equal "hiep hiep"
l.states.test =
rotation: 100
value: "hoera"
l.onAnimationEnd ->
l.text.should.equal "hoera"
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 25a34cf

Please sign in to comment.