Skip to content

Commit

Permalink
add swiper
Browse files Browse the repository at this point in the history
  • Loading branch information
cnyet committed Nov 30, 2018
1 parent 3d09e51 commit acf977b
Show file tree
Hide file tree
Showing 12 changed files with 180 additions and 1 deletion.
71 changes: 71 additions & 0 deletions css/main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
* {
-webkit-tap-highlight-color: transparent;
outline: 0;
margin: 0;
padding: 0;
vertical-align: baseline;
}

body, h1, h2, h3, h4, h5, h6, hr, p, blockquote, dl, dt, dd, ul, ol, li, pre, form, fieldset, legend, button, input, textarea, th, td {
margin: 0;
padding: 0;
vertical-align: baseline;
}

img {
border: 0 none;
vertical-align: top;
}

i, em {
font-style: normal;
}

ol, ul {
list-style: none;
}

input, select, button, h1, h2, h3, h4, h5, h6 {
font-size: 100%;
font-family: inherit;
}

table {
border-collapse: collapse;
border-spacing: 0;
}

a {
text-decoration: none;
color: #666;
}

body {
margin: 0 auto;
min-width: 320px;
max-width: 768px;
width: 100%;
height: 100%;
font-size: 14px;
font-family: -apple-system, Helvetica, "Microsoft YaHei", Arial, sans-serif;
line-height: 1.5;
color: #666;
text-size-adjust: 100% !important;
user-select: none;
}

input[type="text"], textarea {
appearance: none;
}

html {
width: 100%;
height: 100%;
}

/**
* 状态类
*/
.hide {
display: none !important;
}
12 changes: 12 additions & 0 deletions css/swiper.min.css

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions demos/手势滑屏/swiper.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.container{
width: 100%;
height: 100vh;
overflow: hidden;
}
.wrapper{
overflow: auto;
transition: transform .2s;
}
.wrapper-item{
width: 100%;
height: 100vh;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
background-color: #fff;
font-size: 18px;
}
22 changes: 22 additions & 0 deletions demos/手势滑屏/swiper.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>滑屏效果</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="../../css/main.css">
<link rel="stylesheet" type="text/css" media="screen" href="swiper.css" />
</head>
<body>
<div class="container">
<div class="wrapper" id="swiper">
<div class="wrapper-item">swiper01</div>
<div class="wrapper-item">swiper02</div>
<div class="wrapper-item">swiper03</div>
</div>
</div>
<script src="../../js/hammer.min.js"></script>
<script src="swiper.js"></script>
</body>
</html>
35 changes: 35 additions & 0 deletions demos/手势滑屏/swiper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
var intervalTime = 200;
var intervalDistance = 100;
var currentIndex = 0;
var drag = false;
var pageY = 0;
var distanceY = 0;
var startTime = 0;

var swiper = document.getElementById('swiper');
swiper.addEventListener('touchstart', function(event){
drag = swiper;
pageY = event.touches[0].pageY;
startTime = new Date();
console.log('touchstart');
});

swiper.addEventListener('touchmove', function(event){
if (drag) {
distanceY = event.touches[0].pageY - pageY;
}
});

swiper.addEventListener('touchend', function(event){
var interval = new Date() - startTime;
var asbDistance = Math.abs(distanceY);
drag = false;
if (interval > intervalTime) {

}
if (distanceY > asbDistance) {
swiper.style.transform = '';
}
console.log('touchend', interval);
});

File renamed without changes.
2 changes: 1 addition & 1 deletion 波浪效果特效.html → demos/波浪效果/wave.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>CSS3水波动画</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" media="screen" href="css/wave.css" />
<link rel="stylesheet" type="text/css" media="screen" href="wave.css" />
</head>
<body>
<div id="container">
Expand Down
Binary file added images/swiper1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/swiper2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/swiper3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions js/hammer.min.js

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions js/swiper.min.js

Large diffs are not rendered by default.

0 comments on commit acf977b

Please sign in to comment.