[RESOLVED] Is it possible to attach a style to an image in an array?
I'm not even sure if I'm asking the right thing: I've got a sequence of images that can be clicked through but I'd like a few - not all - of the images to be shunted a certain number of pixels to the right.
I don't know if there's a way to attach a style determining the position of an image (maybe 2.png in the example below) relative to the position of images in the rest of the sequence whilst leaving the rest alone?
Code:
<script type="text/javascript">
function preload(arr) {
for(var i=0; i<arr.length; i++) (new Image()).src = arr[i];
}
var picsA = ["1.png", "2.png", "3.png", "4.png", "5.png", "6.png"];
preload(picsA);
var index = 0; picNumberA = 0;
function showNextPicA() {
if (picNumberA == (picsA.length -1)) {
picNumberA = 0;
} else {
picNumberA = picNumberA + 1;
}
document.getElementById('placeholderA').src = picsA[picNumberA];
}
</script>
I'm really sorry to be straying so far beyond my understanding and so grateful for any help - thanks for reading so far!
I've been playing around, but can't seem to come up with a sandbox example that will bubble the way you're describing it. Is there somewhere I can grab the code you're using at the moment?
Sorry about the delay, but I believe I may have a way around this finally. Tried canceling the Click event, but when I did that the drag didn't work so a couple things to do:
Insert the line:
Code:
var lastMove;
at the top of the drag script (right after the comment block is as good a place as any).
Insert this code as the last line of the function moveDragableElement:
Code:
lastMove = new Date();
Insert this code as the first line of your function showNextPicA
Code:
if (new Date() - lastMove < 500) return false;
Code simply makes sure that there is a 500ms pause between the last movement of the image and taking action on the onclick event - you can play around with the 500ms in the last line to suit your sensitivity on the click.
I can't believe you persisted with this - it works beautifully! Thank you so much - I wish I had some knowledge to give back! Really, massive thanks for this.
Bookmarks