Anime: Binding animation to scroll event

Created on 18 Sep 2017  路  2Comments  路  Source: juliangarnier/anime

Are there any example of binding an animation to a scroll event?

Like http://scrollmagic.io/

Most helpful comment

As @alexchantastic said, you can just use the seek property. For ScrollMagic specifically, something like this works:

// Assuming you've already set up your scroll magic controller and anime timeline
// var timeLine = anime.timeline({...});

new ScrollMagic.Scene({
  duration: timeLine.duration
}).on('progress', function(event){
  timeLine.seek(timeLine.duration * event.progress)
});

For a manual approach, just trigger the timeline seek on scroll.

All 2 comments

I don't think the docs contain an example for triggering an animation on scroll, but you can repurpose the seek example to fire on a scroll event.

As @alexchantastic said, you can just use the seek property. For ScrollMagic specifically, something like this works:

// Assuming you've already set up your scroll magic controller and anime timeline
// var timeLine = anime.timeline({...});

new ScrollMagic.Scene({
  duration: timeLine.duration
}).on('progress', function(event){
  timeLine.seek(timeLine.duration * event.progress)
});

For a manual approach, just trigger the timeline seek on scroll.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

LiveLikeCounter picture LiveLikeCounter  路  3Comments

gaou-piou picture gaou-piou  路  3Comments

Elaborate3P1C picture Elaborate3P1C  路  7Comments

trusktr picture trusktr  路  6Comments

edenprojectde picture edenprojectde  路  5Comments