Clip property as diagonal mask
by rhernando
HTML
<script src="http://cdnjs.cloudflare.com/ajax/libs/gsap/1.9.1/TweenMax.min.js"></script>
<div id="mainCont">
<div id="firstCont">
<div id="childElem">Hidey Ho Neighbourinou!!!!</div>
</div>
</div>
<button id="btn1" style="margin-top:100px;">play</button>
CSS
#mainCont{
width:400px;
height:400px;
background:#f0f;
overflow:hidden;
}
#firstCont{
width:400px;
height:500px;
background:#0FF transparent;
position:absolute;
overflow:hidden;
clip:rect(0px, 400px, 500px, 0px)
}
#childElem{
width:400px;
height:400px;
top:50px;
left:50px;
background:#00f;
position:relative;
color:#FFF;
font-weight:bold;
}
JavaScript
$(document).ready(function(){
var firstCont = $("div#firstCont"),
child = $("div#childElem"),
btn1 = $("button#btn1"),
tn2 = new TweenMax.to(firstCont, 2, {clip:'rect(0, 0, 500, 0)', paused:true, repeat:1, yoyo:true}),
tn1 = new TweenMax.to(firstCont, 2, {left:0, paused:true});
TweenMax.set(firstCont, {rotation:11, left:-41, top:-52});
TweenMax.set(child, {rotation:-11, top:50, left:50});
btn1.click(function()
{
tn2.play(0);
});
});