The motion graphics toolbelt for the web

Overview

mo · js – npm ci Coverage Status Slack

The motion graphics toolbelt for the web.

mo · js

Intro

mo · js is a javascript motion graphics library that is a fast, retina ready, modular and open source. In comparison to other libraries, it has a different syntax and code animation structure approach. The declarative API provides you a complete control over the animation, making it customizable with ease.

The library provides built-in components to start animating from scratch like html, shape, swirl, burst and stagger, but also bring you tools to help craft your animation in a most natural way. Using mojs on your site will enhance the user experience, enrich your content visually and create delightful animations precisely.

Install

Use with a bundler

Mojs is published on the NPM registry and GPR registry, so you can install it through the command line interpreter using your favorite package manager. This is the best way to install the library if you are comfortable with javascript bundlers like webpack or rollup.

# npm
npm install @mojs/core

# yarn
yarn add @mojs/core

Then import it like any other module inside your build:

import mojs from '@mojs/core';

new mojs.Html({
  // ...
});

Using a bundler has many advantages like output compression, code splitting, tree shaking, etc., so we encourage you to use this kind of tool with mojs.

Use with a CDN

To rapidly include the minified production file in your webpage, load the latest build from your favorite CDN using a generic script markup:

<!-- unpkg -->
<script src="https://unpkg.com/@mojs/core"></script>

<!-- jsdelivr -->
<script src="https://cdn.jsdelivr.net/npm/@mojs/core"></script>

Then instanciate using:

<script>
  new mojs.Html({
    // ...
  });
</script>

By default, if no one is specified, the CDN will automatically target the @latest version of mojs and load the UMD build from dist/mo.umd.js.

User guide

The base documentation you need to get started with mojs.

Learn

Discover the amazing things that mojs can do!

Developer

Get technical informations, open an issue/pull request or join the (amazing) community!

Showcase

Browser support

  • Chrome 49+
  • Firefox 70+
  • Opera 36+
  • Safari 8+
  • Edge 79+

Many other browsers may work, but are not extensively tested.

Maintainers

Since 2019, mojs ecosystem is maintained and developed by:

Kudos

Meet some of the outstanding guys that support mojs on Patreon:

Comments
  • problem with position loading trough ajax

    problem with position loading trough ajax

    Hi, first of all thanks for mo.js. It´s truly amazing :)

    I was trying to implement mo.js on a button with the same code here http://tympanus.net/codrops/2016/02/23/icon-animations-powered-by-mo-js/

    I´ve manage to do that, but found a problem, related with my interface, that I´m going to try to explain since I can´t create a fiddle. My interface has 2 panels, pretty much like an email client. On the left you have a list of thing and when you press one, the panel in the right is loaded trough ajax, without reloading the page.

    What I found out it that when I press a button in the interface loades through ajax, the animation is misplaced, when it should be around the icon. It is a lot of pixels up and left. I´ve checked with firebug and indeed mojs is placing there a div like this:

    <div class="" data-name="mojs-shape" style="position: absolute; width: 115px; height: 115px; margin-left: -57.5px; margin-top: -57.5px; opacity: 0.6; left: 50%; top: 50%; transform: translate(50%, 50%) rotate(0deg) scale(1, 1); transform-origin: 50% 50% 0px;">

    What I think is happening is since the position is absolute, the margin, left and top are being calculated as if the right panel was a whole page, misplacing the animation, since I still have a left panel...

    Is there a way to fix the position, maybe calculating the coordinates after the page is rendered ?

    I hope my explanation was clear :) Thanks

    opened by jcorreia 25
  • Use with Webpack

    Use with Webpack

    I am trying to setup mo.js in my webpack configuration.

    installing it via npm install mo-js --save and then importing it via import mojs from 'mo-js' doesn't work.

    Any tips how to set it up? Is the lib actually Es6 module compatible?

    opened by roundrobin 19
  • Tutorials are not clickable

    Tutorials are not clickable

    In the Tutorials sidebar of mojs.io I can only click Path Easing, all others are unclickable. This is true on Chrome for Mac and Linux as well as Edge on Windows. screenshot from 2015-11-23 08 38 13

    documentation 
    opened by samtstern 19
  • Trying to use with jquery

    Trying to use with jquery

    I'm using Ember.js which is built on jQuery. I have what are called components which are basically just templates that represent a small piece of UI that gets rendered in multiple places. Each of these components that renders gets a unique ID and in the code backing the component I have access to the individual components element via jQuery. However I've found trying to pass that to mojs seems to get me this error

    Uncaught TypeError: (this.o.parent || document.body).appendChild is not a function
    

    I've tried to dereference to javascript using .get(0) but the problem is now that I get the animations only attaching to the first occurrence of my element I'm matching on.

    My particular implementation of this library is using a small library created here

    Which was using document.querySelector but I need to be a little more specific so I can attach these icon animations to each component so I can animate them individually.

    opened by jrdn91 16
  • Can't using

    Can't using "Mo-js" in framework7 :confused:

    Thank @eltonmesquita Edit: to fix it you need add z-index: 0 to the app container style; ex: * { z-index: 0 }

    Problem: I can't using http://mojs.io/ in framework7 :disappointed: I dont know why? :confused: Pleace help me. :face_with_head_bandage:

    Anybody using mo.js with framework7?

    bug 
    opened by cuduy197 14
  • Using an image inside a shape

    Using an image inside a shape

    Hi

    Is it possible to use an image inside a shape? I want to create a circle with that has an image.

    Created the following example with html5 canvas, but then came across mojs and would like to give it a shot but I need to have the possibility to use an image inside a circle shape.

    Thanks

    opened by RobbertWolfs 13
  • Strict mode from outside breaks script

    Strict mode from outside breaks script

    In our gulp task setup, we take vendor JS files, concat & minify them.

    Other packages might include 'use strict'; on the top level, causing strict mode to propagate downward into functions.

    In build/mo.js:7219, we have this:

    BezierEasing.prototype.generate = function(mX1, mY1, mX2,  mY2) {
      // ...
      float32ArraySupported = indexOf.call(global, 'Float32Array') >= 0;
    

    Which raises an exception when in the web page:

    Uncaught TypeError: Array.prototype.indexOf called on null or undefined
        at indexOf (<anonymous>)
        at t.generate (vendor-f37e19184d.js:24316)
        at Function.i (vendor-f37e19184d.js:24315)
        at vendor-f37e19184d.js:24315
        at Object.e.__esModule (vendor-f37e19184d.js:24315)
        at e (vendor-f37e19184d.js:24312)
        at Object.t.__esModule.default (vendor-f37e19184d.js:24312)
        at e (vendor-f37e19184d.js:24312)
        at Object.t.__esModule.default (vendor-f37e19184d.js:24313)
        at e (vendor-f37e19184d.js:24312)
    

    Adding a null check before it fixes this bug:

      float32ArraySupported = global != null && indexOf.call(global, 'Float32Array') >= 0;
    

    However, I'm not sure if falling to false would be the best option here, as I'm not sure what this line means in the longer run.

    Thought this should be checked out. In my case I removed any/all strict definitions from the result.

    bug core 
    opened by chenasraf 12
  • Any way for translate SVG elemements - on IE ?

    Any way for translate SVG elemements - on IE ?

    SVG inline elements, cam be tranlated ... Works fine in: Chrome, Firefox and Safari ...

    IE - not transform SVG elements.

    Exemple: http://codepen.io/Oguima/pen/XmvVqQ

    opened by Oguima 12
  • Burst animation happens twice on ios

    Burst animation happens twice on ios

    I am struggling with an issue with Burst. On every desktop browser, and android phones, the burst is played normally. However, on ios something strange happens: The animation is ran twice, and the total duration is the duration I sat as a property on children. So, on android there is one burst with a duration of five seconds and on ios the is two bursts with a total duration of five seconds.

    The code for the mojs.Burst

    const mojs = require('mo-js');
            this.burst = new mojs.Burst({
                parent: '#label-' + this.props.id,
                radius: 40,
                degree: 300,
                angle: 120,
                count: 11,
                children: {
                    shape: 'line',
                    radius: 6,
                    scale: 1,
                    stroke: this.props.color,
                    strokeDasharray: '100%',
                    strokeDashoffset: { '-100%': '100%' },
                    duration: 5000,
                    easing: 'quad.out',
                }
    

    The triggering:

    this.burst.replay();
    
    opened by olemartin 11
  • documentation update

    documentation update

    Hey guys... I'm just wondering if you have any plan to keep on this project? I don't see the documentation being updated and the last commit was almost a year ago.

    So... What are the plans?

    documentation 
    opened by javierojeda94 10
  • Loading library gives `Uncaught TypeError: Cannot read property 'appendChild' of null`

    Loading library gives `Uncaught TypeError: Cannot read property 'appendChild' of null`

    When loading mo.js I get this error:

    Uncaught TypeError: Cannot read property 'appendChild' of null
    

    on this line:

      Helpers.prototype.vars = function() {
        var ua;
        this.prefix = this.getPrefix();
        ...
        this.div = document.createElement('div');
        return document.body.appendChild(this.div);   <<<<<<< error here.
      };
    
    What is the correct way to require/initalize this library?
    
    I'm just trying to include it into a plain vanilla HTML page.
    
    bug 
    opened by suranyami 10
  • Independent delta not working in .then

    Independent delta not working in .then

    It seems like independent deltas don't work in .then() functions.

    I am trying to create a jump animation using this code:

    const circle = new mojs.Shape({
      top: 40,
      left: 40,
      y: {
        0: 100,
        easing: "cubic.out"
      },
      x: {
        0: 20,
        easing: "linear.none"
      },
      radius: 40,
      duration: 250,
    }).then({
      y: {
        100: 0,
        easing: "cubic.in"
      },
      x: {
        20: 40,
      }
    });
    

    When adding any of the independent delta properties specified in https://mojs.github.io/api/modules/html/#independent-deltas, the .then() is ignored altogether.

    Am I using it improperly or is there any fix for this?

    bug 
    opened by strukteon 4
  • Improve the way custom shapes are instantiated

    Improve the way custom shapes are instantiated

    Currently the only way to use custom graphics is to customize a graphics class and inherit the mojs.CustomShape class, and then add it to mojs using the mojs.addShape() method. Then you can set and use custom graphics in the shape attribute.

    One disadvantage of this method is that the added custom graphics class is global, and sometimes the added custom graphics will only be used in a certain module. My feeling is'this pollutes the global attributes'. For example, I want to use custom graphics menu and close in the Menu component. But in other components, I don't want to use the two custom graphics menu and close.

    So one way I recommend is to support the use of the class type attribute value for the shape attribute. e.g. new mojs.Shape({ shape: MyCustomShapeClass })

    Of course, my thinking is not complete, because I don't know much about the source code of mojs, and there is a better way that would be better. Hope Add support for modular use of custom graphics

    feature 
    opened by ghost 4
  • then() method is firing error

    then() method is firing error "TypeError: Cannot read property '4' of null"

    Rect environment, this is a piece of my code. I cant make then to work. What am I doing wrong?

            progressAnimation.current = new mojs.Html({
                el: progressRef.current,
                width: {
                    [progressRef.current.style.width || 0]: position * 100 + '%'
                },
                duration: 1000
            }).then({
                scale: {
                    '1': '1.3'
                },
                opacity: {
                    '1': '0'
                },
                duration: 1000
            }).play();
    
    bug 
    opened by Mertas 9
  • Add time unit global setting

    Add time unit global setting

    Allow the user to easily choose between seconds and milliseconds when working with mojs duration/shift properties. Instead of using duration: 1000 (ms by default), the user could be able to use duration: 1 (seconds).

    This is the common usage in most animation frameworks.

    feature 
    opened by xavierfoucrier 0
  • Wierd behaviour on Burst count using rand function

    Wierd behaviour on Burst count using rand function

    When setting the burst count using the rand() function, the burst behaves wierdly, or random, too random. Sometimes the children are not spread out evenly, sometimes it's like the last childs is still playing. Compare this to when you set either count to, 2, 3, 4, 5 or 6 directly compared to 'rand(2, 6)'.

    Example:

    const example = new mojs.Burst({
      parent: '#example',
      x: 'rand(-50, 50)',
      y: 'rand(-50, 50)',
      count: 'rand(2, 6)'
    });
    
    document.addEventListener( 'click', function (e) {
      example.generate().replay();
    });
    

    Bug reproduction pen: https://codepen.io/sandstedt/pen/Vwjdroy

    bug 
    opened by Sandstedt 1
  • Correct way to use mojs with promise/async?

    Correct way to use mojs with promise/async?

    I want to play an animation and wait until it finishes. I checked the docs and tutorials and I did not find an API that returns a promise or something.

    It seems there's no related discussion here so I would like it to ask if there's a standard way of doing this?

    What I am doing now is wrapping it in a promise and it works fine:

    const burstPromise = new Promise(resolve => {
        const burst = new mojs.Burst({
            radius: {30: 120},
            count: 10,
            children: {
                duration: 3000,
            },
            onComplete() {
                resolve();
            }
        });
        burst.play();
    });
    
    await burstPromise;
    
    feature 
    opened by uduse 4
Releases(v1.4.0)
  • v1.4.0(Dec 19, 2022)

  • v1.3.0(Jan 19, 2022)

  • v1.2.1(Sep 28, 2021)

  • v1.2.0(Sep 28, 2021)

  • v1.1.0(May 9, 2021)

  • v1.0.3(Apr 2, 2021)

  • v1.0.2(Mar 26, 2021)

    • Fix window.mojs reference: prevent @mojs/player and @mojs/curve-editor from crashing
    • Refactor webpack UMD build by dropping future deprecated properties
    Source code(tar.gz)
    Source code(zip)
  • v1.0.1(Mar 25, 2021)

  • v1.0.0(Mar 25, 2021)

    Official release :tada:

    Breaking changes

    • The angle property is now called rotate to keep it consistent with CSS standards
    • Support for Internet Explorer has been dropped

    New features and improvements

    • Smaller production bundle
    • All dependencies are up to date (except for coffee script)
    • Modern build environment using webpack and webpack-dev-server
    • Browser testing through Browserstack
    • Continuous Integration workflow hosted on Github Actions

    What is planned for the future

    • Fix as more issues as possible and close old ones
    • Build a monorepo to host all packages at the same place
    • Use typescript instead (this part imply a lot of work)
    • Use microbundle to build library and target ESM/modern bundle
    • Use jest for code testing
    • ... and a lot more!

    Feedback

    Feel free to report any issue or feature request. Thanks a lot for using mojs inside your projects!

    The @mojs ecosystem is maintained and developed by @xavierfoucrier and @Sandstedt on their own spare time.

    Source code(tar.gz)
    Source code(zip)
  • 0.288.2(Aug 30, 2017)

  • 0.288.1(Oct 6, 2016)

    • add Html module for DOM animations
    • add stagger wrapper
    • stagger now implements tweenable interface and supports then, tune and generate methods
    • add resume public method for tween and tweenables
    • animations now pause and resume on page visibilityChange
    • fix then chains issue
    • performance improvements
    Source code(tar.gz)
    Source code(zip)
  • 0.265.9(Aug 11, 2016)

  • 0.265.8(Aug 10, 2016)

  • 0.265.6(Jul 14, 2016)

    Completely rewritten tweening engine - now faster, much more robust with exhaustive API. Rewritten Shape, ShapeSwirl and Burst modules.

    Breaking changes (please see API section for more info):

    • Tweens and Other Modules now have play instead of start/run
    • yoyo property renamed to isYoyo
    • All callbacks now work in certain point of time - like timeline. So can fire on both forward and backward directions
    • Burst: childOptions property now named children
    Source code(tar.gz)
    Source code(zip)
  • 0.174.4(Nov 19, 2015)

  • 0.147.3(Oct 20, 2015)

    • [97448cf, 9f90134] Fixes npm lost folders issue and adds missed files
    • [d78d78a] Fixes tween's rewind issue
    • [43f093a] Changes path-easing defaults: precompute = 1450, eps = 0.001
    • [321875e] Adds "none" color name - equivalent to transparent
    • [2b01604] Adds readable parse easing name error
    • [bca8a82] Adds [object HTMLCollection] to allowed stagger props
    • [38ff3f4] h.style now adds prefixes only for transform property
    • [0bbac4d] Fixes tests precision issue
    Source code(tar.gz)
    Source code(zip)
  • 0.146.9(Sep 2, 2015)

  • 0.119.0(May 13, 2015)

  • 0.117.5(May 7, 2015)

  • 0.117.0(May 4, 2015)

  • 0.114.4(Apr 29, 2015)

    • add bezier easing
    • add motion arc
    • add motion blur on motion path
    • add "ease" easing functions
    • start work on docs auto gen with grock
    • backward compatibility break - renamed easing functions to shortcuts:
      • quadratic -> quad
      • quartic -> quart
      • quintic -> quint
      • sinusoidal -> sin
      • exponential -> expo
      • circular -> circ
    Source code(tar.gz)
    Source code(zip)
  • 0.110.1(Apr 4, 2015)

Owner
mo · js
The motion graphics toolbelt for the web
mo · js
Javascript and SVG odometer effect library with motion blur

SVG library for transitioning numbers with motion blur JavaScript odometer or slot machine effect library for smoothly transitioning numbers with moti

Mike Skowronek 793 Dec 27, 2022
Quick and easy spring animation. Works with other animation libraries (gsap, animejs, framer motion, motion one, @okikio/animate, etc...) or the Web Animation API (WAAPI).

spring-easing NPM | Github | Docs | Licence Quick and easy spring animations. Works with other animation libraries (gsap, animejs, @okikio/animate, mo

Okiki Ojo 34 Dec 14, 2022
Theatre.js is an animation library for high-fidelity motion graphics.

Theatre.js is an animation library for high-fidelity motion graphics. It is designed to help you express detailed animation, enabling you to create intricate movement, and convey nuance.

Aria 8.6k Jan 3, 2023
⚡️The Fullstack React Framework — built on Next.js

The Fullstack React Framework "Zero-API" Data Layer — Built on Next.js — Inspired by Ruby on Rails Read the Documentation “Zero-API” data layer lets y

⚡️Blitz 12.5k Jan 4, 2023
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
The JavaScript library for modern SVG graphics.

Snap.svg · A JavaScript SVG library for the modern web. Learn more at snapsvg.io. Follow us on Twitter. Install Bower - bower install snap.svg npm - n

Adobe Web Platform 13.6k Dec 30, 2022
The Swiss Army Knife of Vector Graphics Scripting – Scriptographer ported to JavaScript and the browser, using HTML5 Canvas. Created by @lehni & @puckey

Paper.js - The Swiss Army Knife of Vector Graphics Scripting If you want to work with Paper.js, simply download the latest "stable" version from http:

Paper.js 13.5k Dec 30, 2022
A library optimized for concise and principled data graphics and layouts.

MetricsGraphics is a library built for visualizing and laying out time-series data. At around 15kB (gzipped), it provides a simple way to produce comm

Metrics Graphics 7.5k Dec 22, 2022
A lightweight JavaScript graphics library with the intuitive API, based on SVG/VML technology.

GraphicsJS GraphicsJS is a lightweight JavaScript graphics library with the intuitive API, based on SVG/VML technology. Overview Quick Start Articles

AnyChart 973 Jan 3, 2023
Create graphics with a hand-drawn, sketchy, appearance

Rough.js Rough.js is a small (<9 kB) graphics library that lets you draw in a sketchy, hand-drawn-like, style. The library defines primitives to draw

Rough 17.8k Dec 30, 2022
A cross platform high-performance graphics system.

spritejs.org Spritejs is a cross platform high-performance graphics system, which can render graphics on web, node, desktop applications and mini-prog

null 5.1k Dec 24, 2022
React + Canvas = Love. JavaScript library for drawing complex canvas graphics using React.

React Konva React Konva is a JavaScript library for drawing complex canvas graphics using React. It provides declarative and reactive bindings to the

konva 4.9k Jan 9, 2023
A library optimized for concise and principled data graphics and layouts.

MetricsGraphics is a library built for visualizing and laying out time-series data. At around 15kB (gzipped), it provides a simple way to produce comm

Metrics Graphics 7.5k Dec 22, 2022
A lightweight JavaScript graphics library with the intuitive API, based on SVG/VML technology.

GraphicsJS GraphicsJS is a lightweight JavaScript graphics library with the intuitive API, based on SVG/VML technology. Overview Quick Start Articles

AnyChart 937 Feb 5, 2021
Using Storybook for Pixi.js graphics development

Storybook for Pixi.js Using Storybook for Pixi.js graphics development This project includes: Storybook Pixi.js Pixi Viiewport Background Often conven

Jason Sturges 5 Mar 9, 2022
An indexed compendium of graphics programming papers, articles, blog posts, presentations, and more

Paper Bug CONTRIBUTIONS WANTED What is this? The idea is to have an annotated and easily searchable repository of papers, presentations, articles, etc

Jeremy Ong 64 Dec 16, 2022
Dokka plugin to render Mermaid graphics, from your code comments to your Dokka documentation.

Html Mermaid Dokka plugin Mermaid-Dokka MermaidJS 0.2.2 8.14.0 0.3.0 9.0.0 Step 1: install dependencies { dokkaPlugin("com.glureau:html-mermaid-dokk

Grégory Lureau 23 Sep 16, 2022