I've been working on this for a while and haven't come up with a suitable solution yet.
I have some banner text that absolutely has to scroll/marquee. The example I'm using is stock data but it's other, user-defined-on-the-fly, text that will ultimately go in my final page solution.
The issue I am trying to solve is that the text is clipped and doesn't fully display all of the text before repeating.
Secondary would be to have a smooth transition before restarting. i.e. a truly "circular" loop.
It's a pretty standard HTML/CSS-based 'marquee' though.
Any ideas on the above would be appreciated.
var text = 'Symbol: BABA Open: 168.71 Latest: 166.15 Change: -2.23 Symbol: PEP Open: 115.87 Latest: 115.91 Change: 3.32 Symbol: AAPL Open: 171.47 Latest: 170.42 Change: -0.38 Symbol: AMZN Open: 1627.86 Latest: 1607.95 Change: -14.7 Symbol: FB Open: 164.7 Latest: 162.5 Change: -1.45 Symbol: NFLX Open: 359 Latest: 356.87 Change: -2.2 Symbol: USO Open: 11.61 Latest: 11.71 Change: 0.23 Symbol: NKE Open: 85.56 Latest: 85.38 Change: 0.7 Symbol: YUM Open: 94.69 Latest: 94.12 Change: 0.27 Symbol: LEE Open: 2.64 Latest: 2.61 Change: -0.02';
//text is cutoff at width of parent container
$("#marquee-text").text(text);
.scroller {
height: 20px;
overflow: hidden;
position: relative;
}
.scroller p,
.scroller span {
/*font-size: 3em;*/
white-space: nowrap;
color: black;
position: absolute;
width: 100%;
/*height: 100%;*/
margin: 0;
/*line-height: 50px;*/
/*text-align: center;*/
/* Starting position */
-moz-transform: translateX(100%);
-webkit-transform: translateX(100%);
transform: translateX(100%);
/* Apply animation to this element */
-moz-animation: example1 15s linear infinite;
-webkit-animation: example1 15s linear infinite;
animation: example1 15s linear infinite;
}
/* Move it (define the animation) */
@-moz-keyframes example1 {
0% {
-moz-transform: translateX(100%);
}
100% {
-moz-transform: translateX(-100%);
}
}
@-webkit-keyframes example1 {
0% {
-webkit-transform: translateX(100%);
}
100% {
-webkit-transform: translateX(-100%);
}
}
@keyframes example1 {
0% {
-moz-transform: translateX(100%);
/* Firefox bug fix */
-webkit-transform: translateX(100%);
/* Firefox bug fix */
transform: translateX(100%);
}
100% {
-moz-transform: translateX(-100%);
/* Firefox bug fix */
-webkit-transform: translateX(-100%);
/* Firefox bug fix */
transform: translateX(-100%);
}
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="marquee-div" class="scroller">
<span id="marquee-text"></span>
</div>