Skip to content
Permalink
Browse files

fix TextLayer state switching and animations, by cloning internal state

  • Loading branch information
onnlucky committed Jul 27, 2017
1 parent 25a34cf commit b6b792c3c74d2ffc80a21e00ed7f87c7eac95bc2
Showing with 16 additions and 4 deletions.
  1. +1 −3 framer/LayerStates.coffee
  2. +1 −1 framer/TextLayer.coffee
  3. +14 −0 test/tests/TextLayerTest.coffee
@@ -66,9 +66,6 @@ class LayerStates
stateProperties[k] = v
continue

if StyledText.isStyledText(v)
stateProperties[k] = v

if @_isValidProperty(k, v)
stateProperties[k] = v

@@ -83,6 +80,7 @@ class LayerStates
return true if Gradient.isGradient(v)
return true if v is null
return true if v?.constructor?.name is "Layer"
return true if k is "template"
return false

#################################################################
@@ -284,7 +284,7 @@ class exports.TextLayer extends Layer

# we remember the template data, and merge it with new data
@define "template",
get: -> @_templateData
get: -> _.clone(@_templateData)
set: (data) ->
if not @_templateData then @_templateData = {}

@@ -110,6 +110,20 @@ describe "TextLayer.template", ->
text.text.should.eql "hello world\n2017-07-14T02:40 - test user"
text.template.user.should.eql "Test User"

it "should be able to state switch templates", ->
l = new TextLayer({text: "{value}"})
l.template = value: 3
l.text.should.equal "3"
l.states.test = template: 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"

describe "TextLayer", ->
describe "defaults", ->
it "should set the correct defaults", ->

0 comments on commit b6b792c

Please sign in to comment.
You can’t perform that action at this time.