All pastes #344971 Raw Edit

yegs

public javascript v1 · immutable
·published 2007-02-08 04:00 UTC
rendered paste body
PopupAnimation.prototype.calculateNewMove = function() {	if (this.moves.length > 0) {		var thisMove = this.moves[this.moves.length - 1];	// calculating last pushed move		var frameInterval = (thisMove.frameInterval) ? thisMove.frameInterval : this.defaultFrameInterval;		if (this.movePoints.length > 0) {			// linear move -- todo radial move			// start from last movePoint, end at move's endpoint			var startPoint = this.movePoints[this.movePoints.length - 1];			startPoint.frameInterval = frameInterval;			var deltaX = (thisMove.x - startPoint.x) / thisMove.framesToReach;			var deltaY = (thisMove.y - startPoint.y) / thisMove.framesToReach;			for (var i = 0; i < thisMove.framesToReach; i++) {				var lastPoint = this.movePoints[this.movePoints.length - 1];				var nextX = Math.round(lastPoint.x + deltaX);				var nextY = Math.round(lastPoint.y + deltaY);				this.pushPoint(nextX, nextY, frameInterval);			}		}		else {	// have move, don't have movepoints -- push point only			this.x = thisMove.x;			this.y = thisMove.y;			this.pushPoint(thisMove.x, thisMove.y);		}	}}PopupAnimation.prototype.animate = function() {	this.animationIndex++;	var thisPoint = this.movePoints[this.animationIndex];	var frameInterval = this.defaultFrameInterval;	if (thisPoint) {				// point exists, position		this.x = thisPoint.x;		this.y = thisPoint.y;		this.positionPopup();		frameInterval = thisPoint.frameInterval;	}	if (this.animationIndex == 0) {		// first call, show		if (this.cancelOnClickEnabled && !this.listenerAttached) {	// attach mouse listener if cancelOnClick is set			this.attachListener();			this.listenerAttached = true;		}		this.showPopup();	}	if (this.animationIndex == this.movePoints.length) {	// last call, reset		if (this.autoHideEnabled) { this.hidePopup(); }	// hide when autoHide is set		this.animationIndex = -1;	}	else {		var oThis = this;		var nextFunc = function() {			oThis.animate();		};		this.animationTimeoutId = window.setTimeout(nextFunc, frameInterval);		var nextCallString = this.callStrings[this.animationIndex + 1];		if (nextCallString) {			this.callTimeoutId = window.setTimeout(nextCallString, frameInterval);		}	}}