javascript - detect when an html element exits the screen -


i have marquee. (tag < marquee >). when first element (the span class "span1") stops being seen on screen, notify me.

enter image description here

http://jsfiddle.net/5o4ez17s/

    <div id='container_marquee'>      <marquee id='mymarquee' behavior="scroll" onmouseover="this.stop();" onmouseout="this.start();">                <span class='span1'>first marquee text</span>                <span class='span2'>second marquee text</span>                <span class='span3'>third marquee text</span>                <span class='span4'>fourth marquee text</span>                <span class='span5'>fifth marquee text</span>      </marquee>     </div> 

for example.. :

alert("the first span not visible on screen"); 

i not want have set interval or something, maybe there more efficient way it. perhaps associate listening event or something.

you time , alert user when ticks finished.

    var ticks = 0;     var timeformarquee = 24; //how long takes marquee hit edge (seconds)     var clock = function(){       ticks++;       if(ticks === timeformarquee){        alert("the first span isn't visible on screen");       }     };     window.setinterval(clock, 1000); 

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -