Why Does Js Slideshow Skip First Two Slides?

Joansy

My Javascript slideshow works, except for the first two images act clunky. The images "skip" in, then seem to get caught when they're supposed to fade. The slideshow also starts with the last image instead of the first, which is why I have moved the images in the HTML out of order. What is causing this in the code?

The Javascript:

<script>
    $("#slideshow > div:gt(0)").hide();

    setInterval(function() { 
        $('#slideshow > div:first')
            .fadeOut(10000)
            .next()
            .fadeIn(10000)
            .end()
            .appendTo('#slideshow');
    }, 10000);
</script>

The HTML:

<div id="slideshow">
    <div>
        <img src="img/2.jpg">
    </div>
    <div>
        <img src="img/3.jpg">
    </div>
    <div>
        <img src="img/1.jpg">
    </div>
</div>

The CSS:

#slideshow { 
    position: relative; 
    width: 100%; 
    height: 350px; 
}

#slideshow > div { 
    position: absolute;
}
Joansy

I discovered that my code will work the way I need if I add the same number of next/fadein/end sequences as photos I have. So, in this case, that's three, so I should have three next/fadein/ends before the appendTo.

This makes the transition to the next image fade, not jump.

    $("#slideshow > div:gt(0)").hide();

    setInterval(function() { 
        $('#slideshow > div:first')
        .fadeOut(5000)
        .next()
        .fadeIn(5000)
        .end()
        .next()
        .fadeIn(5000)
        .end()
        .next()
        .fadeIn(5000)
        .end()
        .appendTo('#slideshow');
    }, 5000);

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Messed up slides in custom minimal JS/CSS slideshow

From Dev

Why does xargs skip first argument when passing to subshell?

From Dev

Why does apply skip first element of array used for arguments?

From Dev

gnuplot - skip first two lines

From Dev

Why does When.js promise.then skip a function?

From Dev

Why does not work two controller in Angular JS?

From Dev

Why does using keep_if in Ruby skip over the first element in an array?

From Dev

Why does using keep_if in Ruby skip over the first element in an array?

From Dev

Why does a Java while loop that asks for user input using scanner skip the first input

From Dev

Why does NSNumberFormatter skip a number?

From Dev

Why does it skip the "control" segment?

From Dev

Why does git store objects in directories with the first two characters of the hash?

From Dev

Why does the first column of a XamDataGrid have two LabelPresenters?

From Dev

skip first two elements in an enumeration -- python

From Dev

skip first two elements in an enumeration -- python

From Dev

Slideshow: How to jump to different slides with div ids?

From Dev

javascript slideshow thing opens all slides at once

From Dev

Why does "return;" skip iterations in $.each()?

From Dev

Why does the code skip the for-loop

From Dev

why does javascript skip some of my functions?

From Dev

why does javascript skip some of my functions?

From Dev

Why does Xcode skip for loop code?

From Dev

Why does this recursive function skip numbers?

From Dev

Why does my loop skip even steps?

From Dev

Snake Game - why does the snake skip a tile?

From Dev

Why does scanf skip getting string input?

From Dev

List names of sheets in Google Sheets and skip the first two

From Dev

Ruby CSV: How to skip the first two lines of file?

From Dev

How to skip first two line of CSV in Oracle Loader

Related Related

  1. 1

    Messed up slides in custom minimal JS/CSS slideshow

  2. 2

    Why does xargs skip first argument when passing to subshell?

  3. 3

    Why does apply skip first element of array used for arguments?

  4. 4

    gnuplot - skip first two lines

  5. 5

    Why does When.js promise.then skip a function?

  6. 6

    Why does not work two controller in Angular JS?

  7. 7

    Why does using keep_if in Ruby skip over the first element in an array?

  8. 8

    Why does using keep_if in Ruby skip over the first element in an array?

  9. 9

    Why does a Java while loop that asks for user input using scanner skip the first input

  10. 10

    Why does NSNumberFormatter skip a number?

  11. 11

    Why does it skip the "control" segment?

  12. 12

    Why does git store objects in directories with the first two characters of the hash?

  13. 13

    Why does the first column of a XamDataGrid have two LabelPresenters?

  14. 14

    skip first two elements in an enumeration -- python

  15. 15

    skip first two elements in an enumeration -- python

  16. 16

    Slideshow: How to jump to different slides with div ids?

  17. 17

    javascript slideshow thing opens all slides at once

  18. 18

    Why does "return;" skip iterations in $.each()?

  19. 19

    Why does the code skip the for-loop

  20. 20

    why does javascript skip some of my functions?

  21. 21

    why does javascript skip some of my functions?

  22. 22

    Why does Xcode skip for loop code?

  23. 23

    Why does this recursive function skip numbers?

  24. 24

    Why does my loop skip even steps?

  25. 25

    Snake Game - why does the snake skip a tile?

  26. 26

    Why does scanf skip getting string input?

  27. 27

    List names of sheets in Google Sheets and skip the first two

  28. 28

    Ruby CSV: How to skip the first two lines of file?

  29. 29

    How to skip first two line of CSV in Oracle Loader

HotTag

Archive