diff --git a/src/scroll-animation.js b/src/scroll-animation.js index 262b322..65735d8 100644 --- a/src/scroll-animation.js +++ b/src/scroll-animation.js @@ -122,12 +122,23 @@ export default class ScrollAnimation extends Component { animate(animation, callback) { this.delayedAnimationTimeout = setTimeout(() => { this.animating = true; - this.setState({ - classes: `animated ${animation}`, - style: { - animationDuration: `${this.props.duration}s` - } - }); + if (window.requestAnimationFrame) { + window.requestAnimationFrame(() => { + this.setState({ + classes: `animated ${animation}`, + style: { + animationDuration: `${this.props.duration}s` + } + }); + }); + } else { + this.setState({ + classes: `animated ${animation}`, + style: { + animationDuration: `${this.props.duration}s` + } + }); + } this.callbackTimeout = setTimeout(callback, this.props.duration * 1000); }, this.props.delay); }