-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcss_transform.html
104 lines (104 loc) · 2.39 KB
/
css_transform.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<!DOCTYPE html>
<html>
<head>
<title>scroll</title>
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
<style type="text/css">
body{
margin: 0;
}
#container{
position: relative;
width: 100vw;
height: 100vh;
}
.wrapper{
position: absolute;
left: 50%;
top: 30%;
transform: translate3d(-50%, -50%, 0);
width: 150px;
height: 150px;
}
.iscroll-wrapper{
position: absolute;
left: 50%;
top: 80%;
transform: translate3d(-50%, -50%, 0);
width: 150px;
height: 150px;
}
.content{
width: 100%;
height: 100%;
text-align: center;
background-color: red;
}
</style>
</head>
<body>
<div id="container">
<div class="wrapper">
<div class="content">
weScroll
</div>
</div>
<div class="iscroll-wrapper">
<div class="content">
iscroll-zoom
</div>
</div>
</div>
<script async type="text/javascript" src="./lib/weScroll.min.js"></script>
<script async type="text/javascript" src="./lib/iscroll-zoom.js"></script>
<script type="text/javascript">
window.onload = function(){
var wrapper = document.querySelector(".wrapper");
var target = wrapper.children[0];
var iscrollEle = document.querySelector(".iscroll-wrapper");
var render = function(x,y,scale){
var transformStyle = "translate3d(" + x + "px," + y +"px, 0px) scale("+ scale +")";
target.style.transform = transformStyle;
}
var scroller = new WeScroll(wrapper, {
disablePointer: true,
disableTouch: false,
disableMouse: false,
zoom: true,
ease: "quadratic",
zoomMin: 0.5,
startZoom: 1,
zoomMax: 2,
bounceTime: 600,
render: render,
tap: true,
freeScroll: true,
});
var iscroll = new IScroll(iscrollEle, {
zoom: true,
scrollX: true,
disablePointer: true,
disableTouch: false,
disableMouse: false,
zoomMin: 0.5,
startZoom: 1,
zoomMax: 2,
click: true,
tap: true,
freeScroll: true,
// useTransition: false
});
wrapper.addEventListener("tap", function(e){
scroller.zoom(2);
}, false)
iscrollEle.addEventListener("click", function(e){
iscroll.zoom(2);
}, false);
setTimeout(function(){
scroller.zoom(1.5);
iscroll.zoom(1.5);
}, 300)
}
</script>
</body>
</html>