Reputation: 91
I'm trying to build a blog using HTML and CSS. Now I've integrated API's for certain stocks using PHP and using the data I've created multiple widgets.
Now I'm trying to create a marquee similar to stock markets (endless and infinite without any gaps). I found a few examples on the but failed to understand its implementation.
Can anyone tell how the marquee like feature works in either of these websites
$('document').ready(function(){
refreshData();
})
function refreshData() {
$('#container-table').load("data.php", function(){
setTimeout(refreshData, 10000);
});
$('#container-tablel').load("datanike.php", function(){
setTimeout(refreshData, 10000);
});
$('#container-tabled').load("datamsft.php", function(){
setTimeout(refreshData, 10000);
});
$('#container-tablee').load("dataaapple.php", function(){
setTimeout(refreshData, 10000);
});
$('#container-tablex').load("dataamzn.php", function(){
setTimeout(refreshData, 10000);
});
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="container1">
<div id="container-table"></div>
<div id="container-tablel"></div>
<div id="container-tabled"></div>
<div id="container-tablee"></div>
<div id="container-tablex"></div>
</div>
I would like to implement these like the one in GDAX. But any other implementation will also be greatly appreciated.
Thanks in advance.
Upvotes: 2
Views: 662
Reputation: 228
Try this
This is continuous marquee
// polyfill
window.requestAnimationFrame = (function(){
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
function( callback ){
window.setTimeout(callback, 1000 / 60);
};
})();
var speed = 5000;
(function currencySlide(){
var currencyPairWidth = $('.slideItem:first-child').outerWidth();
$(".slideContainer").animate({marginLeft:-currencyPairWidth},speed, 'linear', function(){
$(this).css({marginLeft:0}).find("li:last").after($(this).find("li:first"));
});
requestAnimationFrame(currencySlide);
})();
.slider{
width:100%;
overflow:hidden;
position:relative;
margin:0;
}
.edge{
left:0;
right:0;
top:0;
bottom:0;
position:absolute;
height:100%;
display:block;
}
.edge:before{
content:'';
position:absolute;
left:0;
background:-webkit-linear-gradient(left, white 10%, rgba(0,0,0,0) 100%);
width:25%;
height:100%;
}
.edge:after{
content:'';
position:absolute;
right:0;
background:-webkit-linear-gradient(right, white 10%, rgba(0,0,0,0) 100%);
width:25%;
height:100%;
}
ul{
background:#ddd;
overflow:hidden;
width:1000%;
margin:0;
}
li{
list-style:none;
display:inline-block;
padding:0 50px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class='slider'>
<div class="edge"></div>
<ul class="slideContainer" id="money_start">
<li class="slideItem" >
EUR
</li>
<li class="slideItem">
USD
</li>
<li class="slideItem">
JPY
</li>
<li class="slideItem">
CNY
</li>
<li class="slideItem">
VD
</li>
<li class="slideItem">
GBP
</li>
<li class="slideItem">
AUD
</li>
<li class="slideItem">
CAD
</li>
<li class="slideItem">
CHF
</li>
<li class="slideItem">
XAU
</li>
</ul>
</div>
Upvotes: 2
Reputation: 2660
You can use simple html <marquee> tag for infinite moving.
See example:
#container-table, #container-tablel, #container-tabled, #container-tablee, #container-tablex {
float: left;
padding: 0 20px 0 0;
}
<div class="container1">
<marquee>
<div id="container-table">test</div>
<div id="container-tablel">test1</div>
<div id="container-tabled">test2</div>
<div id="container-tablee">test3</div>
<div id="container-tablex">test4</div>
</marquee>
</div>
Upvotes: 2
Reputation: 2119
The NSE site is using custom-stock-ticker (A Word Press Plugin). A good place to start there is looking at stock_ticker_script.js
.
Upvotes: 0