var app = new Vue({
el: '#app',
mounted () {
this.$nextTick(this.pinContainerScene)
},
data () {
return {
panels:[
{
title: 'panel 1',
bgColor: '#29b6f6'
},
{
title: 'panel 2',
bgColor: '#ef5350'
},
{
title: 'panel 3',
bgColor: '#ec407a'
},
{
title: 'panel 4',
bgColor: '#66bb6a'
}
]
}
},
methods: {
pinContainerScene () {
const Length = this.panels.length
// Create a new Timeline (equivalent to new TimelineMax())
const tl = new this.$gsap.TimelineMax()
for (var i = 0; i < Length; i++) { // For each panel in this.panels array:
let animFrom, animOutLetters;
switch (i) { // Set animFrom value, depending on the index i of the item
case 0:
break; // First panel is already visible on page load, so no animation
case 1:
animFrom = {x: '-100%'} // Second panel comes from the left
break;
case 2:
animFrom = {x: '100%'} // Third one comes from the right
break;
case 3:
animFrom = {y: '-100%'} // Finally, the last one comes from the top
break;
}
if (i !== 0) { // For each panel except the one whom index is 0, create the tween and add it to the tl timeline
tl.fromTo(`section.panel-${i}`, 1.5, animFrom, {x: '0%', y: '0%', ease: Linear.easeNone})
}
}
// create scene and set its params
const scene = new this.$scrollmagic.Scene({
triggerElement: '.pinContainer',
triggerHook: 'onLeave',
duration: `${Length * 200}%` // each panel animation will last 200% of the screen's height
})
.setPin('.pinContainer')
.setTween(tl)
// Add scene to ScrollMagic controller by emiting an 'addScene' event on vm.$ksvuescr (which is our global event bus)
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.