Autor Zpráva
Adler
Profil *
Prosim o radu
Mam nejakou galerii obrazku (3 definice), ktere horizontálně roluji po najeti na rightarrow.gif
jsem nastavil udalost onMouseOver (puvodne to bylo na kliknuti) ted to funguje (1 definice), ale
neroluje to stale, pouze se to posune o jeden obrazek. musim odjet z prvku a najet znova, pak se to zase posune pouze o jeden obr . Jsem v tomhle lama. Na co bych se mel v .js scriptu zamerit, aby me to scrolovalo stale tedy dokud z prvky neodjedu mysi ? asi zrejme na .scrollForward (2 definice)potazmo scrollReverse ale nevim na co konretne ..jinak cely script je celkem obsahly prave se v tom nejak ztracim...

-------------------------------------------------------------1 definice

<a id="nextButton2" href="javascript:;"onMouseOver="myScroller2.scrollForward()" onMouseOut="zastav()" ><img src="obr/rightarrow.gif" alt="See last image" style="margin-top: 3px; margin-left: -6px;" border="0"/></a>

<a id="previousButton2" href="javascript:;" onMouseOver="myScroller2.scrollReverse()" onMouseOut="zastav()" ><img src="obr/leftarrow.gif" alt="See last image" style="margin-top: 3px; margin-left: -2px;" border="0"/></a>

------------------------------------------------------------------2 definice vytah z externiho *.js

this.scrollForward = function() {
_origOffset = parseInt(_imageScrollerChildDivID.style.left);
_currentOffset = parseInt(_imageScrollerChildDivID.style.left);
_newOffset = _currentOffset - (this.THUMB_WIDTH * iImageScrollAmount);
if (this.THUMB_PADDING > 0) {
_newOffset = _newOffset - ((2 * iImageScrollAmount) * this.THUMB_PADDING);
}
if (bEnableThumbBorder == 1) {
_newOffset = _newOffset - 4;
}
if (IS_SCROLLING == false && _newOffset >= MAX_REVERSE_OFFSET) {
NEW_FORWARD_OFFSET = _newOffset;
moveScrollerLeft(3);
}
};


--------------------------------------3 definice vlozena do html, ke ktere patri samozrejme prvni
<div id="isFrame2" name="isFrame2" style="margin: 20px; padding: 10px; position: relative; overflow: hidden;">


<div id="isImageRow2" name="isImageRow2" style="position: absolute; top: 0px; left: 0px;">


<script type="text/javascript">

var myScroller2 = new ImageScroller2("isFrame2", "isImageRow2");

myScroller2.addThumbnail("obr/baba.gif","obr/baba.gif", "baba", "baba" );

myScroller2.addThumbnail("obr/robohlav.gif","mp3.html", "robohlav.gif", "robohlav.gif");

myScroller2.addThumbnail("obr/bumbac.gif","obr/bumbac.gif", "bumbac.gif", "bumbac.gif");

myScroller2.addThumbnail("obr/baba.gif","obr/baba.gif", "baba", "baba");

myScroller2.addThumbnail("obr/robohlav.gif","obr/robohlav.gif", "robohlav.gif", "robohlav.gif");

myScroller2.addThumbnail("obr/bumbac.gif","obr/bumbac.gif", "bumbac.gif", "bumbac.gif");

myScroller2.setThumbnailHeight(140);

myScroller2.setThumbnailWidth(140);

myScroller2.setThumbnailPadding(3);

myScroller2.setScrollSpeed(3);

myScroller2.setScrollAmount(7);

myScroller2.enableThumbBorder(false);

myScroller2.setScrollType(0);

myScroller2.setClickOpenType(1);

myScroller2.setThumbsShown(3);

myScroller2.renderScroller();

</script>




</div>





</div>
peta
Profil
Adler
odkaz na stranku, pulku programu jsi tu nedal a nikdo nebude tak ochotnej, ze by si to zkopiroval do souboru, pridal obrazky...
Resp, mozna jsem slepy, ale nevidim ten reverse. Navic, reverse je mzna klicove slovo.
Adler
Profil *
jednalo se mě spíš o vseobecné informace, jak Uz jsem to "odladil" :) redefinoval jsem funkci this.scrollEnd, která měla na starost rolování do konce při libovolném počtu obrázků, tu jsem potom zavolal onMouseOver

this.scrollEnd = function() {
if (IS_SCROLLING == false) {
NEW_FORWARD_OFFSET = MAX_REVERSE_OFFSET;
CURRENT_THUMB_INDEX = iNumOfImages - iNumOfThumbsShown;
moveScrollerLeft();
}
};

a pak jsem redefinoval funkce , která zajištují ukončení rolování:
[b]onMouseOut
napr. funkci this.scrollForward2 kde jsem nastavil _newOffset = _currentOffset , coz zpusobi okamzite zastaveni rolujiciho obrázku.

pokud by někdo potřeboval tak zdrojovy kod skriptu je zde :

var ImageScroller2 = function(_imageScrollerParentDivID, _imageScrollerChildDivID) {
_imageScrollerParentDivID = getElem(_imageScrollerParentDivID);
_imageScrollerChildDivID = getElem(_imageScrollerChildDivID);
var prImagePaths = new Array();
var prImageAltText = new Array();
var prImageClicks = new Array();
var prImageDescription = new Array();
var iNumOfThumbsShown = 1;
var iNumOfImages;

var bAutoScroll = 0;
//0=false, 1=true
var iAutoScrollDelay = 2000;
var bAutoScrollDirection = 1;
//0=back, 1=forward
var bAutoReverse = 1;
//0=false, 1=true
var iScrollType = 0;
//0=horizontal, 1=vertical
var bEnableThumbBorder = 0;
//0=no, 1=yes
var bEnableCurrentCount = 1;
//0=no, 1=yes
var bEnableThumbDescription = 0;
//0=no, 1=yes
var bClickOpenType = 0;
//0=same window, 1=new window
var iImageScrollAmount = 1;
//number of images to scroll


var objCounterDiv = "";
var objDescriptionDiv = "";
var iSmoothSlideInterval = 3;
var iSmoothSlideAmount = 1;
var moveTimer ;

this.THUMB_HEIGHT = 80;
this.THUMB_WIDTH = 80;
this.THUMB_PADDING = 4;

var CURRENT_THUMB_INDEX = 1;
var NEW_REVERSE_OFFSET = 0;
var MAX_REVERSE_OFFSET = 0;
var NEW_FORWARD_OFFSET = 0;
var IS_SCROLLING = false;
//* BEGIN FUNCTIONS *//




this.setNumOfImageToScroll = function(_NumOfImagesToScroll) {
iImageScrollAmount = parseInt(_NumOfImagesToScroll);
};
this.enableThumbnailDescription = function(_descriptionDivID) {
bEnableThumbDescription = 1;
objDescriptionDiv = _descriptionDivID;
};

this.setScrollType = function(_iType)
{ if (_iType == 0) { iScrollType = 0; } else {iScrollType = 1; } };



this.setScrollSpeed = function(_iSpeed) {
if (_iSpeed > 0 || _iSpeed < 1000) {
iSmoothSlideInterval = _iSpeed;
}
else {
iSmoothSlideInterval = 7;
}
};
this.setScrollAmount = function(_iAmount) {
if (_iAmount > 0 || _iAmount < 1000) {
iSmoothSlideAmount = _iAmount;
}
else {
iSmoothSlideAmount = 7;
}
};
this.setClickOpenType = function(_openType) {
if (_openType == 0 || _openType == 1) {
bClickOpenType = _openType;
}
};
this.enableCurrentCount = function(_counterDivID) {
bEnableCurrentCount = 1;
objCounterDiv = _counterDivID;
};
this.enableThumbBorder = function(_boolean) {
bEnableThumbBorder = _boolean;
};
this.setThumbsShown = function(_newNumOfThumbsShown) {
iNumOfThumbsShown = parseInt(_newNumOfThumbsShown);
};
this.addThumbnail = function(_thumbnailURL, _fullClickURL, _thumbnailAlt, _thumbnailDescription) {
prImagePaths[prImagePaths.length] = _thumbnailURL;
prImageClicks[prImageClicks.length] = _fullClickURL;
prImageAltText[prImageAltText.length] = _thumbnailAlt;
prImageDescription[prImageDescription.length] = _thumbnailDescription;
};
this.setThumbnailHeight = function(_newThumbHeight) {
this.THUMB_HEIGHT = _newThumbHeight;
};
this.getThumbnailHeight = function() {
return this.THUMB_HEIGHT;
};
this.setThumbnailWidth = function(_newThumbWidth) {
this.THUMB_WIDTH = _newThumbWidth;
};
this.getThumbnailWidth = function() {
return this.THUMB_WIDTH;
};
this.setThumbnailPadding = function(_newThumbPadding) {
this.THUMB_PADDING = _newThumbPadding;
};
this.getThumbnailPadding = function() {
return THUMB_PADDING;
};
this.getCurrentThumbIndex = function() {
return CURRENT_THUMB_INDEX;
};
this.getThumbnailCount = function() {
return iNumOfImages;
};
this.renderScroller = function() {
iNumOfImages = prImagePaths.length;
if (iNumOfThumbsShown > iNumOfImages) {
iNumOfThumbsShown = iNumOfImages;
}
MAX_REVERSE_OFFSET = 0 - (iNumOfImages - iNumOfThumbsShown) * this.THUMB_WIDTH;
if (this.THUMB_PADDING > 0) {
MAX_REVERSE_OFFSET = MAX_REVERSE_OFFSET - (iNumOfImages * this.THUMB_PADDING);
}
if (bEnableThumbBorder == 1) {
MAX_REVERSE_OFFSET = MAX_REVERSE_OFFSET - (iNumOfImages * 4);
}
if (iScrollType == 0) {
_imageScrollerParentDivID.style.width = (this.THUMB_WIDTH * iNumOfThumbsShown) + (iNumOfThumbsShown * (this.THUMB_PADDING * 2)) + "px";
if (bEnableThumbBorder == 1) {
_imageScrollerParentDivID.style.width = (parseInt(_imageScrollerParentDivID.style.width) + (iNumOfThumbsShown * 4)) + "px";
}
_imageScrollerParentDivID.style.height = this.THUMB_HEIGHT + (this.THUMB_PADDING * 2) + "px";
if (bEnableThumbBorder == 1) {
_imageScrollerParentDivID.style.height = (parseInt(_imageScrollerParentDivID.style.height) + 4) + "px";
}
_imageScrollerChildDivID.style.width = (this.THUMB_WIDTH * iNumOfImages) + (iNumOfImages * (this.THUMB_PADDING * 2)) + "px";
if (bEnableThumbBorder == 1) {
_imageScrollerChildDivID.style.width = (parseInt(_imageScrollerChildDivID.style.width) + (iNumOfImages * 4)) + "px";
}
}
else if (iScrollType == 1) {
_imageScrollerParentDivID.style.width = (this.THUMB_WIDTH) + ((this.THUMB_PADDING * 2)) + "px";
if (bEnableThumbBorder == 1) {
_imageScrollerParentDivID.style.width = (parseInt(_imageScrollerParentDivID.style.width) + (4)) + "px";
}
_imageScrollerParentDivID.style.height = (this.THUMB_HEIGHT * iNumOfThumbsShown) + (iNumOfThumbsShown * (this.THUMB_PADDING * 2)) + "px";
if (bEnableThumbBorder == 1) {
_imageScrollerParentDivID.style.height = (parseInt(_imageScrollerParentDivID.style.height) + (iNumOfThumbsShown * 4)) + "px";
}
_imageScrollerChildDivID.style.width = (this.THUMB_WIDTH) + (this.THUMB_PADDING * 2) + "px";
if (bEnableThumbBorder == 1) {
_imageScrollerChildDivID.style.width = (parseInt(_imageScrollerChildDivID.style.width) + 4) + "px";
}
}
//*** [Begin] Image Cacheing code ***//
var oHref;
var oImage;
oHref = document.createElement("a");
oImage = document.createElement("img");

for (i = 0; i < iNumOfImages; i++) {
oHref = document.createElement("a");
oHref.href = prImageClicks[i];
oHref.title = prImageAltText[i];

if (bClickOpenType == 1) {
oHref.target = "_blank";
}

oImage = document.createElement("img");
oImage.src = prImagePaths[i];
oImage.alt = prImageAltText[i];
oImage.border = 0;
oImage.width = this.THUMB_WIDTH;
oImage.height = this.THUMB_HEIGHT;
oImage.style.padding = this.THUMB_PADDING;

oHref.appendChild(oImage);
_imageScrollerChildDivID.appendChild(oHref);

}
//*** [End] Image Cacheing code ***//

if (bEnableCurrentCount == 1) {
addAnEvent(window, "load", this.updateCurrentCount);
}
if (bEnableThumbDescription == 1) {
addAnEvent(window, "load", this.updateCurrentDescription);
}
};



this.scrollUp = function() {
_origOffset = parseInt(_imageScrollerChildDivID.style.top);
_currentOffset = parseInt(_imageScrollerChildDivID.style.top);
_newOffset = _currentOffset - (this.THUMB_HEIGHT * iImageScrollAmount);
if (this.THUMB_PADDING > 0) {
_newOffset = _newOffset - (2 * this.THUMB_PADDING);
}
if (bEnableThumbBorder == 1) {
_newOffset = _newOffset - 4;
}
if (IS_SCROLLING == false && _newOffset >= MAX_REVERSE_OFFSET) {
NEW_FORWARD_OFFSET = _newOffset;
moveScrollerUp();
}
};
this.scrollDown = function() {
_origOffset = parseInt(_imageScrollerChildDivID.style.top);
_currentOffset = parseInt(_imageScrollerChildDivID.style.top);
_newOffset = _currentOffset + (this.THUMB_HEIGHT * iImageScrollAmount);
if (this.THUMB_PADDING > 0) {
_newOffset = _newOffset + (2 * this.THUMB_PADDING);
}
if (bEnableThumbBorder == 1) {
_newOffset = _newOffset + 4;
}
if (_newOffset <= 0) {
if(_currentOffset > (_origOffset - this.THUMB_HEIGHT)) {
if (IS_SCROLLING == false && _newOffset >= MAX_REVERSE_OFFSET) {
NEW_REVERSE_OFFSET = _newOffset;
moveScrollerDown();
}
}
}
};
this.scrollTop = function() {
if (IS_SCROLLING == false) {
NEW_FORWARD_OFFSET = ( - 1 * (iNumOfImages - iNumOfThumbsShown) * this.THUMB_HEIGHT);
amater2560
Profil *
Je zbytočné na to používať Javascript ked to iste funguje jednoriadkovým zápisom
tagom
<MARQUEE parametre>

Vaše odpověď

Mohlo by se hodit

Neumíte-li správně určit příčinu chyby, vkládejte odkazy na živé ukázky.
Užíváte-li nějakou cizí knihovnu, ukažte odpovídajícím, kde jste ji vzali.

Užitečné odkazy:

Prosím používejte diakritiku a interpunkci.

Ochrana proti spamu. Napište prosím číslo dvě-sta čtyřicet-sedm:

0