JSFiddle - React, Tailwind, and code Playground
HTML
<div id="container">
<div id="wrapper">
<div id="timeline_wrapper">
<div id="stage">
<div id="timeline">
<span>Start<span>
<div id="road">
<span>End<span>
</div>
</div>
</div>
</div>
<div id="controls_wrapper">
<div id="pad">
<div id="joystick"></div>
</div>
</div>
</div>
</div>
CSS
#wrapper{
width: 900px;
height: 500px;
margin: 0 auto;
overflow: hidden;
}
#timeline_wrapper{
float: left;
width: 800px;
height: 500px;
background: lightgray;
}
#stage{
background: none repeat scroll 0 0 white;
height: 459px;
margin-left: 20px;
margin-top: 20px;
width: 760px;
}
#timeline{
border: 1px solid red;
height: 452px;
left: 182px;
margin-left: 10px;
position: relative;
top: -95px;
width: 372px;
transform: perspective(300px) rotateX(34deg);
-moz-transform: perspective(300px) rotateX(34deg);
-webkit-transform: perspective(300px) rotateX(34deg);
overflow: scroll;
}
#road{
width:100%;
height: 1500px;
background: #ccc;
}
/*controls*/
#controls_wrapper{
float: left;
width: 100px;
height: 500px;
background: #aaa;
}
#pad{
width: 50px;
height: 150px;
background: white;
margin-left:20px;
margin-top: 20px;
}
#joystick{
background: none repeat scroll 0 0 red;
border-radius: 20px 20px 20px 20px;
height: 30px;
left: 10px;
position: relative;
top: 62px;
width: 30px;
}
#joystick:hover{
cursor: pointer;
}
#console{
margin:0 auto;
width: 900px;
height:100px;
background:black;
color:green;
}
.events{
}
.icons{
background: url("icon3.png") no-repeat;
height: 121px;
width: 75px;
}
JavaScript
var animating = true;
$("#console").html( "scroll height : " + $('#timeline')[0].scrollHeight );
$("#timeline").animate({ scrollTop: $('#timeline')[0].scrollHeight}, 2000);
var animate = function(r){
$("#road").stop().animate({ scrollTop : r },2000,function(){
if( animating ){
animate(r);
}
})
}
$("#joystick").draggable({
revert: true,
containment: "parent",
create: function(){
$(this).data("startLeft",parseInt($(this).css("left")));
$(this).data("startTop",parseInt($(this).css("top")));
},
start: function() {
animating = true;
},
drag: function(event,ui){
var rel_left = ui.position.left - parseInt($(this).data("startLeft"));
var rel_top = ui.position.top - parseInt($(this).data("startTop"));
animate(rel_top)
},
stop: function(){
animating = false;
},
axis : "y"
});