Skip to content

Commit

Permalink
delete TextLayer.value/.transform
Browse files Browse the repository at this point in the history
  • Loading branch information
onnlucky committed Jul 27, 2017
1 parent 6bc3024 commit 25a34cf
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 81 deletions.
12 changes: 0 additions & 12 deletions framer/TextLayer.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
69 changes: 0 additions & 69 deletions test/tests/TextLayerTest.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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.