PageSourceSearch

https://www.leiko.ru/articles/dw_glide.js

js leiko.ru collected 2026-10-05 00:02:11 UTC 2,469 bytes, 58 lines download raw bytes

1/*************************************************************************
2  This code is from Dynamic Web Coding at www.dyn-web.com
3  Copyright 2003-4 by Sharon Paine 
4  See Terms of Use at www.dyn-web.com/bus/terms.html
5  regarding conditions under which you may use this code.
6  This notice must be retained in the code as is!
7*************************************************************************/
8
9/*
10  dw_glide.js - requires dw_lib.js
11  version date July 2004 
12*/
13
14// acc is number between -1 and 1 ( -1 full decelerated, 1 full accelerated, 0 linear, i.e. no acceleration)
15dynObj.prototype.slideTo = function (destX,destY,slideDur,acc,endFn) {
16  if (!document.getElementById) return;
17  this.slideDur = slideDur || .0001; var acc = -acc || 0;
18  if (endFn) this.onSlideEnd = endFn;
19  // hold destination values (check for movement on 1 axis only)
20 	if (destX == null) this.destX = this.x;	else this.destX = destX;
21  if (destY == null) this.destY = this.y; else this.destY = destY;
22  this.startX = this.x; this.startY = this.y;
23	this.st = new Date().getTime();
24	// control points for bezier-controlled slide (see www.youngpup.net accelimation)
25  this.xc1 = this.x + ( (1+acc) * (this.destX-this.x)/3 );
26	this.xc2 = this.x + ( (2+acc) * (this.destX-this.x)/3 );
27  this.yc1 = this.y + ( (1+acc) * (this.destY-this.y)/3 );
28	this.yc2 = this.y + ( (2+acc) * (this.destY-this.y)/3 );
29	this.sliding = true;
30  this.onSlideStart();
31  dw_Animation.add(this.animString + ".doSlide()");
32}
33
34dynObj.prototype.doSlide = function() {
35	if (!this.sliding) return;	
36	var elapsed = new Date().getTime() - this.st;
37	if (elapsed < this.slideDur) {
38    var x = dw_Bezier.getValue(elapsed/this.slideDur, this.startX, this.destX, this.xc1, this.xc2);
39    var y = dw_Bezier.getValue(elapsed/this.slideDur, this.startY, this.destY, this.yc1, this.yc2);
40		this.shiftTo( Math.round(x) ,Math.round(y) );
41		this.onSlide();
42	} else {	// if time's up
43    dw_Animation.remove(this.animString + ".doSlide()");
44		this.shiftTo(this.destX,this.destY);
45		this.onSlide();
46		this.sliding = false;
47		this.onSlideEnd();
48	}
49}
50
51dynObj.prototype.slideBy = function(dx,dy,slideDur,acc,endFn) {
52	var destX=this.x+dx; var destY=this.y+dy;
53	this.slideTo(destX,destY,slideDur,acc,endFn);
54}
55
56dynObj.prototype.onSlideStart = function () {}
57dynObj.prototype.onSlide = function () {}
58dynObj.prototype.onSlideEnd = function () { if (this.el) this.el = null; }

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.