ulovliglogning.dk/assets/js/main.js

74 lines
2.3 KiB
JavaScript
Raw Normal View History

var controllerPanes = new ScrollMagic.Controller({
globalSceneOptions: {
//triggerHook: 'onLeave'
}
});
var controllerAnimations = new ScrollMagic.Controller({
globalSceneOptions: {
//triggerHook: 'onLeave'
}
});
2018-01-20 23:49:35 +00:00
// get all sections
var sections = document.querySelectorAll("section");
var sectionCount = sections.length;
var sectionDurations = [];
2018-01-20 23:49:35 +00:00
var wipeAnimation = new TimelineLite()
for (var i = 0; i < sections.length; i++) {
sectionDurations.push(sections[i].offsetHeight/300);
// fromY = i == 0 ? "-100%" : "0";
// toY = /*i == sections.length - 1 ? "0" :*/ "-100%";
2018-01-20 23:49:35 +00:00
// wipeAnimation = wipeAnimation.fromTo(sections[i], sectionDurations[i], {
// y: fromY,
2018-01-20 23:49:35 +00:00
// }, {
// y: toY,
2018-01-20 23:49:35 +00:00
// })
}
var wipeAnimation = new TimelineLite()
.fromTo(sections[0], sectionDurations[0], {
y: "-0%",
}, {
y: "-100%",
}).fromTo(sections[1], sectionDurations[1], {
y: "-0%",
}, {
y: "-100%",
}).fromTo(sections[2], sectionDurations[2], {
y: "-0%",
}, {
y: "-100%",
}).fromTo(sections[3], sectionDurations[3], {
y: "-0%",
}, {
y: "-100%",
}).fromTo(sections[4], sectionDurations[4], {
y: "-0%",
}, {
y: "-100%",
})
2018-01-20 23:49:35 +00:00
// create scene for every slide
//for (var i = 0; i < sections.length - 1; i++) {
var triggerElement = document.getElementsByClassName("container")[0];
new ScrollMagic.Scene({
triggerElement: triggerElement,
duration: "400%",
triggerHook: "onLeave"
})
.setPin(triggerElement)
.setTween(wipeAnimation)
.addIndicators() // add indicators (requires plugin)
.addTo(controllerPanes);
//}
2018-01-20 23:49:35 +00:00
// for (var i = 0; i < sections.length; i++) {
2018-01-20 23:49:35 +00:00
// new ScrollMagic.Scene({
// triggerElement: sections[i]
2018-01-20 23:49:35 +00:00
// })
// .setClassToggle(sections[i], "appear")
// .addIndicators({name: "1 - add a class"}) // add indicators (requires plugin)
// .addTo(controllerAnimations);
// }