css 3d变换页面翻转效果 - 控制过渡

时间:2015-09-11 13:56:19

标签: jquery css3 transform css-transitions preserve-3d

一切正常但是如果你仔细观察它之后,过渡是可以的,直到中点,然后它会快速移动到位。如果你再次点击,反向翻转捕捉到中间点,然后过渡就可以了。

而且,如果你仔细观察,当实际翻转发生时,有些东西会落后。

我提前为我的凌乱代码道歉。

这是我的代码的js小提琴链接

page flip jsfiddle

这是代码

$(function() {
  $('.on-top').on('click', function() {
    $('.on-top .kami-peek-mask').removeClass('hover-rotate');
    $('.on-top .kami-peek-mask').removeClass('click-rotate-reverse');
    $('.on-top .kami-peek-mask').addClass('click-rotate');
    $('.on-top').removeClass('click-zindex-top');
    $('.on-bottom').removeClass('click-zindex-bottom');
    $('.on-top').addClass('click-zindex-bottom');
    $('.on-bottom').addClass('click-zindex-top');

  })

  $('.on-bottom').on('click', function() {
    $('.on-top .kami-peek-mask').removeClass('click-rotate');
    $('.on-top .kami-peek-mask').addClass('click-rotate-reverse');
    $('.on-top').removeClass('click-zindex-bottom');
    $('.on-top').addClass('click-zindex-top');
    $('.on-bottom').removeClass('click-zindex-top');
    $('.on-bottom').addClass('click-zindex-bottom');

  })

  $('.on-top').hover(
    function() {
      $('.on-top .kami-peek-mask').addClass('hover-rotate');
      $('.kami-shadow').addClass('hover-opacity');
    },
    function() {
      $('.kami-peek-mask').removeClass('hover-rotate');
      $('.kami-shadow').removeClass('hover-opacity');
    }



  )

})
body {
  margin-top: 50px;
  margin-left: 50px;
}
.clearfix:after {
  content: "";
  display: table;
  clear: both;
}
.origami {
  position: relative;
  display: block;
  width: 320px;
  height: 250px;
  text-align: center;
}
.kami-wrapper {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  z-index: 10;
  perspective: 1240px;
  transition: z-index 0s 233.333ms;
}
.kami-wrapper.on-top {
  z-index: 20;
  transition: z-index 0s 233.333ms;
}
.kami-wrapper.on-top.click-zindex-bottom {
  z-index: 10;
}
.kami-wrapper.on-bottom.click-zindex-top {
  z-index: 20;
}
.kami-wrapper.on-top.click-zindex-top {
  z-index: 20;
}
.kami-wrapper.on-bottom.click-zindex-bottom {
  z-index: 10;
}
.kami-mask {
  position: absolute;
  width: 50%;
  top: 0;
  bottom: 0;
  overflow: hidden;
  backface-visibility: hidden;
  transform-style: preserve-3d;
  transform-origin: 100% 0px 0px;
  transform: rotateY(0deg);
  transition: -webkit-transform 350ms ease-out 233.333ms;
}
.kami-peek-mask {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  left: 50%;
  width: 50%;
  overflow: hidden;
  backface-visibility: hidden;
  transform-style: preserve-3d;
  transform-origin: 0px 0px 0px;
  transition: -webkit-transform 350ms linear 0ms;
  transform: rotateY(0deg);
}
.on-top .kami-peek-mask.click-rotate {
  transform: rotateY(-90deg);
}
.on-top .kami-peek-mask.click-rotate-reverse {
  transition: -webkit-transform 0.5s linear 0ms;
  transform: rotateY(0deg);
}
.on-top .kami-peek-mask.hover-rotate {
  transform: rotateY(-30deg);
}
.kami-shadow {
  position: absolute;
  display: block;
  content: " ";
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  background: black;
  margin: 0;
  width: 100%;
  height: 100%;
  transition: opacity 350ms linear;
  opacity: 0;
}
.kami-shadow.hover-opacity {
  opacity: 0.1;
}
.kami {
  position: absolute;
  top: 0;
  left: 0;
  width: 200%;
  height: 100%;
  background-color: #f2f0eb;
}
.kami-peek-mask .kami {
  right: 0;
  left: auto;
}
span {
  display: block;
  margin: 50px auto 0;
}
.origami-content {
  color: white;
  background-color: #484745;
}
.origami-content p {
  margin: 0 12.5%;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-alpha1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" rel="stylesheet" />

<body>

  <div class="origami">
    <div class="kami-wrapper on-top">


      <div class="kami-mask">
        <div class="kami">
          <span><i class="fa fa-envelope fa-4x"></i></span>
          <p><strong>More Sign-Ups</strong>
          </p>
        </div>
      </div>

      <div class="kami-peek-mask">
        <div class="kami kami-peek">
          <span><i class="fa fa-envelope fa-4x"></i></span>
          <p><strong>More Sign-Ups</strong>
          </p>
          <span class="kami-shadow"></span>
        </div>
      </div>




    </div>


    <div class="kami-wrapper on-bottom">

      <div class="kami-mask">
        <div class="kami origami-content">
          <span><i class="fa fa-envelope fa-2x"></i></span>
          <p><strong>More Sign-Ups</strong>
          </p>
          <p>Grow your email database by making it easy for your visitors to sign up on your site. A Flip Form or FlipJack can start your relationship off on the right foot.</p>
        </div>
      </div>

      <div class="kami-peek-mask">
        <div class="kami origami-content kami-peek">
          <span><i class="fa fa-envelope fa-2x"></i></span>
          <p><strong>More Sign-Ups</strong>
          </p>
          <p>Grow your email database by making it easy for your visitors to sign up on your site. A Flip Form or FlipJack can start your relationship off on the right foot.</p>
          <span class="kami-shadow" style="transition: opacity 350ms linear;"></span>
        </div>
      </div>

    </div>

  </div>


</body>

0 个答案:

没有答案