PSD-Tutorials.de
Forum für Design, Fotografie & Bildbearbeitung
Tutkit
Agentur
Hilfe
Kontakt
Start
Forum
Aktuelles
Besonderer Inhalt
Foren durchsuchen
Tutorials
News
Anmelden
Kostenlos registrieren
Aktuelles
Suche
Suche
Nur Titel durchsuchen
Von:
Menü
Anmelden
Kostenlos registrieren
App installieren
Installieren
JavaScript ist deaktiviert. Für eine bessere Darstellung aktiviere bitte JavaScript in deinem Browser, bevor du fortfährst.
Du verwendest einen veralteten Browser. Es ist möglich, dass diese oder andere Websites nicht korrekt angezeigt werden.
Du solltest ein Upgrade durchführen oder einen
alternativen Browser
verwenden.
Antworten auf deine Fragen:
Neues Thema erstellen
Start
Forum
Sonstiges
Webdesign, Webentwicklung & Programmierung
PHP, Javascript, jQuery, Ajax, nodeJS, MySQL...
JS sliding panel
Beitrag
<blockquote data-quote="limubai81" data-source="post: 1139776" data-attributes="member: 83538"><p>hiho ich habe im inet ein script gefunden mit welchen eine divbox auf- und zugeslided wird. nur leider wird beim ersten betätigen des buttons die box von der falschen stelle und seite aufgezogen. Sie soll aber auch beim ersten betatigen genauso aufsliden wie bei den darauf folgenden klicks.</p><p>das script hab ich von hier</p><p></p><p></p><p>meine testdatei:</p><p></p><p></p><p>der quelltext: [html]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"></p><p><html xmlns="http://www.w3.org/1999/xhtml"></p><p><head></p><p><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></p><p><title>Unbenanntes Dokument</title></p><p><script type="text/javascript"></p><p>function animate(elementID, newLeft, newTop, newWidth,</p><p> newHeight, time, callback)</p><p>{</p><p> var el = document.getElementById(elementID);</p><p> if(el == null)</p><p> return;</p><p> </p><p> var cLeft = parseInt(el.style.left);</p><p> var cTop = parseInt(el.style.top);</p><p> var cWidth = parseInt(el.style.width);</p><p> var cHeight = parseInt(el.style.height);</p><p> </p><p> var totalFrames = 1;</p><p> if(time> 0)</p><p> totalFrames = time/40;</p><p></p><p> var fLeft = newLeft - cLeft;</p><p> if(fLeft != 0)</p><p> fLeft /= totalFrames;</p><p> </p><p> var fTop = newTop - cTop;</p><p> if(fTop != 0)</p><p> fTop /= totalFrames;</p><p> </p><p> var fWidth = newWidth - cWidth;</p><p> if(fWidth != 0)</p><p> fWidth /= totalFrames;</p><p> </p><p> var fHeight = newHeight - cHeight;</p><p> if(fHeight != 0)</p><p> fHeight /= totalFrames;</p><p> </p><p> doFrame(elementID, cLeft, newLeft, fLeft,</p><p> cTop, newTop, fTop, cWidth, newWidth, fWidth,</p><p> cHeight, newHeight, fHeight, callback);</p><p>}</p><p></p><p>function doFrame(eID, cLeft, nLeft, fLeft,</p><p> cTop, nTop, fTop, cWidth, nWidth, fWidth,</p><p> cHeight, nHeight, fHeight, callback)</p><p>{</p><p> var el = document.getElementById(eID);</p><p> if(el == null)</p><p> return;</p><p></p><p> cLeft = moveSingleVal(cLeft, nLeft, fLeft);</p><p> cTop = moveSingleVal(cTop, nTop, fTop);</p><p> cWidth = moveSingleVal(cWidth, nWidth, fWidth);</p><p> cHeight = moveSingleVal(cHeight, nHeight, fHeight);</p><p></p><p> el.style.left = Math.round(cLeft) + 'px';</p><p> el.style.top = Math.round(cTop) + 'px';</p><p> el.style.width = Math.round(cWidth) + 'px';</p><p> el.style.height = Math.round(cHeight) + 'px';</p><p> </p><p> if(cLeft == nLeft && cTop == nTop && cHeight == nHeight</p><p> && cWidth == nWidth)</p><p> {</p><p> if(callback != null)</p><p> callback();</p><p> return;</p><p> }</p><p> </p><p> setTimeout( 'doFrame("'+eID+'",'+cLeft+','+nLeft+','+fLeft+','</p><p> +cTop+','+nTop+','+fTop+','+cWidth+','+nWidth+','+fWidth+','</p><p> +cHeight+','+nHeight+','+fHeight+','+callback+')', 40);</p><p>}</p><p></p><p>function moveSingleVal(currentVal, finalVal, frameAmt)</p><p>{</p><p> if(frameAmt == 0 || currentVal == finalVal)</p><p> return finalVal;</p><p> </p><p> currentVal += frameAmt;</p><p> if((frameAmt> 0 && currentVal>= finalVal)</p><p> || (frameAmt <0 && currentVal <= finalVal))</p><p> {</p><p> return finalVal;</p><p> }</p><p> return currentVal;</p><p>}</p><p></p><p></p><p></p><p>function slideExample2(elementId, headerElement)</p><p>{</p><p> var element = document.getElementById(elementId);</p><p> if(element.up == false || element.down)</p><p> {</p><p> animate(elementId, 150, 0, 0, 150, 250, null);</p><p> element.up = true;</p><p> element.down = false;</p><p> headerElement.innerHTML = '+';</p><p> }</p><p> else</p><p> {</p><p> animate(elementId, 0, 0, 150, 150, 250, null);</p><p> element.down = true;</p><p> element.up = false;</p><p> headerElement.innerHTML = '-';</p><p> }</p><p>}</p><p></p><p></p><p></p><p></p><p></script></p><p></head></p><p></p><p><body></p><p><div></p><p><div style="position:relative;</p><p> width:150px;</p><p> height:170px;</p><p> top:0px;</p><p> left:0px;"></p><p> <div id="exampleHeader2"</p><p> style="position:absolute;</p><p> width:20px;</p><p> height:150px;</p><p> top:0px;</p><p> left:150px;</p><p> background:#3b587a;</p><p> text-align:center;</p><p> color:#FFFFFF;"</p><p> onclick="slideExample2('examplePanel2', this);"></p><p> +</p><p> </div></p><p> <div id="examplePanel2"</p><p> style="position:absolute;</p><p> width:0px;</p><p> height:150px;</p><p> top:0px;</p><p> left:20px;</p><p> background:#a6bbcd;</p><p> overflow:hidden;"></p><p> Content</p><p> </div></p><p></div></p><p></div></p><p></p><p></body></p><p></html></p><p>[/html]lg LiMu</p></blockquote><p></p>
[QUOTE="limubai81, post: 1139776, member: 83538"] hiho ich habe im inet ein script gefunden mit welchen eine divbox auf- und zugeslided wird. nur leider wird beim ersten betätigen des buttons die box von der falschen stelle und seite aufgezogen. Sie soll aber auch beim ersten betatigen genauso aufsliden wie bei den darauf folgenden klicks. das script hab ich von hier meine testdatei: der quelltext: [html]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Unbenanntes Dokument</title> <script type="text/javascript"> function animate(elementID, newLeft, newTop, newWidth, newHeight, time, callback) { var el = document.getElementById(elementID); if(el == null) return; var cLeft = parseInt(el.style.left); var cTop = parseInt(el.style.top); var cWidth = parseInt(el.style.width); var cHeight = parseInt(el.style.height); var totalFrames = 1; if(time> 0) totalFrames = time/40; var fLeft = newLeft - cLeft; if(fLeft != 0) fLeft /= totalFrames; var fTop = newTop - cTop; if(fTop != 0) fTop /= totalFrames; var fWidth = newWidth - cWidth; if(fWidth != 0) fWidth /= totalFrames; var fHeight = newHeight - cHeight; if(fHeight != 0) fHeight /= totalFrames; doFrame(elementID, cLeft, newLeft, fLeft, cTop, newTop, fTop, cWidth, newWidth, fWidth, cHeight, newHeight, fHeight, callback); } function doFrame(eID, cLeft, nLeft, fLeft, cTop, nTop, fTop, cWidth, nWidth, fWidth, cHeight, nHeight, fHeight, callback) { var el = document.getElementById(eID); if(el == null) return; cLeft = moveSingleVal(cLeft, nLeft, fLeft); cTop = moveSingleVal(cTop, nTop, fTop); cWidth = moveSingleVal(cWidth, nWidth, fWidth); cHeight = moveSingleVal(cHeight, nHeight, fHeight); el.style.left = Math.round(cLeft) + 'px'; el.style.top = Math.round(cTop) + 'px'; el.style.width = Math.round(cWidth) + 'px'; el.style.height = Math.round(cHeight) + 'px'; if(cLeft == nLeft && cTop == nTop && cHeight == nHeight && cWidth == nWidth) { if(callback != null) callback(); return; } setTimeout( 'doFrame("'+eID+'",'+cLeft+','+nLeft+','+fLeft+',' +cTop+','+nTop+','+fTop+','+cWidth+','+nWidth+','+fWidth+',' +cHeight+','+nHeight+','+fHeight+','+callback+')', 40); } function moveSingleVal(currentVal, finalVal, frameAmt) { if(frameAmt == 0 || currentVal == finalVal) return finalVal; currentVal += frameAmt; if((frameAmt> 0 && currentVal>= finalVal) || (frameAmt <0 && currentVal <= finalVal)) { return finalVal; } return currentVal; } function slideExample2(elementId, headerElement) { var element = document.getElementById(elementId); if(element.up == false || element.down) { animate(elementId, 150, 0, 0, 150, 250, null); element.up = true; element.down = false; headerElement.innerHTML = '+'; } else { animate(elementId, 0, 0, 150, 150, 250, null); element.down = true; element.up = false; headerElement.innerHTML = '-'; } } </script> </head> <body> <div> <div style="position:relative; width:150px; height:170px; top:0px; left:0px;"> <div id="exampleHeader2" style="position:absolute; width:20px; height:150px; top:0px; left:150px; background:#3b587a; text-align:center; color:#FFFFFF;" onclick="slideExample2('examplePanel2', this);"> + </div> <div id="examplePanel2" style="position:absolute; width:0px; height:150px; top:0px; left:20px; background:#a6bbcd; overflow:hidden;"> Content </div> </div> </div> </body> </html> [/html]lg LiMu [/QUOTE]
Bilder bitte
hier hochladen
und danach über das Bild-Icon (Direktlink vorher kopieren) platzieren.
Zitate einfügen…
Authentifizierung
Wenn ★ = 12, ◇ = 4 und die Hälfte von ★ zu ◇ addiert wird, was ist das Ergebnis?
Antworten
Start
Forum
Sonstiges
Webdesign, Webentwicklung & Programmierung
PHP, Javascript, jQuery, Ajax, nodeJS, MySQL...
JS sliding panel
Oben