• Stars
    star
    751
  • Rank 60,419 (Top 2 %)
  • Language
    JavaScript
  • Created over 12 years ago
  • Updated almost 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Small JavaScript library for sprite based animations and panning.

Motio

Small JavaScript library for simple but powerful sprite based animations and panning.

Motio takes an element and animates its background position to create an animation effect. All is super optimized for speed and chained to the requestAnimationFrame, with a polyfill for older browsers without it.

That being said, animating the element background is not the fastest possible way how to do this (canvas solutions are a lot faster), but it is sure as hell the most simple one, and compatible with everything from IE6 and up.

Dependencies

Motio has no dependencies, but there is an optional Motio jQuery plugin extension available.

Compatibility

Works everywhere.

Usage

Sprite animation mode:

var element = document.querySelector('#sprite');
var sprite = new Motio(element, {
	fps: 10,
	frames: 14
});
sprite.play();   // start animation
sprite.pause();  // pause animation
sprite.toggle(); // toggle play/pause
sprite.toStart(); // animate to 1st frame and stop
sprite.toEnd();   // animate to last frame and stop
sprite.to(10);    // animate to 11th frame and stop

Seamless background panning mode:

var element = document.querySelector('#panning');
var panning = new Motio(element, {
	fps: 30, // Frames per second. More fps = higher CPU load.
	speedX: -30 // Negative horizontal speed = panning to left.
});
panning.play();    // start animation
panning.pause();   // pause animation
panning.toggle();  // toggle play/pause

Download

Latest stable release:

jQuery plugin version:

When isolating issues on jsfiddle, you can use this URL:

Documentation

Can be found in the docs directory.

Contributing

Please, read the Contributing Guidelines for this project.

More Repositories

1

sly

JavaScript library for one-directional scrolling with item based navigation support.
JavaScript
2,870
star
2

fpsmeter

Sexy, fast, and themable FPS meter.
JavaScript
578
star
3

uosc

Minimalist cursor proximity based UI for MPV player.
Lua
226
star
4

tooltip

JavaScript Tooltip component.
JavaScript
190
star
5

laravel-console

In-browser console for Laravel PHP framework.
CSS
170
star
6

espy

jQuery plugin for on-scroll detecting whether the element entered or left the viewport.
JavaScript
111
star
7

imagesloaded

A small helper that triggers a callback after all the selected/child images have been loaded.
JavaScript
100
star
8

tooltips

Tooltips for DOM elements.
JavaScript
40
star
9

loremImages

jQuery plugin for populating elements with random images
JavaScript
38
star
10

grunt-bumpup

Update the version, date, and other properties in JSON files while preserving indentation style.
JavaScript
35
star
11

grunt-gcc

Grunt task for minifying JavaScript files with Google Closure Compiler.
JavaScript
18
star
12

grunt-tagrelease

Commit the changes and tag the last commit with a version from provided JSON file.
JavaScript
17
star
13

volley

jQuery plugin for dividing and filtering elements based on their visual position.
JavaScript
16
star
14

remove-trailing-separator

Removes all separators from the end of a string.
JavaScript
11
star
15

e

Simple element creation / templating with SVG support.
JavaScript
9
star
16

utilus

Utilities fof Stylus.
CSS
9
star
17

position

Component that returns element's position box object relative to documentElement.
JavaScript
9
star
18

fs-extended

Node.js module that extends the native `fs` with convenient methods.
JavaScript
5
star
19

raft

requestAnimationFrame Throttle - throttle a function to be executed at most once per animation frame.
JavaScript
5
star
20

grunt-checkrepo

Grunt task to check the state of repository.
JavaScript
4
star
21

definer

Easier and less verbose wrapper for Object.defineProperties.
JavaScript
3
star
22

node-gcc

Node wrapper for Google Closure Compiler.
JavaScript
3
star
23

event

Event binding component with support for legacy browsers.
JavaScript
2
star
24

constructor-apply

Apply an arguments array to object constructor.
JavaScript
1
star
25

lab

Collection of my web experiments.
JavaScript
1
star
26

darsain.github.com

Personal website.
CSS
1
star
27

isarraylike

Check if value is an array-like object.
JavaScript
1
star
28

iswindow

Checks whether value is a window object.
JavaScript
1
star