Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

GUI for live easing/property curves editing

License

NotificationsYou must be signed in to change notification settings

mojs/mojs-curve-editor

Repository files navigation

GUI for live easing/property curves editing.

mojs-curve-editor

MojsCurveEditor is a GUI plugin for interactive custom easings and property curves editing while crafting your animations. It is part ofmojs tools.

Installation

TheMojsCurveEditor depends onmojs >= 0.225.2, tween autoupdates available formojs >= 0.276.2. Please make sure you've linkedmojs library first.

#npmnpm install @mojs/curve-editor#cdn<script src="https://cdn.jsdelivr.net/npm/@mojs/curve-editor"></script>

ImportMojsCurveEditor constructor inside your code, depending on your environment:

constMojsCurveEditor=require('mojs-curve-editor').default;// orimportMojsCurveEditorfrom'@mojs/curve-editor';

If you installed it with script link - you should haveMojsCurveEditor global

Usage

ConstructMojsCurveEditor with the next options:

constmojsCurve=newMojsCurveEditor({// name of the Curve you are working on. The name is used to// identify record in `localStorage` to restore 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'});

After that you can "connect" the curve with yourmojs modules by passing a "sample" of the curve to theeasing property of the module, like this:

constmojsCurve=newMojsCurveEditor();consttween=newmojs.Tween({easing:mojsCurve.getEasing()});// orconstshape=newmojs.Shape({easing:mojsCurve.getEasing()});// or as `property curve`consthtml=newmojs.Html({el:'#js-el',x:{0:100,curve:mojsCurve.getEasing()}});

Eachtween/module should have it's out sample of the curve, this means you need to callmojsCurve.getEasing() send thesample of the curve to theeasing property of modules.

If you usemojs>0.276.5 the state of the modules with the curvesample will be updated automatically.

ThegetEasing function receives options hash:

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

After you are happy with the curve you made, you need to change thesample,mojsCurve.getEasing() calls, with the actual path data that you can get by clicking on thecode buttoncode button:

consthtml=newmojs.Html({el:'#js-el',x:{0:100,easing:'M0, 100 L100, 0'}});

Options

Constructor accepts the next options:

constcurveEditor=newMojsCurveEditor({// name of the curve editorname:'bounce curve'// if should preserve state on page reloadsisSaveState:true,// start path - will be loaded on initialization of the curve,// e.g. before any user modifications were made. Path of 'M0, 100 L100, 0' is set by default.startPath:'M0, 100 L100, 0',// callback on path change, accepts path stringonChange:function(path){},// if should hide when minimized - useful when you try to embedisHiddenOnMin:false});

Public Methods

curveEditor// get `easing function` of the curve.getEasing()// maximize the curve editor.maximize()// minimize the curve editor.minimize()// toggle `maximize/minimize` methods regarding editor's state.toggleSize();

Shortcuts

  • alt + z -undo curve action
  • alt + x -redo curve action
  • alt + d -delete selected point(s)
  • [3 times]alt + \ -reset curve

All shortcuts work only for active editor - it should haveorange mojs logo indicator at bottom left.

Development

Installwebpack globally:

[sudo] npm install webpack -g

Install dependencies withnpm:

[sudo] npm install

Runwebpack:

webpack

Please make sure you started afeature branch with thefeature name (better from thedev branch) before making changes.

About

GUI for live easing/property curves editing

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

 
 
 

Contributors7


[8]ページ先頭

©2009-2025 Movatter.jp