Permalink
Browse files

Not using the defaultStyles for textAlign

  • Loading branch information...
nvh committed Jul 19, 2017
1 parent eac82f2 commit a30cfcbcc2284b9ea002d3921dee390dddc047a3
Showing with 22 additions and 5 deletions.
  1. +8 −5 framer/StyledText.coffee
  2. +14 −0 test/tests/TextLayerTest.coffee
View
@@ -203,13 +203,14 @@ class StyledTextBlock
return @text is combinedText
class exports.StyledText
blocks: []
blocks: null
textAlign: null
element: null
autoWidth: false
autoHeight: false
textOverflow: null
defaultStyles:
@defaultStyles =
fontStyle: "normal"
fontVariantCaps: "normal"
fontWeight: "normal"
@@ -221,25 +222,27 @@ class exports.StyledText
wordWrap: "break-word"
constructor: (configuration) ->
@defaultStyles.textAlign = configuration?.alignment ? "left"
@textAlign = configuration?.alignment ? "left"
if configuration?.blocks?
@blocks = configuration.blocks.map((b) -> new StyledTextBlock(b))
else
@blocks = []
getOptions: ->
blocks: @blocks.map((b) -> b.getOptions())
alignment: @defaultStyles.textAlign
alignment: @textAlign
@isStyledText: (styledText) ->
return styledText?.blocks? and styledText?.alignment? and _.isArray(styledText.blocks) and _.isString(styledText.alignment)
setElement: (element) ->
return if not element?
@element = element
for style, value of @defaultStyles
for style, value of StyledText.defaultStyles
if not @element.style[style]
@element.style[style] = value
if @textAlign? and not @element.style["textAlign"]
@element.style["textAlign"] = @textAlign
render: ->
return if not @element?
@@ -53,6 +53,20 @@ describe "TextLayer", ->
styledText: exampleStyledTextOptions
l.styledTextOptions.should.eql exampleStyledTextOptions
it "setting the alignment shouldn't influence other layers", ->
a = new TextLayer
styledText:
blocks: []
alignment: "left"
b = new TextLayer
styledText:
blocks: []
alignment: "center"
a.styledTextOptions.alignment.should.equal "left"
b.styledTextOptions.alignment.should.equal "center"
describe "animation", ->
it "should start animating from the textcolor the layer has", (done) ->
text = new TextLayer

0 comments on commit a30cfcb

Please sign in to comment.