i'm using fullpage.js and i'd like to animate 2 images as soon as i get to the second section. looks like i can't make it work with css only, so i picked up some js code from the documentation. check this jsfiddle: http://jsfiddle.net/67oe1jvn/9/
the thing is: if i scroll down to the second section, the 2 images get animated and fade in from left and right sides. BUT if i change section, nothing happens... now i want the to "disappear" as soon as i leave the second section.
i used afterLoad and onLoad as said in the documentation, like this:
$.fn.fullpage({
afterLoad: function(anchorLink, index){
var loadedSection = $(this);
if(index == 1){
$('#slidetext1 #rock').animate({right:"0px"});
$('#slidetext1 #deer').animate({left:"0px"});
}
},
onLeave: function(index, nextIndex, direction){
var leavingSection = $(this);
if(index == 2 && direction =='up'){
$('#slidetext1 #rock').animate({right:"-271px"});
$('#slidetext1 #deer').animate({left:"-271px"});
} else if(index == 2 && direction == 'down'){
/* DO SOMETHING */
}
}
});
i'm new with this plugins so would be cool if someone helps me :)
also i saw this guy posting a similar question that maybe can help clarifying what i need: fullPage.js onLeave event triggers .