JSFiddle - React, Tailwind, and code Playground
by Arun Prakash
HTML
<body>
<div class="row question-bg">
<div class="col-xs-1">
<div class="arrow-left navigation-color" id="leftArrow">
</div>
</div>
<div class="col-xs-9">
<div class="container-fluid" id="scrollquestion" style="overflow-x:hidden;white-space: nowrap;overflow-y:hidden ;top: 500px; padding: 4px; width:auto;">
</div>
</div>
<div class="col-xs-1">
<div class="arrow-right" id="rightArrow">
</div>
</div>
</div>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="js/jquery.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="js/bootstrap.min.js"></script>
<script src="js/script.js"></script>
</body>
CSS
.c {
color: black;
background-color: #FFFFFF;
font-size: 11px;
border-radius: 50%;
width: 30px;
display: inline-block;
text-align: center;
vertical-align: middle;
border-color: blue;
/* box-shadow: 0 0 0 3px #002525; // JUST ADD THIS LINE AND MODIFY YOUR COLOR*/
padding-right: 10px;
padding-left: 3px;
margin-left: 10px;
margin-right:10px;
white-space: nowrap;
}
.container-outer { overflow-x: scroll; width: auto; height: 60px; overflow-y:hidden;}
.container-inner { width: 10000px; }
.navigation-color {
font-size: 40px;
color:#01AEBC;
text-align: center;
}
.question-bg{
background-color: #ededed;
}
.question-not-viewed{
background-color: #FFFFFF;
color: black;
}
.question-viewed{
color:#00A5B5;
box-shadow: 0 0 0 3px #00A5B5;
}
.current-question{
background-color: #01AEBC;
color:white;
}
/*.col-sm-3{display: inline-block;width:auto;}
.c {
color: #64cbcd;
font-size: 11px;
border-radius: 50%;
// height: 30px;
width: 30px;
display: inline-block;
text-align: center;
vertical-align: middle;
border-color: blue;
box-shadow: 0 0 0 3px #002525; // JUST ADD THIS LINE AND MODIFY YOUR COLOR
padding-right: 10px;
padding-left: 3px;
margin-left:10px;
margin-right:10px
}
*/
.arrow-up {
width: 0;
height: 0;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
border-bottom: 5px solid black;
}
.arrow-down {
width: 0;
height: 0;
border-left: 20px solid transparent;
border-right: 20px solid transparent;
border-top: 20px solid #f00;
}
.arrow-right {
width: 0;
height: 0;
border-top: 10px solid transparent;
border-bottom: 10px solid transparent;
border-left: 10px solid blue;
}
.arrow-left {
width: 0;
height: 0;
border-top: 10px solid transparent;
border-bottom: 10px solid transparent;
border-right:10px solid blue;
}
JavaScript
$( document ).ready(function() {
fillQuestionNumber(30);
console.log( "ready!" );
$("#leftArrow").click(function () {
var leftPos = $('#scrollquestion').scrollLeft();
$("#scrollquestion").animate({scrollLeft: leftPos - 200}, 800);
});
$("#rightArrow").click(function () {
var leftPos = $('#scrollquestion').scrollLeft();
$("#scrollquestion").animate({scrollLeft: leftPos + 200}, 800);
});
$(".c").click(function(){
$(this).addClass("question-viewed");
$(this).addClass("current-question");
$(this).siblings().removeClass("current-question");
});
$(function() {
var scrollLeftPrev=0;
$('#scrollquestion').scroll( function() {
// console.log($('#scrollquestion').width());
// console.log($('#scrollquestion').scrollLeft());
var newScrollLeft=$('#scrollquestion').scrollLeft();
if(scrollLeftPrev===newScrollLeft){
alert('right end');
}
if(newScrollLeft===0){
alert('left end');
}
console.log($('#scrollquestion').width());
console.log(newScrollLeft);
scrollLeftPrev=newScrollLeft;
// if ( $('#scrollquestion').scrollLeft() == ($('#scrollquestion').width() - $('#scrollquestion').width())) {
// alert('end2!');
// }
// if ( $('#scrollquestion').scrollLeft() == ($('#scrollquestion').width() + $('#scrollquestion').width()+200)) {
// alert('end!');
// }
});
});
});
function fillQuestionNumber(questionNum){
for(var i=1;i<=questionNum;i++){
$("#scrollquestion").append('<div class="c"><h6>'+i+'</h6></div>');
}
}