MozillaPL.org - polskie centrum Mozilli

Główne menu:

[JS] przesuwana galeria a Firefox

Jak tworzyć strony WWW zgodnie ze standardami

Moderator: Pomocy?!

[JS] przesuwana galeria a Firefox

Postautor: ogon » 20 maja 2006, 18:19

Przeglądarka: Mozilla/5.0 (Windows; U; Windows NT 5.0; pl; rv:1.8.0.3) Gecko/20060426 Firefox/1.5.0.3

witam!
znalazlem fajną rzecz - przesuwana galeria:
Kod: Zaznacz cały
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>

   <head>
      <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
      <meta name="generator" content="Adobe GoLive 4">
      <script type="text/javascript"><!--
var w=235;
var h=295;
var l=screen.width-(w+15);
var features='left='+l+',top=0,width='+w+',height='+h+',resizable=yes';

function pop(url) {
window.open(url,'',features);
}
// -->
      </script>
      <script type="text/javascript"><!--
//<![CDATA[

//* preload rollover
var roll = new Image()
roll.src = 'spiraalmetman3opt.jpg'

var speed = 1;
var intervalVal = "";
var prevPos = 0;
var currPos = 0;

function arrowCenter()
{
   var posLeft = document.getElementById("arrow").style.pixelLeft;
   var pixelWidth = document.getElementById("arrow").style.pixelWidth;

   return posLeft + (pixelWidth / 2);
}

function scrollIt(objImg)
{
   var imgWidth = objImg.offsetWidth;
   var iDivEdgeToImgCenter = objImg.offsetLeft + (imgWidth / 2);
   var iDivEdgeToArrowCenter = arrowCenter() - currPos;
   var iAmountToMove = iDivEdgeToArrowCenter - iDivEdgeToImgCenter + 26;

   clearInterval(intervalVal);

   if(iAmountToMove > 0)
      intervalVal = setInterval("doRight(" + objImg.id + ")", speed);
   else if(iAmountToMove < 0)
      intervalVal = setInterval("doLeft(" + objImg.id + ")", speed);
}

function doRight(objImg)
{
   var imgWidth = objImg.offsetWidth;
   var iDivEdgeToImgCenter = objImg.offsetLeft + Math.round((imgWidth / 2));
   var iDivEdgeToArrowCenter = arrowCenter() - currPos;

    currPos = document.getElementById("container").style.posLeft;
   if((iDivEdgeToArrowCenter - iDivEdgeToImgCenter + 26) == 0)
   {
      clearInterval(intervalVal);
      return;
   }
   
   currPos++;
   document.getElementById("container").style.posLeft = currPos;
}

function doLeft(objImg)
{
   var imgWidth = objImg.offsetWidth;
   var iDivEdgeToImgCenter = objImg.offsetLeft + Math.round((imgWidth / 2));
   var iDivEdgeToArrowCenter = arrowCenter() - currPos;

   currPos = document.getElementById("container").style.posLeft;
   if((iDivEdgeToArrowCenter - iDivEdgeToImgCenter + 26) == 0)
   {
      clearInterval(intervalVal);
      return;
   }

   currPos--;
   document.getElementById("container").style.posLeft = currPos;
}

//]]>
// -->
      </script>
      <link href="http://www.inspiration-company.nl/layout2.css" rel="stylesheet" type="text/css">
      <style type="text/css"><!--
         #container { border: solid 0px #6699cc; position: absolute; top: 100px; left: 0px; width: 5788px; visibility: visible; #: absolute; }
         #middle { position: absolute; top: 95px; left: 0px; width: 950px; height: 350px; overflow: hidden; visibility: visible }
         .images { float: left; border: none; position: relative; }
         body { background-color: #ffffff; overflow: hidden; }-->
      </style>
   </head>

   <body>
      <div id="middle">
         <div id="container">
            <table>
               <tr>
                  <td>
                     <div class="kop">
                        <img border="0" src="dotwhite.gif" height="1" width="52"> Image1
                        <img border="0" src="http://www.inspiration-company.nl/dotwhite.gif" height="1" width="155">Image 2
                        <img border="0" src="http://www.inspiration-company.nl/dotwhite.gif" height="1" width="135">Image 3
                        <img border="0" src="http://www.inspiration-company.nl/dotwhite.gif" height="1" width="145">Image 4
                        <img border="0" src="http://www.inspiration-company.nl/dotwhite.gif" height="1" width="145">Image 5
                        <img border="0" src="http://www.inspiration-company.nl/dotwhite.gif" height="1" width="145">Image 6</div>
                  </td>
               </tr>
               <tr>
               <td>
                  <a href="(Empty Reference!)" target="_self"><img ID="LinkA" class="images" border="0" src="http://www.inspiration-company.nl/intromanopschommelopt.jpg"></a>
                  <img class="images" border="0" src="http://www.inspiration-company.nl/dotwhite.gif" height="1" width="40">
                  <a href="(Empty Reference!)" target="_self"><img ID="LinkB" class="images" border="0" src="http://www.inspiration-company.nl/introgatinluchtopt.jpg"></a>
                  <img class="images" border="0" src="http://www.inspiration-company.nl/dotwhite.gif" height="1" width="40">
                  <a href="(Empty Reference!)" target="_self"><img ID="LinkC" class="images" border="0" src="http://www.inspiration-company.nl/introvogelsincirkelopt.jpg"></a>
                  <img class="images" border="0" src="http://www.inspiration-company.nl/dotwhite.gif" height="1" width="40">
                  <a href="(Empty Reference!)" target="_self"><img ID="LinkD" class="images" border="0" src="http://www.inspiration-company.nl/intromanopschommelopt.jpg"></a>
                  <img class="images" border="0" src="http://www.inspiration-company.nl/dotwhite.gif" height="1" width="40">
                  <a href="(Empty Reference!)" target="_self"><img ID="LinkE" class="images" border="0" src="http://www.inspiration-company.nl/intromanopschommelopt.jpg"></a>
                  <img class="images" border="0" src="http://www.inspiration-company.nl/dotwhite.gif" height="1" width="40">
                  <a href="(Empty Reference!)" target="_self"><img ID="LinkF" class="images" border="0" src="http://www.inspiration-company.nl/introgatinluchtopt.jpg"></a>
                  <img class="images" border="0" src="http://www.inspiration-company.nl/dotwhite.gif" height="1" width="40">
               </td>
            </tr>
                <tr>
                  <td></td>
               </tr>
            </table>
         </div>
         </div>
       
      <div id="links">
         <a href="#" onclick="scrollIt(LinkA);">LinkA: scroll to image 1, is that possible?</a><br>
         <a href="#" onclick="scrollIt(LinkB);">LinkB: scroll to image 2, is that possible?</a><br>
         <a href="#" onclick="scrollIt(LinkC);">LinkC: scroll to image 3, is that possible?</a><br>   
         <a href="#" onclick="scrollIt(LinkD);">LinkD: scroll to image 4, is that possible?</a><br>
         <a href="#" onclick="scrollIt(LinkE);">LinkE: scroll to image 5, is that possible?</a><br>   
         <a href="#" onclick="scrollIt(LinkF);">LinkF: scroll to image 6, is that possible?</a><br>
     </div>
      <div id="arrow" style="position: absolute; top: 150px; left: 460px;">
         <img src="http://www.inspiration-company.nl/pijl-omlaagkleinopt.jpg" width="50" height="50" border="0"></div>
   </body>

</html>

ALE! pod IE smiga w przeciwienstwie do Firefoxa.. wiecie moze co z tym kodem zrobic, zeby smigalo pod FF?
pozdrawiam!
ogon
 

Postautor: ogon » 21 maja 2006, 12:44

Przeglądarka: Mozilla/5.0 (Windows; U; Windows NT 5.0; pl; rv:1.8.0.3) Gecko/20060426 Firefox/1.5.0.3

jeszecze jedno.. wlasnie sprawdzilem sobie ten kod krok po kroku i jesli sie nie myle, to FF wykonuje wszystko do momentu:
Kod: Zaznacz cały
document.getElementById("container").style.posLeft = currPos;
w f-cjach 'doLeft' i 'doRight'. i mam zawias.. jest ktos moze kto sie zna na JS?:)
pozdrawiam!
ogon
 

Postautor: riddle » 21 maja 2006, 13:53

Przeglądarka: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.3) Gecko/20060426 Firefox/1.5.0.3

O ile wiem nie ma czegoś takiego jak posLeft tylko jest offsetLeft… pogooglaj, nie wiem czy to się aplikuje do style czy od razu do obiektu
riddle
 
Posty: 502
Z nami od: 24 maja 2004, 17:43
Lokalizacja: Łódź

Postautor: ogon » 21 maja 2006, 14:04

Przeglądarka: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.1.4322)

no wlasnie tak kombinuje, narazie bez efektu. dalem offsetLeft gdzie trzeba a teraz bede kombinowal z tymi stylami jak napisales:)
ogon
 

Postautor: riddle » 21 maja 2006, 15:26

Przeglądarka: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.3) Gecko/20060426 Firefox/1.5.0.3

A i właśnie… przypomniałem sobie, że nie da się modyfikować offset____ (Left, Top, Width etc)… można to robić tylko przez zwykłe style.
riddle
 
Posty: 502
Z nami od: 24 maja 2004, 17:43
Lokalizacja: Łódź

Postautor: Gość » 21 maja 2006, 15:37

Przeglądarka: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.1.4322)

yeay! :) juz dziala!!!
tak jak pisales - nie ma czegos takiego dla FF jak posLeft, ale i offsetLeft do konca nie dziala w tym miejscu jak trzeba. dalem wiec:
Kod: Zaznacz cały
document.getElementById("container").style.left = currPos + "px";

i dziala:)) oczywiscie sam do tego nie doszedlem, ale tlumacze dla innych:)
dzieki za odpowiedzi riddle:) pozdrawiam!!!
Gość
 

Postautor: riddle » 21 maja 2006, 20:45

Przeglądarka: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.3) Gecko/20060426 Firefox/1.5.0.3

Chodziło mi o to, że tak jak używasz

var posLeft = document.getElementById("arrow").style.pixelLeft;

to powinno się używać offsetLeft zwracający odgległość od lewej krawędzi, w tym przypadku, body. Potem mając tą wartość można modyfikować style.left. Nie słyszałem o pixelLeft, może to jakiś relikt MS.
riddle
 
Posty: 502
Z nami od: 24 maja 2004, 17:43
Lokalizacja: Łódź


Wróć do Tworzenie stron WWW

Kto jest online

Zarejestrowani użytkownicy: Baidu [Spider], Bing [Bot], Google [Bot]

Przejdź do powiązanej strony

Nawigacja:

Stopka: