Code Monkey home page Code Monkey logo

editor-timeline's Introduction

editor-timeline

timeline for multimedia editors

example

var keycode = require('keycode');
var timeline = require('editor-timeline')(200);
timeline.appendTo('#timeline');

window.addEventListener('keydown', function (ev) {
    var chr = keycode(ev);
    if (chr === 'k') {
        var m = timeline.mark();
        timeline.select(m.id);
    };
    if (chr === 'delete') timeline.removeMark('_active');
    if (chr === 'home') timeline.setTime(0);
    if (chr === 'space') timeline.toggle();
    if (chr === 'left') {
        ev.stopPropagation();
        ev.preventDefault();
        timeline.select('prev');
    }
    if (chr === 'right') {
        ev.stopPropagation();
        ev.preventDefault();
        timeline.select('next');
    }
});

var play = document.querySelector('#play');
timeline.on('start', function () {
    play.textContent = '||';
});
timeline.on('stop', function () {
    play.textContent = '>';
});

with some html:

<html>
  <style>
    #timeline { height: 50px; }
  </style>
  <body>
    <button id="play">&gt;</button>
    <div id="timeline"></div>
    <script src="bundle.js"></script>
  </body>
</html>

bundle with browserify:

browserify timeline.js > bundle.js

methods

var timeline = require('editor-timeline')

var t = timeline(pxps)

Create a new timeline t given pxps, the number of pixels per second.

t.appendTo(target)

Append the timeline element to the html element or query string target.

var m = t.mark()

Create a new mark m.

t.select(id)

Select the mark at id.

t.removeMark(id)

Remove the mark at id.

t.start()

Start playing.

t.stop()

Stop playing.

t.toggle()

Start playing if not playing, otherwise stop playing.

t.setTime(n)

Set the current time n in seconds.

t.getTime()

Get the current time in seconds.

events

t.on('mark', function (m, elem) {})

When there is a new mark, this event fires.

t.on('show', function (m, index) {})

When the mark is activated, this event fires.

t.on('remove', function (m, index) {})

When a mark is removed, this event fires.

install

With npm do:

npm install editor-timeline

license

MIT

editor-timeline's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.