Skip to content

Instantly share code, notes, and snippets.

@bahia0019
Last active April 19, 2018 02:14
Show Gist options
  • Save bahia0019/b5f0a0c0ed6b9a4e5678b16f2f14a4d1 to your computer and use it in GitHub Desktop.
Save bahia0019/b5f0a0c0ed6b9a4e5678b16f2f14a4d1 to your computer and use it in GitHub Desktop.
Flip Image with Greensock
/**
* Polaroid Flip
*
*/
const polaroidFlip = function () {
const flipSection = document.querySelectorAll('section');
for (var i = 0; i < flipSection.length; i++) {
// cardBack = document.createElement('div')
// cardBack.classList.add('content-block-back')
// flipSection[i].appendChild(cardBack)
const cardFront = document.querySelector('.content-block');
const cardBack = document.querySelector('.content-block-back');
const flipImages = document.querySelector('.swiper-polaroid');
const flipButton = document.querySelector('.flip-button');
const flipBackButton = document.querySelector('.flip-back-button');
// .classList.add('content-block');
// flipSection.appendChild(cardBack)
var tl = new TimelineMax({ paused: true });
tl.to(cardFront, 1, { rotationY: '180', zIndex: 0 })
.to(cardBack, 1, { rotationY: '0', zIndex: 10 }, 0)
flipButton.addEventListener(
"click",
function (event) {
tl.play(0)
event.preventDefault()
},
false
)
flipBackButton.addEventListener(
"click",
function (event) {
tl.reverse(0)
event.preventDefault()
},
false
)
}
};
polaroidFlip();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment