-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
142 lines (127 loc) · 3.7 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
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>SlideHammer Demo</title>
<link rel="stylesheet" href="dist/slidehammer.min.css">
<style>
* {
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
-ms-box-sizing: border-box;
}
body {
color: #333;
font-family: Arial, sans-serif;
}
.contained {
max-width: 640px
}
.centered {
margin-left: auto;
margin-right: auto;
}
.padding-2x {
padding: 40px;
}
@media (max-width: 480px) {
.padding-2x {
padding: 20px;
}
}
.margin-top-2x {
margin-top: 40px;
}
.stats {
padding: 20px;
background-color: #efeeea;
}
.indicators {
text-align: center;
}
.indicator {
display: inline-block;
width: 10px;
height: 10px;
margin: 0 5px;
background-color: #8f8e8c;
cursor: pointer;
border-radius: 100%;
}
.indicator.current {
background-color: #222;
}
</style>
</head>
<body>
<section class="padding-2x">
<div class="contained centered">
<h1>SlideHammer</h1>
<p>
A demo of an experimental slider using hammer.js.
</p>
<div class="slides">
<div class="slide">
<img src="demo/otters.jpg" alt="" />
</div>
<div class="slide">
<img src="demo/red-panda-sleeping.jpg" alt="" />
</div>
<div class="slide">
<img src="demo/alpaca.jpg" alt="" />
</div>
<div class="indicators"></div>
</div>
</div>
<div class="stats contained centered margin-top-2x">
<div class="stat">
Event type: <span class="stat-event"></span>
</div>
<div class="stat">
Delta X: <span class="stat-delta-x"></span> px
</div>
<div class="stat">
Slider offset: <span class="stat-offset"></span> px
</div>
<div class="stat">
Delta time: <span class="stat-delta-time"></span> ms
</div>
<div class="stat">
Velocity X: <span class="stat-velocity"></span> px/ms
</div>
</div>
</section>
<script type="text/javascript" src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="dist/slidehammer.min.js"></script>
<script type="text/javascript">
slides = new SlideHammer($('.slides'), {
onInit: function() {
var slider = this;
var slideCount = slider.slides.length;
for (var i = 0; i < slideCount; i++) {
$('.indicators').append($('<div>', {class: 'indicator'}));
}
$('.indicator').click(function() {
slider.slideTo($(this).index());
$('.indicator.current').removeClass('current');
$(this).addClass('current');
})
},
onSlideChange: function() {
var slider = this;
$('.indicator.current').removeClass('current');
$('.indicator').eq(slider.currentSlide.index()).addClass('current');
},
onPan: function(e) {
$('.stat-event').html(e.type);
$('.stat-delta-x').html(e.deltaX);
$('.stat-offset').html(this.left);
$('.stat-delta-time').html(e.deltaTime);
$('.stat-velocity').html(e.velocityX);
}
});
</script>
</body>
</html>