views:

2742

answers:

4

Is it possible to create a 100% seamless marquee in jQuery (or just javascript but jQuery prefered)? I've made a simple marquee that moves left until it is off the screen then simply jumps (when out of view) to the right and starts again. However I would love it to not have the wait.

The only way I could think of doing this would be to duplicate the text and put it after the first text, then swap them round again. However I have no idea how to implement this in jQuery.

Any ideas?

+5  A: 

Given the following markup:

<div id="marquee">My Text</div>

I'd do something like this:

$("#marquee").wrapInner("div"); // wrap "My Text" with a div
$("#marquee").append($("#marquee div").clone().hide()); // now there are two divs with "My Text"
// animate the divs as desired

EDIT:

See a preview with more code here.

Joel Potter
Still need code to swap once marquee has passed the visible window.
Diodeus
This is not seamless, there is a huge gap after text end and before text starts again.
Evgeny
@Evgeny, depends on your definition of seamless. This design makes the screen act like a cylinder, causing the text flowing off one side to immediately appear on the other.
Joel Potter
@Joel, seamless for me means without visible large gaps after text content end and before text content start - given that the gap is not part of the content itself (spaces, tabs, etc).
Evgeny
@Evgeny, as I said, it depends. From my reading of the question, this is the result the OP was looking for. Your version would not be hard to write I imagine. If you want, create another question and I or someone else will try it.
Joel Potter
@joel still laggy ( maybe becouse of useing css )
Adam Ramadhan
A: 

Thanks for the information

Anurag Katoch
A: 

try this http://takien.com/699/jquery-twitter-marquee.php

takien
A: 

Hi,

Can any one give example of vertical scrolling images continuesly.

-vara www.varadesigns.com

vara