⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dw_slide.js

📁 javascirpt的绘图脚本 包括dw_clip.js
💻 JS
字号:
/* 
		dw_slide.js 
		requires dw_core.js
		version date: July 2002

		This code is from Dynamic Web Coding - www.dyn-web.com 
    See Terms of Use at http://www.dyn-web.com/bus/terms.html
    Permission granted to use this code 
    as long as this entire notice is included.
		
		This code was developed while studying code from: 
		dynduo by Dan Steinman at www.dansteinman.com/dynduo,
		www.cross-browser.com by Mike Foster,
		and www.youngpup.net by Aaron Boodman.
		Code is adapted from those sources.
		
		The slide methods are modified from cbe_slide.js from
		www.cross-browser.com by Mike Foster, where the following
		notice is included:
		
		* Copyright (c) 2002 Michael Foster (mike@cross-browser.com)
 		* This library is distributed under the terms of the 
		* GNU Lesser General Public License (gnu.org).
	  * Time-based, parametric equation animation derived from 
	  * algorithms by Aaron Boodman (youngpup.net), 
	  * and Sebastien Chevrel (sebchevrel.com).
		
    Permission granted to use this code 
    as long as this entire notice is included.
*/


// slide methods
// heavily borrowed from www.cross-browser.com
dynObj.prototype.slideTo = function(destX,destY,slideTime,fn,container) {
	this.slideTime = slideTime||.0001; this.fn=fn||null;
	// ok to slide along one axis only
	if (destX==null) destX=this.x;
	if (destY==null) destY=this.y;
	if (isNaN(parseInt(destX))) {	// if relative to container (string)
		this.posRel(destX,destY,container);
		this.destX=this.leftPos; this.destY=this.topPos;
	} else {
		this.destX=destX; this.destY=destY;
	}
	this.distX=this.destX-this.x; this.startX=this.x;
	this.distY=this.destY-this.y; this.startY=this.y;
	this.slideStart = (new Date()).getTime();
	if (this.slideProp=="steady") this.per = 1/this.slideTime;
	else this.per = Math.PI/(2*this.slideTime);
	if (this.slideProp=="acc") {
		this.distX=-this.distX; this.distY=-this.distY;
		this.startX=this.destX; this.startY=this.destY;
	}
	this.sliding=true;
	this.doSlide();
}

dynObj.prototype.slideBy = function(dx,dy,slideTime,fn,container) {
	var destX=this.x+dx; var destY=this.y+dy;
	this.slideTo(destX,destY,slideTime,fn,container);
}

dynObj.prototype.doSlide = function() {
	if (!this.sliding) return;	// slide can be interrupted
	var elapsed = (new Date()).getTime()-this.slideStart;
	if (elapsed<this.slideTime) {
		if (this.slideProp=="dec") {
			var x = Math.round((this.distX)*Math.sin(this.per*elapsed)+this.startX);
			var y = Math.round((this.distY)*Math.sin(this.per*elapsed)+this.startY);
		} else if (this.slideProp=="acc") {
			var x = Math.round((this.distX)*Math.cos(this.per*elapsed)+this.startX);
			var y = Math.round((this.distY)*Math.cos(this.per*elapsed)+this.startY);
		} else {
			var x = Math.round((this.distX)*(this.per*elapsed)+this.startX);
			var y = Math.round((this.distY)*(this.per*elapsed)+this.startY);
		}
		this.shiftTo(x,y);
		this.onSlide();
		setTimeout(this.obj+".doSlide()",35);
	} else {	// if time's up
		this.shiftTo(this.destX,this.destY);
		this.onSlide();
		this.sliding=false;
		this.onSlideEnd();
		if (this.fn) eval(this.fn);
	}
}

// do you want your slides to be steady, accelerate or decelerate?
dynObj.prototype.slideProp="dec";	// can be "steady", "acc", or "dec"

dynObj.prototype.onSlide=function() {}
dynObj.prototype.onSlideEnd=function() {}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -