Clickable Hotspots in TimeKitJS

One of the most powerful uses for TimeKitJS is the ability to embed hidden content that can be revealed when a user clicks or hovers on a particular subject in a video. Often these subjects we want to show additional information on will move as the video plays, which means our interactive areas, or "hotspots," must move with them. This tutorial will show you how to make a clickable hotspot that moves in sync with a video.

Play the demo:

To achieve this effect, first create an element the size and shape of the area you want to be clickable and stylize it with standard CSS as desired (you can even make them invisible!). Make sure to set your attributes position:absolute; and top and left to the position you want your hotspot to be in at the start of the video.

Next, determine between which points in time in the video you want your hotspot to be moving. For example, if you want your hot spot to start moving from left:50px; top:50px; at 2 seconds into the video, and end up at left: 100px; top: 100px; at 4 seconds into the video, simply add the data attributes data-tk-2s="left:50px;top:50px;" data-tk-4s="left:100px;top:100px;" to your hotspot's HTML element. This will tell TimeKitJS to start moving your hotspot at the first timestamp and transition smoothly on a straight vector until it reaches its new destination at exactly the time specified in the second timestamp. Add as many timestamps and positions as you like to create complex paths for your clickable hotspot to follow.

Demo JavaScript:
var tk = new TimeKit('#video');
var el = document.getElementById("hotspot");
el.addEventListener("click", function(){
    alert("Blub Blub");
Demo HTML:
<div class="tk-canvas">
    <video id="video" controls loop>
        <source src="goldfish.mp4" type="video/mp4">
        <source src="goldfish.webm" type="video/webm">
        Sorry, your browser doesn't support HTML5 video.
    <div id="hotspot"
Demo CSS:
.tk-canvas {
    overflow: hidden;
    position: relative;
#hotspot {
    background: #fff;
    border: 10px solid red;
    border-radius: 100%;
    box-shadow: 0px 3px 3px rgba(0,0,0,0.25);
    cursor: pointer;
    height: 10px;
    left: 710px;
    opacity: 0.75;
    position: absolute;
    top: 125px;
    width: 10px;
    z-index: 2;