gsap.registerPlugin(ScrollTrigger);

(function($) {

	function inview() {

		var
			duration = 1,
			stagger = duration / 5;

		var args = {
			scrollTrigger: {
				trigger: this,
				toggleActions: 'restart pause restart pause',
				start: 'top 90%'
			},
			autoAlpha: 0,
			ease: 'power3.out',
			duration: duration,
			stagger: stagger
		};

		switch($(this).attr('data-col-inview')) {
			case 'left':
				args.x = -100;
				args.rotationY = -20;
				break;
			case 'right':
				args.x = 100;
				args.rotationY = 20;
				break;
			case 'top':
				args.y = -100;
				args.rotationX = 20;
				break;
			case 'bottom':
				args.y = 100;
				args.rotationX = -20;
				break;
			default:
				break;
		};

		// console.log($(this).attr('data-col-inview'));

		gsap.set(this, { perspective: 1200 });

		gsap.from($(this).children(), args);

		// gsap.from($(this).children(), {
		// 	scrollTrigger: {
		// 		trigger: this,
		// 		toggleActions: 'restart pause restart pause'
		// 	},
		// 	stagger: stagger,
		// 	x: -100,
		// 	rotationY: -30,
		// 	autoAlpha: 0,
		// 	ease: 'power3.out',
		// 	duration: duration
		// });

	};

	$('[data-col-inview]').each(inview);

})(jQuery);

// gsap.from('[data-col-inview="left"] > *', {
// 	scrollTrigger: {
// 		trigger: this,
// 		toggleActions: 'restart none none none'
// 	},
// 	x: -100,
// 	autoAlpha: 0,
// 	ease: 'back.out',
// 	duration: 1
// })
