TweenMax Flip Card

I just heard about GSAP today and played with it for 6 hours (which is AWESOME by the way!), I got it all except when I want to flip the card, the back side of it doesn't appear, I searched all over the net looking for a post having the same problem but turned out with no luck.

Checking the elements, I think the problem is that when rotated, the #testCard

child divs ( #front

and #back

) do not rotate and the browser thinks this face #front

is showing it, but I have no idea how to solve it!

Take a look at This DEMO , click on the box and see the problem!

here is the code i used for it:

HTML:

<div id="flipContainer">
    <div id="testCard">
        <div id="front">Front</div>
        <div id="back">Back</div>
    </div>
</div>

      

CSS

#flipContainer{
    width:200px;
    height:100px;
    background-color:#EEE;
    position:absolute;
    top:100%;
    left:50px;
    margin-top:-150px;
    z-index:99999999999999999999999999999;}
#testCard{
    width:100%;
    height:100%;
    position:absolute;
    cursor:pointer;
    overflow:hidden;}
#testCard div {
    display: block;
    position: absolute;
    width: 100%;
    height: 100%;}
#front{
    background-color:#F00;}
#back{
    background-color:#00F;}

      

jQuery: (JS)

TweenMax.set('#flipContainer, #testCard',{
    perspective:1000
    });
TweenMax.set($('#testCard'),{
    boxShadow:'0 0 10px #000',
    borderRadius:'10px',
    transformStyle:'preserve-3d',
    transformOrigin:'center center 50'
    });
TweenMax.set('#testCard div',{
    backfaceVisibility:'hidden'
    });
TweenMax.set('#back',{
    rotationY:-180
    });
TweenMax.set($('#flipContainer'),{
    borderRadius:'10px'
    });

var flipped=false;
$('#testCard').click(function(){
    if(!flipped){
        TweenMax.to($(this),1,{
            rotationY:180,
            onComplete:function(){
                flipped=true;
                }
            });
    }
    else{
        TweenMax.to($(this),1,{
            rotationY:0,
            onComplete:function(){
                flipped=false;
                }
            });
        }
    });

      

+3


source to share


1 answer


since no one answered after several hours of play with the problem, I discovered that the problem with the CSS attribute that I have given #testCard

, overflow:hidden;

I deleted it and worked on request!



DEMO

+2


source







All Articles