i am actualy trying to create a 3D Menu for that i use CSS3 transform and jquery animate for the animation when hovering.
Here is my first working example: JSFiddle
$(document).ready(function(){
$( "li" ).on( "mouseover", function() {
$(this).animate({ trans: 55 }, {
step: function(now,fx) {
$(this).css('-webkit-transform','rotateY('+now+'deg)');
$(this).css('-moz-transform','rotateY('+now+'deg)');
$(this).css('transform','rotateY('+now+'deg)');
},
duration:10000
},'linear');
});
$( "li" ).on( "mouseleave", function() {
$(this).animate({ trans: 60 }, {
step: function(now,fx) {
$(this).css('-webkit-transform','rotateY('+now+'deg)');
$(this).css('-moz-transform','rotateY('+now+'deg)');
$(this).css('transform','rotateY('+now+'deg)');
},
duration:3000
},'linear');
});
});
body {
font-family: sans-serif;
}
.parent {
perspective: 50em;
}
.parent.perspective {
perspective: 1000px;
margin-top: 50px;
}
.child {
display: block;
width: 350px;
margin: 10px;
height: auto;
background-color: deepskyblue;
color:#fff;
cursor: pointer;
text-align: center;
line-height: 80px;
font-size: 26px;
transform: rotateY(60deg);
}
.child:hover {
/* transform: rotateY(10deg);*/
}
<div id="head">
<h1></h1>
<span class="description">3D Effekt auf Elementen</span>
</div>
<div id="menu">
<ul class="parent perspective">
<li class="child">First Person</li>
<li class="child">Battlefield 4</li>
<li class="child">Call of Duty</li>
<li class="child">Burnout Paradise</li>
</ul>
</div>
there are two problems / questions left:
First: the initial animation animates not from actual state to the configured as you can see in my jsfiddle - why? and what to change?
second: if i try to obtain first the configured DEG (from the css) and put it into a js variable i don't have the number (eg: 40 or 60 or whatever) - it obtains some coordinates... i need to have the solution to on mouseout reuse the origin value for the transition from the css any ideea how to get this?
Kind regards