I am attempting to create a flip page using jQuery and CSS3. I have managed to achieve it by placing my two pages in one container and rotating the entire container, but I would like to rotate the pages individually. Here is the code I currently have:
CSS:
#pagecontainer {
position: absolute;
width: 100%;
height: 100%;
}
.page {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
-webkit-backface-visibility: hidden;
-moz-backface-visibility: hidden;
-o-backface-visibility: hidden;
backface-visibility: hidden;
}
.back {
-webkit-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
-o-transform: rotateY(180deg);
transform: rotateY(180deg);
}
.flip.out {
-webkit-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
-ms-transform: rotateY(180deg);
-o-transform: rotateY(180deg);
transform: rotateY(180deg);
-webkit-transform-style: preserve-3d;
-webkit-transition: all 1.0s linear;
-moz-transform-style: preserve-3d;
-moz-transition: all 1.0s linear;
-o-transform-style: preserve-3d;
-o-transition: all 1.0s linear;
transform-style: preserve-3d;
transition: all 1.0s linear;
}
.flip.in {
-webkit-transform: rotateY(0deg);
-moz-transform: rotateY(0deg);
-ms-transform: rotateY(0deg);
-o-transform: rotateY(0deg);
transform: rotateY(0deg);
-webkit-transform-style: preserve-3d;
-webkit-transition: all 1.0s linear;
-moz-transform-style: preserve-3d;
-moz-transition: all 1.0s linear;
-o-transform-style: preserve-3d;
-o-transition: all 1.0s linear;
transform-style: preserve-3d;
transition: all 1.0s linear;
}
Following this, I apply these classes to my pages within the page container:
container.append(nextPage);
nextPage.attr("class", "page back");
currentPage.one('webkitTransitionEnd', function(e) {
currentPage.remove();
});
nextPage.attr("class", "page back flip in");
container[0].offsetWidth;
currentPage.attr("class", "page flip out");
However, only the front page is flipping. What could be the issue?
EDIT: I managed to solve it. I needed to adjust the order in my script. It should be:
currentPage.attr("class", "page flip out"); <-- Start with this
container[0].offsetWidth;
nextPage.attr("class", "page back flip in"); <-- End with this