Skip to content

Commit

Permalink
Better conversion of InterpolableNumber to InterpolableString for bot…
Browse files Browse the repository at this point in the history
…h start and end frames
  • Loading branch information
michaelvillar committed Aug 27, 2016
1 parent 5dbb753 commit bd3ca5a
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions src/dynamics.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,18 @@ getCurrentProperties = (el, keys) ->
for key in keys
properties[key] = createInterpolable(el[key])

addUnitsToNumberInterpolables(el, properties)

properties

addUnitsToNumberInterpolables = (el, properties) ->
for k, interpolable of properties
if interpolable instanceof InterpolableNumber && el.style? && k of el.style
interpolable = new InterpolableString([
interpolable,
unitForProperty(k, 0),
])
properties[k] = interpolable
properties

# Interpolable
Expand Down Expand Up @@ -1127,22 +1139,17 @@ startAnimation = (el, properties, options, timeoutId) ->
dynamics.css(el, properties)
options.complete?(@)
return
properties = parseProperties(properties)
startProperties = getCurrentProperties(el, Object.keys(properties))

properties = parseProperties(properties)

endProperties = {}
transforms = []
for k, v of properties
if el.style? and transformProperties.contains(k)
transforms.push([k, v])
else
interpolable = createInterpolable(v)
if interpolable instanceof InterpolableNumber && k not of el && el.style?
interpolable = new InterpolableString([
interpolable,
unitForProperty(k, 0),
])

endProperties[k] = interpolable
endProperties[k] = createInterpolable(v)

if transforms.length > 0
isSVG = isSVGElement(el)
Expand All @@ -1161,6 +1168,8 @@ startAnimation = (el, properties, options, timeoutId) ->
[endProperties.transform.props.rotate[1], endProperties.transform.props.rotate[2]]
)

addUnitsToNumberInterpolables(el, endProperties)

animations.push({
el: el,
properties: {
Expand Down

0 comments on commit bd3ca5a

Please sign in to comment.