<!-- Simple example of use of this site
by Théophile Walter -->
<iframe src="/" id="iframe-id"></iframe>
<input type="button" value="Start" id="start-button" onclick="javascript:toggleAnimation(this);" />
|
body {
margin: 0;
padding: 0;
overflow: hidden;
}
iframe {
margin: 0;
padding: 0;
width: 100vw;
height: 100vh;
border: none;
}
input[type="button"] {
cursor: pointer;
border: 2px solid #404040;
background-color: #F0F0F0;
border-radius: 5px;
padding: 5px;
font-weight: bold;
}
#start-button {
z-index: 1;
position: fixed;
right: 10px;
top: 10px;
}
|
/* Setting up some variables */
var currentX = 0, currentY = 0;
var interval = false,toogleBg = false;
/* Toggle on/off the rotate animation */
function toggleAnimation(el) {
if (!interval) {
interval = setInterval(function () {
document.getElementById("iframe-id").style.transform = "rotateX(" + currentX + "deg) rotateY(" + currentY + "deg)";
currentX += 5; currentY += 7.5;
currentX %= 360; currentY %= 360;
}, 100);
el.value = "Stop";
console.log("Animation started!");
} else {
clearInterval(interval);
interval = false;
el.value = "Start";
console.log("Animation stopped!");
}
}
/* Makes the button blink */
setInterval(function() {
document.getElementById("start-button").style.backgroundColor = toogleBg ? "#A0A0A0" : "#F0F0F0";
toogleBg = !toogleBg;
}, 1000);
JavaScript Console
|
|