基于WebKit的翻牌效果

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<!DOCTYPE HTML>
<html>
<head>
<style type="text/css">
.base{
   position:absolute;left:0px;top:0px;width:440px;height:330px;
}
.container{
  overflow:visible;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  perspective: 500;
  -webkit-perspective: 500;
}
.back{
  background:url(Stage_01.png);
  backface-visibility:hidden;
  -webkit-backface-visibility:hidden;
  transform:rotateY(0deg);
  -webkit-transform:rotateY(0deg);
}
.front{
 background:url(Stage_02.png);
 backface-visibility:hidden;
 -webkit-backface-visibility:hidden;
 transform:rotateY(180deg);
 -webkit-transform:rotateY(180deg);
 transform-origin:center center;
 -webkit-transform-origin:center center;
}
.containerRotate{
  transition: all 1.5s;
  transform:rotateY(180deg) translateZ(-50px);
  -webkit-transform:rotateY(180deg) translateZ(-50px);
  transform-origin:center center;
  -webkit-transform-origin:center center;
}
.containerRotateEnd{
  transition: all 0.5s;
  transform:rotateY(180deg) translateZ(0px);
  -webkit-transform:rotateY(180deg) translateZ(0px);
  transform-origin:center center;
  -webkit-transform-origin:center center;
}
</style>
</head>
<body>
  <div id=‘container‘ class="base container">
    <div id=‘frontLbl‘ class="base front"></div>
    <div id=‘backLbl‘  class="base back"></div>
  </div>
</body>
<script type="text/javascript">
  function whichTransitionEvent(){
    var t;
    var el = document.createElement(‘fakeelement‘);
    var transitions = {
      ‘transition‘:‘transitionend‘,
      ‘OTransition‘:‘oTransitionEnd‘,
      ‘MozTransition‘:‘transitionend‘,
      ‘WebkitTransition‘:‘webkitTransitionEnd‘,
      ‘MsTransition‘:‘msTransitionEnd‘
    }
 
    for(t in transitions){
        if( el.style[t] !== undefined ){
            return transitions[t];
        }
    }
}
 
/* 监听 transition! */
var transitionEvent = whichTransitionEvent();
var _container = document.getElementById(‘container‘);
transitionEvent && _container.addEventListener(transitionEvent, function(e) {
    var _self = this;
    setTimeout(function(){
      _self.className="base container containerRotateEnd";
    },2000)
});
_container.addEventListener(‘click‘,function(e){
  var _self = this;
  this.className="base container containerRotate";
  })
</script>
</html>

  

基于WebKit的翻牌效果,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。