
/*
* Custom Script File For View Css3 Example 
* Create by Anees Hikmat Abu hmaid
* aneeshikmat@2nees.com
* 2nees.com
* create at 15-04-2015
*/

$(document).ready(function(){

	// Global Value Variable
	var value = "";
	
	// Example 1 in page 45.html (change rotation value)
	$("#changeDeg-1").on("change",function(){
		value = $("#changeDeg-1").val() + "deg";
		$("#persp-1").text(value);
		
		$(".ex-45 .ex-45-1, .ex-45 .ex-45-2, .ex-45 .ex-45-3, .ex-45 .ex-45-4").css({
            '-webkit-transform': 'rotateY(' + value + ')',
            'transform': 'rotateY(' + value + ')'
        });
	});
	
	// Example 1 in page 46.html (change rotation value 2D & 3D)
	var timer;
	$("#startRotate-1").click(function(){
		var count = 1;
		clearInterval(timer);
	    timer = setInterval(function(){ 
			value = count + "deg";
			
			$(".ex-46 .ex-46-1").css({
				'-webkit-transform': 'rotate(' + value + ')',
				'transform': 'rotate(' + value + ')'
			});
			
			$(".ex-46 .ex-46-2").css({
				'-webkit-transform': 'rotateY(' + value + ') rotateX(' + value + ') rotateZ(' + value + ')',
				'transform': 'rotateY(' + value + ') rotateX(' + value + ') rotateZ(' + value + ')'
			});
			
			if(count == 180){
				clearInterval(timer);
			}
			count++;
		}, 20);
	});
	
	// Example 1 in page 47.html (change Positiion by translate value 2D & 3D)
	$("#startRotate-2").click(function(){
		var count = 1;
		clearInterval(timer);
	    timer = setInterval(function(){ 
			value = count + "deg";
			
			$(".ex-47 .ex-47-1 .child").css({
				'-webkit-transform': 'rotateY(' + value + ') rotateX(' + value + ') rotateZ(' + value + ')',
				'transform': 'rotateY(' + value + ') rotateX(' + value + ') rotateZ(' + value + ')',
			});
			
			$(".ex-47 .ex-47-2").css({
				'-webkit-perspective':  count + "px",
				'perspective':  count + "px"
			});
			
			$(".ex-47 .ex-47-2 .child").css({
				'-webkit-transform': 'rotateY(' + value + ') rotateX(' + value + ') rotateZ(' + value + ')',
				'transform': 'rotateY(' + value + ') rotateX(' + value + ') rotateZ(' + value + ')',
			});
			
			if(count == 720){
				clearInterval(timer);
			}
			count++;
		}, 20);
	});
});