Fork me on GitHub

TimeĀ­Line.js

multitouch timelines for javascript

Touch Controls

Mouse Controls

API Basics

include timeline.js

<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.1.1.min.js"></script>
<script src="http://www.russellmcc.com/timelinejs/timeline.min.js"></script>

create a div with a height

<div id="timeline" style="height:200px;"></div>

initialize the timeline

$("#timeline").timeline();

it looks like this:

InitialĀ­ization Options

pass in an object to the initialization to set the options

$("#timeline").timeline({
   fgColor: 'chartreuse',
   ptColor: 'violet',
   dragColor: 'aqua',
   ptRadius: 30,
   points: [[.25, .5], [.5,.75], [.75,.5]]
});

available options

Resizing

resize like this:

$("#timeline").timeline({points:[[.5,.5]]});       
$("#timeline").timeline('resize', 200, 200)

Setting points

just get the timeline object and call setPoints. Don't do this during a drag.

$("#timeline").timeline({points:[[.5,.5]]});       
$("#timeline").timeline().setPoints([[.25,.25], [.75,.75]])

Getting points

$("#timeline").timeline({points:[[.5,.5]]});
var updatePoints = function(){
    var points = $("#timeline").timeline().getPoints();
    var str = "<dl>";
    for(var i = 0; i < points.length; ++i) {
        str += "<dt>" + points[i][0].toFixed(2) + "</dt>";
        str += "<dd>" + points[i][1].toFixed(2) + "</dd>";
    }
    str += "<dl>";
    $("#points").html(str);
}
$("#timeline").bind('change', updatePoints);
updatePoints();