Convert Figma logo to code with AI

mojs logomojs

The motion graphics toolbelt for the web

18,496
894
18,496
37

Top Related Projects

15,508

A JavaScript Typing Animation Library

49,575

JavaScript animation engine

19,483

GSAP (GreenSock Animation Platform), a JavaScript animation library for the modern web

15,183

JavaScript library to make drawing animation on SVG

Render After Effects animations natively on Web, Android and iOS, and React Native. http://airbnb.io/lottie/

16,455

Parallax Engine that reacts to the orientation of a smart device

Quick Overview

mo.js is a JavaScript animation library that helps create smooth and engaging web animations. It offers a declarative API for creating complex animations with minimal code, and provides a wide range of customizable shapes and effects.

Pros

  • Powerful and flexible animation capabilities
  • Lightweight and performant
  • Supports both SVG and HTML elements
  • Extensive documentation and examples

Cons

  • Learning curve for complex animations
  • Limited browser support for older versions
  • Fewer community resources compared to some other animation libraries
  • Some advanced features require additional plugins

Code Examples

Creating a simple burst animation:

const burst = new mojs.Burst({
  radius:   { 0: 100 },
  count:    5,
  children: {
    shape:      'circle',
    radius:     20,
    fill:       ['red', 'blue', 'green', 'yellow', 'purple'],
    duration:   2000
  }
});

burst.play();

Animating an HTML element:

const element = document.querySelector('.my-element');
const tween = new mojs.Tween({
  duration: 1000,
  onUpdate: (progress) => {
    element.style.transform = `scale(${1 + progress})`;
  }
});

tween.play();

Creating a custom shape:

class Star extends mojs.CustomShape {
  getShape() {
    return '<path d="M5.51132201,34.7776271 L33.703781,32.8220808 L44.4592855,6.74813038 L23.9337716,23.379622 L5.51132201,34.7776271 Z" />';
  }
}
mojs.addShape('star', Star);

const star = new mojs.Shape({
  shape:    'star',
  fill:     'yellow',
  scale:    { 0: 1 },
  duration: 1000
});

star.play();

Getting Started

To get started with mo.js, follow these steps:

  1. Install mo.js via npm:

    npm install @mojs/core
    
  2. Import mo.js in your JavaScript file:

    import mojs from '@mojs/core';
    
  3. Create a simple animation:

    const circle = new mojs.Shape({
      shape:    'circle',
      scale:    { 0: 1 },
      duration: 1000,
      easing:   'elastic.out'
    });
    
    circle.play();
    

For more advanced usage and documentation, visit the official mo.js website: https://mojs.github.io/

Competitor Comparisons

15,508

A JavaScript Typing Animation Library

Pros of Typed.js

  • Lightweight and focused on typing animations
  • Easy to set up and use with minimal configuration
  • Supports custom CSS classes for styling typed text

Cons of Typed.js

  • Limited to typing animations only
  • Less flexible for complex motion graphics
  • Smaller community and fewer updates compared to mo.js

Code Comparison

Typed.js:

var typed = new Typed('#element', {
  strings: ['First sentence.', 'Second sentence.'],
  typeSpeed: 30
});

mo.js:

const burst = new mojs.Burst({
  radius:   { 0: 100 },
  count:    5,
  children: {
    shape:      'circle',
    fill:       { 'cyan' : 'yellow' },
    duration:   2000
  }
});

Summary

Typed.js is a specialized library for creating typing animations, making it ideal for projects that require this specific effect. It's easy to use and lightweight but limited in scope. mo.js, on the other hand, is a more comprehensive motion graphics library that offers a wide range of animation possibilities beyond typing effects. While mo.js provides greater flexibility and power for complex animations, it may have a steeper learning curve and be overkill for simple typing animations.

49,575

JavaScript animation engine

Pros of Anime

  • Lighter weight and faster performance
  • Simpler API with a more intuitive learning curve
  • Better browser compatibility, including IE10+

Cons of Anime

  • Less powerful for complex animations and shape morphing
  • Fewer built-in easing functions compared to Mo.js
  • Limited support for SVG animations

Code Comparison

Mo.js:

const burst = new mojs.Burst({
  radius:   { 0: 100 },
  count:    5,
  children: {
    shape:      'circle',
    fill:       { 'cyan' : 'yellow' },
    scale:      { 1: 0 },
    duration:   2000
  }
});

Anime:

anime({
  targets: '.element',
  translateX: 250,
  scale: 2,
  rotate: '1turn',
  duration: 800,
  easing: 'easeInOutQuad'
});

Summary

Anime is a lightweight and easy-to-use animation library, ideal for simpler animations and projects requiring broad browser support. It offers a straightforward API but may lack some advanced features found in Mo.js.

Mo.js, on the other hand, provides more powerful tools for complex animations and shape morphing, with a wider range of built-in easing functions. However, it has a steeper learning curve and may be overkill for simpler projects.

Choose Anime for quick, simple animations with broad compatibility, or Mo.js for more complex, customizable animations in modern browsers.

19,483

GSAP (GreenSock Animation Platform), a JavaScript animation library for the modern web

Pros of GSAP

  • More comprehensive and feature-rich animation library
  • Extensive documentation and community support
  • Cross-browser compatibility and performance optimization

Cons of GSAP

  • Larger file size and potential overhead for simpler projects
  • Steeper learning curve for beginners

Code Comparison

GSAP:

gsap.to(".box", {duration: 2, x: 100, y: 50, rotation: 360});

MoJS:

const tween = new mojs.Tween({
  duration: 2000,
  onUpdate: (progress) => {
    el.style.transform = `translateX(${100 * progress}px) translateY(${50 * progress}px) rotate(${360 * progress}deg)`;
  }
});
tween.play();

Key Differences

  • GSAP offers a more declarative syntax, while MoJS requires more manual setup
  • GSAP provides built-in easing functions and timeline management
  • MoJS focuses on modular, object-oriented approach to animations

Use Cases

  • GSAP: Complex, timeline-based animations and interactive web experiences
  • MoJS: Custom, shape-based animations and micro-interactions

Community and Ecosystem

  • GSAP: Larger community, more third-party plugins, and extensive learning resources
  • MoJS: Smaller but dedicated community, fewer external resources available
15,183

JavaScript library to make drawing animation on SVG

Pros of Vivus

  • Lightweight and focused specifically on SVG animation
  • Simple API with minimal configuration required
  • Supports various animation types (delayed, sync, oneByOne, etc.)

Cons of Vivus

  • Limited to SVG line drawing animations
  • Lacks advanced features and complex animation capabilities
  • Smaller community and fewer updates compared to Mo.js

Code Comparison

Vivus example:

new Vivus('my-svg', {duration: 200, type: 'delayed'});

Mo.js example:

const circle = new mojs.Shape({
  shape: 'circle',
  scale: {0: 1},
  duration: 1000
}).play();

Key Differences

  • Vivus focuses solely on SVG line drawing animations, while Mo.js offers a broader range of animation types and shapes
  • Mo.js provides more advanced features and customization options, but has a steeper learning curve
  • Vivus is ideal for simple SVG animations, while Mo.js is better suited for complex, interactive animations

Use Cases

  • Choose Vivus for quick and easy SVG line drawing animations
  • Opt for Mo.js when creating complex, multi-object animations or interactive motion graphics

Community and Support

  • Mo.js has a larger community and more frequent updates
  • Vivus is stable but receives fewer updates and has a smaller ecosystem

Render After Effects animations natively on Web, Android and iOS, and React Native. http://airbnb.io/lottie/

Pros of Lottie-web

  • Supports complex animations exported directly from After Effects
  • Extensive ecosystem with tools and plugins for various platforms
  • Widely adopted and maintained by a large company (Airbnb)

Cons of Lottie-web

  • Larger file size due to JSON-based animation format
  • Limited runtime manipulation of animations
  • Steeper learning curve for creating custom animations

Code Comparison

Mo.js:

const burst = new mojs.Burst({
  radius:   { 0: 100 },
  count:    5,
  children: {
    shape:      'circle',
    fill:       { 'cyan' : 'yellow' },
    scale:      { 1: 0 },
    duration:   2000
  }
});

Lottie-web:

lottie.loadAnimation({
  container: document.getElementById('lottie-container'),
  renderer: 'svg',
  loop: true,
  autoplay: true,
  path: 'data.json'
});

Mo.js focuses on programmatic creation of animations using JavaScript, allowing for more dynamic and interactive animations. Lottie-web, on the other hand, relies on pre-designed animations exported from After Effects, which are then loaded and played back using the library. This makes Lottie-web more suitable for complex, pre-designed animations, while Mo.js excels in creating programmatic and interactive animations on the fly.

16,455

Parallax Engine that reacts to the orientation of a smart device

Pros of Parallax

  • Simpler and more lightweight, focusing specifically on parallax scrolling effects
  • Easier to implement for basic parallax scrolling scenarios
  • Better performance for simple parallax effects due to its focused nature

Cons of Parallax

  • Limited to parallax scrolling effects, less versatile than Mo.js
  • Less active development and community support
  • Fewer animation options and customization possibilities compared to Mo.js

Code Comparison

Parallax example:

var scene = document.getElementById('scene');
var parallax = new Parallax(scene);

Mo.js example:

const burst = new mojs.Burst({
  radius:   { 0: 100 },
  count:    5,
  children: {
    shape:      'circle',
    fill:       { 'cyan' : 'yellow' },
    duration:   2000
  }
});

Summary

Parallax is a focused library for creating parallax scrolling effects, making it simpler to use for specific scenarios. However, it lacks the versatility and extensive animation capabilities of Mo.js. Mo.js offers a wider range of animation options and is more suitable for complex, interactive animations beyond just parallax effects. The choice between the two depends on the specific project requirements and the complexity of animations needed.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

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, 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 web page, 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:

Contribute

If you want to report a bug or request a new feature/improvement, please read the project contributors guidelines before. Thanks for taking time to contribute.

NPM DownloadsLast 30 Days