


一、效果图
二、html代码
- 1
- 2
- 3
三、源代码
var $ = function (id) {
return "string" == typeof id ? document.getElementById(id) : id;
};
var Class = {
create: function() {
return function() {
this.initialize.apply(this, arguments);
}
}
}
Object .extend = function(destination, source) {
for (var property in source) {
destination[property] = source[property];
}
return destination;
}
var TransformView = Class.create();
TransformView.prototype = {
//Container object, sliding object, switching parameter, switching number
initialize: function(container, slider, parameter, count, options) {
if(parameter var oContainer = $(container), oSlider = $(slider), oThis = this;
this.Index = 0;//Current index
this._timer = null;//Timer
this._slider = oSlider;//Sliding object
this._parameter = parameter ;//Switching parameter
this._count = count || 0;//Switching quantity
this._target = 0;//Target parameter
this.SetOptions(options);
this.Up = !!this.options.Up;
this.Step = Math.abs(this.options.Step);
this.Time = Math.abs(this.options.Time) ;
this.Auto = !!this.options.Auto;
this.Pause = Math.abs(this.options.Pause);
this.onStart = this.options.onStart;
this.onFinish = this.options.onFinish;
oContainer.style.overflow = "hidden";
oContainer.style.position = "relative";
oSlider.style.position = "absolute";
oSlider.style.top = oSlider.style.left = 0;
},
//Set the default properties
SetOptions: function(options) {
this. options = {//Default value
Up: true,//Whether to go up (otherwise to the left)
Step: 5,//Sliding change rate
Time: 10,//Sliding delay
Auto: true,//Whether to automatically convert
Pause: 2000,//Pause time (valid when Auto is true)
onStart: function(){},//Execute when starting conversion
onFinish: function (){}//Execute when the conversion is completed
};
Object.extend(this.options, options || {});
},
//Start switching settings
Start : function() {
if(this.Index this.Index = this._count - 1;
} else if (this.Index >= this._count){ this .Index = 0; }
this._target = -1 * this._parameter * this.Index;
this.onStart();
this.Move();
},
//Move
Move: function() {
clearTimeout(this._timer);
var oThis = this, style = this.Up ? "top" : "left",
iNow = parseInt(this._slider.style[style]) || 0,
iStep = this.GetStep(this._target, iNow);
if (iStep != 0) {
this._slider.style[style] = (iNow iStep) "px";
this._timer = setTimeout(function(){ oThis.Move(); }, this.Time);
} else {
this._slider.style[style] = this._target "px";
this.onFinish();
if (this.Auto) { this._timer = setTimeout(function(){ oThis.Index ; oThis.Start(); }, this.Pause); }
}
},
//Get the step size
GetStep: function(iTarget, iNow) {
var iStep = (iTarget - iNow) / this.Step;
if (iStep == 0) return 0;
if (Math.abs(iStep) 0 ? 1 : -1) ;
return iStep;
},
//Stop
Stop: function(iTarget, iNow) {
clearTimeout(this._timer);
this._slider.style[this .Up ? "top" : "left"] = this._target "px";
}
};
window.onload=function(){
function Each(list, fun){
for (var i = 0, len = list.length; i };
var objs = $("idNum2").getElementsByTagName("li");
var tv = new TransformView("idTransformView2", "idSlider2", 408, 3, {
onStart: function(){ Each(objs, function(o, i){ o.className = tv.Index == i ? "on" : ""; }) },//Button style
Up: false
});
tv.Start();
Each(objs, function(o, i){
o.onmouseover = function(){
o.className = "on";
tv.Auto = false;
tv.Index = i;
tv.Start();
}
o.onmouseout = function(){
o.className = " ";
tv.Auto = true;
tv.Start();
}
})
}
The name is obvious at first glance. So I won’t explain the code in detail!
Demo and source file download

JavaScript如何实现图片的左右无缝滑动切换效果?随着互联网的发展,网页设计中经常会使用图片作为页面的重要元素。而图片的切换效果对于页面的美观度和交互性起着重要的影响。在本篇文章中,我们将探讨如何使用JavaScript实现图片的左右无缝滑动切换效果,并附有具体的代码示例。实现图片的左右无缝滑动切换效果,首先需要做到以下几点:建立一个图片容器,用

如何通过纯CSS实现图片轮播效果的方法和技巧在现代网页设计中,图片轮播效果常常被用于展示多张图片或广告的轮流切换。实现图片轮播效果的方式有很多,其中一种常见的方式是使用CSS动画。本文将介绍如何通过纯CSS实现图片轮播效果的方法和技巧,并提供具体的代码示例。一、HTML结构首先,在HTML中需要准备好用于轮播的图片元素。以下是一个简单的HTML结构示例:&l

原生js实现append()方法,需要具体代码示例在编写JavaScript代码时,经常需要在网页中往指定元素中添加新的内容。常见的操作是通过innerHTML属性来设置元素的HTML内容。然而,使用innerHTML属性有时会导致元素内部的事件监听器、样式等丢失。为了更好地实现添加内容的功能,我们可以自己实现一个append()方法。append()方法可

制作响应式的图片切换特效是前端开发中常见的任务之一。在本篇文章中,我们将使用HTML、CSS和jQuery来实现这个特效。下面是详细步骤和具体的代码示例。HTML结构首先,我们需要创建图片切换特效所需的HTML结构。可以使用以下代码示例来创建一个简单的HTML结构。<divclass="slider-container">

如何使用JavaScript实现图片切换的渐变效果?随着互联网的发展,网站设计越来越注重用户体验。图片切换是网站常见的交互效果之一,通过图片的渐变切换可以更好地吸引用户的注意力。本文将介绍如何使用JavaScript实现图片切换的渐变效果,并提供具体代码示例。在开始之前,我们需要准备一些图片资源。假设我们有三张图片,分别是"image1.jpg"、"

如何利用Layui实现图片切换轮播效果,需要具体代码示例标题:利用Layui实现图片切换轮播效果详解引言:在现代网页设计中,图片切换轮播效果已经成为了常见的元素之一。利用图片轮播可以使网页更加动感和吸引人的效果。本文将以Layui为基础,介绍如何实现图片切换轮播效果,并给出具体的代码示例。一、Layui轮播组件介绍Layui是一款经典的前端UI框架,里面包含

如何通过Vue实现图片的切换和轮播效果?Vue是一种用于构建用户界面的JavaScript框架,它提供了一种优雅而高效的方法来处理Web应用程序中的数据和交互逻辑。Vue的许多强大功能之一就是它可以轻松地处理图片的切换和轮播效果。在本文中,我们将介绍如何使用Vue来实现这些效果。首先,我们需要准备一些基本的HTML结构和样式来展示图片。我们可以使用<i

JavaScript如何实现图片的左右无缝滑动切换效果同时加入缩放和淡入淡出动画?在网站开发中,图片的滑动切换效果是非常常见的需求,这里我们将介绍如何使用JavaScript实现一种左右无缝滑动切换效果,同时加入缩放和淡入淡出动画。本文将提供详细的代码示例,让你能够轻松实现该效果。首先,我们需要在HTML中准备一个容器,用于放置图片,并且设置容器的


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Dreamweaver Mac version
Visual web development tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Zend Studio 13.0.1
Powerful PHP integrated development environment

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 English version
Recommended: Win version, supports code prompts!
