html - Long text scroll in JavaScript -


i need scroll long text in 1 line (right left) javascript.

currently doing change margin-left timer.

        //change margin     $('#slidercontenttext').css('margin-left', -slideroptions.currentmargin);     slideroptions.currentmargin=slideroptions.currentmargin+slideroptions.marginspeed; 

there other way this?

the problem if change margin every 10 ms 1 there lot cpu consumption.

you should not use margin purpose (see why) ... can use relative position ...

or best solution: relative position + css transitions

js

var s = $('#slidercontenttext');  setinterval(function(){   s.toggleclass('moveleft'); },1000); 

css

#slidercontenttext {   position: relative;   transition: left 1s;   left: 0; } #slidercontenttext.moveleft {   left: 50px; } 

you should store jquery elements outside function loops avoid memory consumption


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -