<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<title>轮播</title>
<link rel="stylesheet" type="text/css" href="slider.css" rel="external nofollow" >
<script src="slider.js"></script>
</head>
<body>
<div id="slider" class="slider-wrapper">
<ul class="slider-items">
<li class="slider-item"><img src="images/pic21.gif" alt="1"></li>
<li class="slider-item"><img src="images/pic22.gif" alt="2"></li>
<li class="slider-item"><img src="images/pic23.gif" alt="3"></li>
<li class="slider-item"><img src="images/pic24.gif" alt="4"></li>
</ul>
</div>
<script>
Slider('#slider',{});
</script>
</body>
</html>
body {
padding: 0;
min-width: 300px;
max-width: 640px;
margin: 0 auto;
}
ul {
list-style: none;
}
ul,li {
margin: 0;
padding: 0;
}
.slider-wrapper {
position: relative;
width: 100%;
height: 220px;
overflow: hidden;
-webkit-user-select: none;
-ms-user-select: none;
user-select: none;
}
.slider-items {
position: relative;
height: 100%;
}
.slider-item {
float: left;
text-align: center;
cursor: pointer;
}
.slider-item > img {
width: 100%;
pointer-events: none;
}
.slider-pagination {
position: absolute;
bottom: 10px;
left: 0;
width: 100%;
text-align: center;
-webkit-transition-duration: .3s;
-moz-transition-duration: .3s;
-o-transition-duration: .3s;
transition-duration: .3s;
}
.slider-bullet {
width: 8px;
height: 8px;
margin: 0 5px;
display: inline-block;
border-radius: 100%;
background-color: black;
opacity: .2;
cursor: pointer;
}
.slider-bullet-active {
opacity: 1;
background-color: #007aff;
}
.slider-button {
position: absolute;
top: 50%;
width: 50px;
height: 50px;
text-align: center;
line-height: 50px;
margin-top: -25px;
z-index: 10;
font-size: 4rem;
color: gray;
-webkit-user-select:none;
user-select:none;
}
.next {
right: 0px;
}
.prev {
left: 0px;
}
;( function( global, factory ) {
"use strict";
if ( typeof module === "object" && typeof module.exports === "object" ) {
module.exports = global.document ?
factory( global, true ) :
function( w ) {
if ( !w.document ) {
throw new Error( "Slider requires a window with a document" );
}
return factory( w );
};
} else {
factory( global );
}
// Pass this if window is not defined yet
} )( typeof window !== "undefined" ? window : this, function( window, noGlobal ){
"use strict";
function Slider( selector, options ) {
return new Slider.init( selector, options );
}
Slider.init=function(selector, params){
next:function(){},<br> prev:function(){},<br> move:function(){}
}<br> Slider.init.prototype = Slider.prototype = {<br> <br> };
return Slider
});
function translate3d(element,x,y) {
x = x === undefined ? 0 : x;
y = y === undefined ? 0 : x;
element.style['-webkit-transform'] = 'translate3d(-'+x+'px,'+y+'px,0px)';
element.style['transform'] = 'translate3d(-'+x+'px,'+y+'px,0px)';
}
function transition(element,time){
element.style['-webkit-transition-duration'] = time+'ms';
element.style['transition-duration'] = time+'ms';
}
fn.next = function(){
var activeIndex = ++this.activeIndex;
translate3d(this.wrap,activeIndex*this.slideWidth);
transition(this.wrap,this.params.speed);
}
fn.prev = function(){
var activeIndex = --this.activeIndex;
translate3d(this.wrap,activeIndex*this.slideWidth);
transition(this.wrap,this.params.speed);
}
var activeIndex = this.lastIndex--;<br>if(activeIndex > this.lastIndex){
return;
}
var activeIndex = --this.activeIndex;
if(activeIndex < this.firstIndex){
return;
}
fn.createLoopItems = function(){
var lastItem = this.slides[this.lastIndex];
var firstItem = this.slides[this.firstIndex];
var prevItem = lastItem.cloneNode(true);
var nextItem = firstItem.cloneNode(true);
var sliderCount = this.sliderCount+2;
var slideWidth = this.slideWidth;
this.slideStack.push(this.firstIndex);
this.slideStack.unshift(this.lastIndex);
this.wrap.insertBefore(prevItem,firstItem);
this.wrap.appendChild(nextItem);
this.wrap.style.width = slideWidth * sliderCount + 'px';
translate3d(this.wrap,slideWidth);
this.activeIndex += 1;
this.sliderCount = sliderCount;
this.lastIndex += 2;
}
transition(this.wrap,0);
fn.fixedPrevLoop = function(){
var that = this;
setTimeout(function(){
that.fixedLoop(that.lastIndex-1)
},that.params.speed);
}
this.container.addEventListener('transitionend',function(){<br>
//监听动画结速之后再执行判断是否要修复<br>},false);
fn.autoPlay = function(){
var that = this;
if(!this.params.autoplay){
return;
}
this.timeId = setTimeout(function(){
that.next();
//that.prev();
that.autoPlay();
},this.params.delay);
}
fn.bindEvents = function(){
if(Device.desktop){
this.container.addEventListener('mousedown',this,false);
this.container.addEventListener('mousemove',this,false);
document.addEventListener('mouseup',this,false);
}else{
this.container.addEventListener('touchstart',this,false);
this.container.addEventListener('touchmove',this,false);
document.addEventListener('touchend',this,false);
}
this.container.addEventListener('transitionend',this,false);
this.container.addEventListener('click',this,false);
}
fn.handleEvent = function(e){
var type = e.type;<br> //注意这里边的this<br>}
fn.stop = function(){
this.axis.x = 0;
translate3d(this.wrap,this.slideWidth*this.activeIndex);
transition(this.wrap,this.params.speed);
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有