@mojs/player –
GUI player to control your animations.
Player controls for mojs. Intended to help you to craft mojs
animation sequences. To be clear, this player is not needed to play mojs
animations. It is just a debug tool that gives you the ability to:
- control your sequences with
GUI
while working on them - it saves the current progress of your animation thus you don't loose the
focus
- it gives you
bounds
to constrain focus point
of your animation - it gives you the control over the speed of animation
- it gives you the ability to seek animations freely
- it saves player's state and settings thus they not get lost when page reloaded
Installation
The MojsPlayer
depends on mojs >= 0.225.2
so make sure you link it first.
# cdn
<script src="https://cdn.jsdelivr.net/npm/@mojs/player"></script>
# npm
npm i @mojs/player
Import MojsPlayer
constructor to your code, depending on your environment:
const MojsPlayer = require('mojs-player').default;
import MojsPlayer from '@mojs/player';
If you installed it with script link — you should have MojsPlayer
global
Usage
Construct MojsPlayer
and pass your main Tween/Timeline
to the add
option:
const mainTimeline = new mojs.Timeline({});
const mojsPlayer = new MojsPlayer({
add: mainTimeline
});
The add
option is the only required option to launch: player's controls should appear at the bottom of the page when ready
You can also set other player initial state:
const mojsPlayer = new MojsPlayer({
add: mainTimeline,
className: '',
isSaveState: true,
isPlaying: false,
progress: 0,
isRepeat: false,
isBounds: false,
leftBound: 0,
rightBound: 1,
isSpeed: false,
speed: 1,
isHidden: false,
precision: 0.1,
name: 'mojs-player',
onToggleHide(isHidden) {
if (isHidden) {
} else {
}
}
});
Shortcuts
alt + p
- toggle play
/pause
playback statealt + -
- decrease progress by 1/100
alt + +
- increase progress by 1/100
shift + alt + -
- decrease progress by 1/10
shift + alt + +
- increase progress by 1/10
alt + s
- stop
playbackalt + r
- toggle repeat
statealt + b
- toggle bounds
statealt + h
- toggle show
/hide
player statealt + q
- reset speed
to 1x
alt + 2
- decrease speed
by 1/50
alt + 3
- increase speed
by 1/50
shift + alt + 2
- decrease speed
by 1/10
shift + alt + 3
- increase speed
by 1/10
Development
Install webpack globally:
[sudo] npm install webpack -g
Install dependencies with npm:
[sudo] npm install
Run webpack:
webpack
Please make sure you are on the dev
branch before making changes.