-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
73 lines (65 loc) · 2.62 KB
/
index.html
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
<!doctype html>
<html lang="zh-cn">
<head>
<meta charset="utf-8">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="format-detection" content="telephone=no" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>仿微信摇一摇</title>
<style type="text/css" media="screen">
.shake-mask{position: absolute;top: 0;left: 0;height: 100%;width: 100%;display: block;text-align: center;display: none;z-index: 9999;}
.shake-mask .top,.shake-mask .bottom{background-image: url(./images/shake_bg.png);background-color: #282C2D}
.shake-mask .top{height:50%;display: none;position: relative;overflow: hidden;-webkit-transform:translateY(-100%);}
.shake-mask .top img{position: absolute;bottom: -102px}
.shake-mask .bottom{height:50%;display: none;position: relative;overflow: hidden;-webkit-transform:translateY(100%);}
.shake-mask .bottom img{position: absolute;top: -102px}
.shake-mask .top.shaking{-webkit-animation:upAnimation .9s 1;display: block;}
.shake-mask .bottom.shaking{-webkit-animation:downAnimation .9s 1;display: block;}
@-webkit-keyframes upAnimation
{
0% {-webkit-transform:translateY(-100%);}
50% {-webkit-transform:translateY(0);}
100% {-webkit-transform:translateY(-100%);}
}
@-webkit-keyframes downAnimation
{
0% {-webkit-transform:translateY(100%);}
50% {-webkit-transform:translateY(0);}
100% {-webkit-transform:translateY(100%);}
}
</style>
<script type="text/javascript" src="./js/jquery.min.js"></script>
<script type="text/javascript" src="./js/shake.js"></script>
</head>
<body>
<div class="shake-mask">
<div class="top"><img src="./images/shake_hand.png" width="200"></div>
<div class="bottom"><img src="./images/shake_hand.png" width="200"></div>
</div>
<script type="text/javascript">
var myShakeEvent = new Shake({
threshold: 5, // optional shake strength threshold
timeout: 300 // optional, determines the frequency of event generation
});
myShakeEvent.start();
var $oShake = $('.shake-mask'), shakeTimer;
$('div img', $oShake).css({'left':($(window).width()-200)/2});
var shakeStart = function() {
$oShake.show().find('.top,.bottom').addClass('shaking');
}
var shakeEnd = function() {
$oShake.hide().find('.top,.bottom').removeClass('shaking');
}
var showShake = function() {
shakeStart();
shakeTimer && clearTimeout( shakeTimer );
shakeTimer = setTimeout( shakeEnd, 900 );
}
window.addEventListener('shake', function(){
showShake();
}, false)
</script>
<a href="javascript:showShake();void(0);">仿微信摇一摇</a>
</body>
</html>