Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mojs-curve-editor

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mojs-curve-editor

mojs GUI for editing easing/property curves

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6
increased by50%
Maintainers
1
Weekly downloads
 
Created
Source

mojs curve editor

mojs-curve-editor

MojsCurveEditor is a GUI plugin for interactive custom easings/property curves editing while crafting your animations. Part of mojs tools.

Installation

The MojsCurveEditor depends on mojs >= 0.225.2, tween autoupdates available for mojs >= 0.276.2. Please make sure you've linked mojs library first.

CDN:

<script src="//cdn.jsdelivr.net/mojs-curve-editor/latest/mojs-curve-editor.min.js"></script>

NPM:

[sudo] npm install mojs-curve-editor

Bower:

bower install mojs-curve-editor

Import MojsCurveEditor constructor to your code (depends on your environment) :

const MojsCurveEditor = require('mojs-player').default;
// or
import MojsCurveEditor from 'mojs-player';

If you installed it with script link - you should have MojsCurveEditor global.

Usage

Construct MojsCurveEditor with the next options:

  const mojsCurve = new MojsCurveEditor({
    // Name of the Curve you are working on. The name is used to
    // idetify record in `localStorage` to resore the state from
    // when page gets reloaded, so please specify unique names if 
    // you use more than one editor on the same page.
    name:         'bounce curve',
    // if should preserve state on page reloads
    isSaveState:  true
  });

After that you can "connect" the curve with your mojs modules by passing a "sample" of the curve to the easing property of the modules like this:

  const mojsCurve = new MojsCurveEditor();

  const tween = new mojs.Tween({
    easing: mojsCurve.getEasing()
  });

  // or

  const shape = new mojs.Shape({
    easing: mojsCurve.getEasing()
  });

  // or as `property curve`

  const html = new mojs.Html({
    el:     '#js-el',
    x:      { 100: 100, curve: mojsCurve.getEasing() }
  });
    

Each tween/module should have it's out sample of the curve, this means you need to call mojsCurve.getEasing() send the sample of the curve to the easing property of modules.

If you use mojs>0.276.5 the state of the modules with the curve sample will be updated automatically.

The getEasing function recieves options hash:

  // ...
  easing: mojsCurve.getEasing({
    // `transform` function that pipes thru the current value
    // of the curve so you can transform it
    transform: (k) => { return k; }
  });
  // ...

After you are happy with the curve you need to change the sample(mojsCurve.getEasing() calls) with actual path data which you can get by clicking on the code button (code button):

  const html = new mojs.Html({
    el:     '#js-el',
    // after the change
    x:      { 0: 100, easing: 'M0, 100 C0, 100 19.8984745544779, 40.10152544552211 30, 30 C40.1015254455221, 19.89847455447789 80, 45 80, 45 C80, 45 100, 0 100, 0 ' }
  });

Shortcuts

  • alt + z - undo curve action
  • alt + x - rendo curve action
  • alt + d - delete selected point(s)

Development

Install webpack globally:

[sudo] npm install webpack -g

Install dependencies with npm:

[sudo] npm install

Run webpack:

webpack

Please make sure you started a feature branch with the feature name (better from the dev branch) before making changes.

License

(The MIT License)

Copyright (c) Oleg Solomka @LegoMushroom legomushroom@gmail.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Keywords

FAQs

Package last updated on 24 Aug 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc