Skip to content

Commit

Permalink
Support animating DOM properties like scrollTop
Browse files Browse the repository at this point in the history
  • Loading branch information
perrin4869 committed Aug 5, 2016
1 parent ed9bc5b commit 789e6de
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/dynamics.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ applyProperties = (el, properties) ->
v = "#{v}#{unitForProperty(k, v)}"
if isSVG && svgProperties.contains(k)
el.setAttribute(k, v)
else if k of el # support animating scrollTop, etc
el[k] = v
else
el.style[propertyWithPrefix(k)] = v

Expand Down
13 changes: 13 additions & 0 deletions test/dynamics.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,19 @@ describe 'dynamics.animate', ->
done()
, 50

it 'animate scrollTop of a DOM element', (done) ->
el = document.createElement('div')
dynamics.animate(el, {
scrollTop: 100,
}, {
duration: 25,
type: dynamics.easeInOut
})
setTimeout ->
expect(el.scrollTop).eql('100')
done()
, 50

it 'animate with a delay', (done) ->
el = document.createElement('div')
el.style.left = 0
Expand Down

0 comments on commit 789e6de

Please sign in to comment.