Home | Registrieren | Einloggen | Suchen | Aktuelles


Forum » Auszeichnungssprachen » Object sanft verschieben Antworten
Object sanft verschieben

Lewi
Quasselstrippe


Beiträge: 288


Hi,

ich suche ein Script, mit dem in ein Object auf einer Seite um 200px (oder was auch immer) nach unten verschieben kann. Dieses Verschieben soll allerdings nicht ruckartig sein, sondern sanft (am besten mit Beschleunigungs- und Abbremsphase).

Hat jemand etwas für mich?

Danke
Lewi


---
Lewi = ehemals the_doc

  Profil   Website   Editieren   Zitieren

Al Blank
Quasselstrippe


Beiträge: 368


Hi,

ich hätte da eine DW-Extension.

1: 
2: 
3: 
4: 
5: 
6: 
7: 
8: 
9: 
10: 
11: 
12: 
13: 
14: 
15: 
16: 
17: 
18: 
19: 
20: 
21: 
22: 
23: 
24: 
25: 
26: 
27: 
28: 
29: 
30: 
31: 
32: 
33: 
34: 
35: 
36: 
37: 
38: 
39: 
40: 
41: 
42: 
43: 
44: 
45: 
46: 
47: 
48: 
49: 
50: 
51: 
52: 
53: 
54: 
55: 
56: 
57: 
58: 
59: 
60: 
61: 
62: 
63: 
64: 
65: 
66: 
67: 
68: 
69: 
70: 
71: 
72: 
73: 
74: 
75: 
76:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Ebende verschieben mit Abbremsen</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function flevSlideDiv() { // v2.0, Marja Ribbers-de Vroed, FlevOOware
	if (arguments.length < 4) {return;}
	var sD = arguments[0]; if (sD == "") {return;}
	var	oD = eval("MM_findObj('" + sD + "')"); if (oD == null) {return;}
	var iNX = parseInt(arguments[1]), iNY = parseInt(arguments[2]), iS = parseInt(arguments[3]);
	var iPx = (arguments.length > 4) ? parseInt(arguments[4]) : 0;
	var iR = (arguments.length > 5) ? parseInt(arguments[5]) : 0;
	var iT = 10, sS = ""; if (!document.layers) {oD = oD.style;} 
	if (oD.tT != null) {clearTimeout(oD.tT);}
	var iCX = parseInt(oD.left), iCY = parseInt(oD.top);
	if (iR != 0) { // relative
		if (iR == 1) {iNX = iCX - iNX; iNY = iCY;} // left
		else if (iR == 2) {iNX = iCX + iNX; iNY = iCY;} // right
		else if (iR == 3) {iNY = iCY - iNY; iNX = iCX;} // up
		else {iNY = iCY + iNY; iNX = iCX;} // down
	}
	var iX = iNX, iY = iNY;
	if ((iCX != iNX) || (iCY != iNY)) {
		if (iPx > 0) { iT = iS;
			var iPxX = iPx, iPxY = iPx, iMX = Math.abs(iCX - iNX), iMY = Math.abs(iCY - iNY);
			if (iMX < iMY) {iPxY = (iMX != 0) ? ((iMY/iMX)*iPx) : iPx;}
			else {iPxX = (iMY != 0) ? ((iMX/iMY)*iPx) : iPx;}
			if (iPxX >= iMX) {iPxX = Math.min(Math.ceil(iPxX), iPx);}
			if (iPxY >= iMY) {iPxY = Math.min(Math.ceil(iPxY), iPx);}
			if ((iCX < iNX) && (iCX + iPxX < iNX)) {iNX = iCX + iPxX;}
			if ((iCX > iNX) && (iCX - iPxX > iNX)) {iNX = iCX - iPxX;}
			if ((iCY < iNY) && (iCY + iPxY < iNY)) {iNY = iCY + iPxY;}
			if ((iCY > iNY) && (iCY - iPxY > iNY)) {iNY = iCY - iPxY;}
		}
		else {
			var iMX = ((iNX - iCX) / iS); 
			iMX = (iMX > 0) ? Math.ceil(iMX) : Math.floor(iMX);
			iNX = iCX + iMX; 
			var iMY = ((iNY - iCY) / iS); 
			iMY = (iMY > 0) ? Math.ceil(iMY) : Math.floor(iMY);
			iNY = iCY + iMY;
		}
		if ((parseInt(navigator.appVersion)>4 || navigator.userAgent.indexOf("MSIE")>-1) && (!window.opera)) {sS="px";}
		if (iMX != 0) {eval("oD.left = '" + iNX + sS + "'");}
		if (iMY != 0) {eval("oD.top = '" + iNY + sS + "'");}
		var sFunction = "flevSlideDiv('" + sD + "'," + iX + "," + iY + "," + iS + "," + iPx + ",0)";
		oD.tT = setTimeout(sFunction,iT);
	}
}
//-->
</script>
</head>

<body>
<a href="#" onClick="flevSlideDiv('ebene',10,200,20,0,0)">Ebene verschieben</a>
<div id="ebene" style="position:absolute; width:100px; height:50px; z-index:1; background-color: #FF0000; layer-background-color: #FF0000; border: 1px #000000; top: 80; left: 10;"></div>
</body>
</html>


onClick="flevSlideDiv('ebene',10,200,20,0,0)

Hier bestimmt der Wert 20 die Beschleunigung/Abbremsung!
10 ist die horizontale, 200 die vertikale Richtung.
Mit den anderen 2 Werten kannst Du auch einstellen das sich die Ebene pro Klick immer weiterbewegt.


Grüße,

Al Blank


Edit:

Slide Layer (v2):
This behavior makes a layer slide to a specified position in the browser window.

It is possible to choose between:
* sliding at constant speed, and
* sliding at gradually decreasing speed.
The sliding speed is adjustable to your needs in both sliding options.

Furthermore, it is possible to choose between:
* absolute movement, where the layer slides to a specified left/top position, and
* relative movement, where the layer slides a given number of pixels left/right/up/down in relation to its current position.

The behavior has been tested (on PC) to be compatible with:
* Internet Explorer 5+ (but it probably also works in IE4.x),
* Netscape 4.x,
* Netscape 6.2+,
* Opera 5+, and
* Mozilla 0.9+&ltbr>

Diese Nachricht wurde geändert von: Al Blank
  Profil   Editieren   Zitieren

Lewi
Quasselstrippe


Beiträge: 288


Wow, genau was ich brauche. Vielen Dank!

---
Lewi = ehemals the_doc

  Profil   Website   Editieren   Zitieren

languitar
Foren-Team


Beiträge: 2795


Wie auch immer das dann mit dem Copyright ist, wenn man keinen Dreamweaver besitzt...

---
Take a look here!
Lichtblick - Einblick - Ausblick

  Profil   E-Mail   Website   Editieren   Zitieren
 

Antworten
Nach oben