Scroll the page vertically wait and roll again

Asked

Viewed 40 times

0

I have a PHP page that reads an XML with an RSS, I wonder if there is a way to scroll the page until the second RSS appears and then continue until the next RSS so successively.

See the page: http://rss.dbcam.com.br/principais

Scrolling shows other RSS below.

Another option would be a way for me to load the first RSS, then delete it and appear the second and so on.

  • Hello David, this link HTML you show is full of errors. Do you have control over this HTML? it is you who create it or it is of an external site?

  • yes, it is I who have control. It is with some flaws because I am just using this for example.

1 answer

1

You have HTML issues you need to fix.

remember that Ids have to be unique. So at the same time

<div id='corpo'>
    <div id='foto'>
        <img id="foto"

you must use classes and switch to:

<div class='corpo'>
    <div class='foto'>
        <img class="foto"

In your HTML there is another problem that is some Divs are not closed. The Divs class="corpo" are getting inside of themselves.

Regarding your scroll question you can do so, using classes:

var $noticias = $('.corpo');
var qtd = $noticias.length;
var i = 0;
setInterval(function () {
if ((i++) == qtd) i = 0;
    $('html, body').animate({
        scrollTop: $noticias.eq(i).position().top
    }, 800); // <--- velocidade do scroll

}, 2000);  // <--- tempo de espera entre cada imagem

jsFiddle: http://jsfiddle.net/0ufjvuyx/

Browser other questions tagged

You are not signed in. Login or sign up in order to post.