Skip to content

Commit

Permalink
Merge pull request #28 from perrin4869/master
Browse files Browse the repository at this point in the history
Support animating DOM properties like scrollTop
  • Loading branch information
mv-stripe authored Aug 5, 2016
2 parents ed9bc5b + 789e6de commit 16440ca
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 16440ca

Please sign in to comment.