<div id="fullpage">
<div class="section">Some section 1</div>
<div class="section">Some section 2</div>
<div class="section">Some section 3</div>
<div class="section">Some section 4</div>
</div>
// const afterLoadFullpage = new CustomEvent('afterLoadFullpage', );
var myFullpage = new fullpage('#fullpage', {
//options here
autoScrolling:true,
// afterLoad: function(origin, destination, direction) {
// let anniversaryText = document.querySelector('.anniversary-text-wrap');
// if (destination.index == 1) {
// // тут работает
// // alert('section 2');
// }
// },
afterLoad: function(origin, destination, direction) {
document.dispatchEvent(new CustomEvent("afterLoad", {
detail: { origin, destination, direction }
}));
if (destination.index == 1) {
// тут работает
// alert('section 2');
// afterLoad: () => customEmitter.emit('afterLoad', destination),
// document.dispatchEvent(afterLoadFullpage);
}
// afterLoad: () => customEmitter.emit('afterLoad', ...arguments),
},
});
// myFullpage.on('afterLoad', function(origin, destination, direction) {
// if (destination.index == 1) {
// // а тут нет
// alert('section 2');
// }
// })
// customEmitter.on('event', doWhatever);
document.addEventListener('afterLoad', function(e) {
alert(e.detail.destination.index);
})
This Pen doesn't use any external CSS resources.