Skip to content

Instantly share code, notes, and snippets.

@dougkeeling
Created June 18, 2020 14:59
Show Gist options
  • Save dougkeeling/dd1f0925675c2869197b775669ab2d28 to your computer and use it in GitHub Desktop.
Save dougkeeling/dd1f0925675c2869197b775669ab2d28 to your computer and use it in GitHub Desktop.
[ScrollMagic loop over elements] Loop through elements with a given class and add animations to them. Be sure each item in the loop has a unique ID. #scrollmagic #javascript #jquery
$('.my-class').each(function(){
var id = $(this).attr('id');
scenes[scenes.length] = new ScrollMagic.Scene({triggerElement: '#'+id, duration: 0, triggerHook: 0.9, reverse: false})
.setClassToggle('#'+id, "animate");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment