mojs / mojs/mojs

Is there a duration for each Shape properties ?

Open
#64 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature
Dominant language
CoffeeScript
Stars
18.8k
Forks
888
PR merge metrics
No merged PRs in 30d

Description

Hi !

I'm actually trying a basic Shape animation on this codepen and I would like to know if it's possible to have a duration for each property of a unique Shape. Like mojs.Html.

For example, I have a square which I would like to draw the outline first and making disappear after a delay while he turns :

|----------------------------------- Rotate --------------------------------|
|--- StrokeDashoffset ---| - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - -|-------- Opacity -------|
const square = new mojs.Shape({
  shape:       'rect',
  stroke:      '#FA6B6E',
  fill:        'none',
  radius:      20,
  strokeWidth: 8,
  angle:       { 0 : 90 },
  strokeDasharray: '100%',
  strokeDashoffset: { '-100%' : '0', duration: 500 },
  opacity:     { 1 : 0, delay: 1000, duration: 500 },
  // duration : 1500, // ???
});

But it doesn't work for me and, instead, I tried to use .then({})and I made something like this :

|----- Rotate * 0.25 ----||---- Rotate * 0.5 -----||----- Rotate * 0.25 ----|
|--- StrokeDashoffset ---| - - - - - - - - - - - - - - - - - - - - - - - - - 
- - - - - - - - - - - - - - - - - - - - - - - - - -|-------- Opacity -------|
const _rotate = dist => ({
  duration:    duration * dist,
  angle:       { 0 : [360 * dist], easing: 'linear.none' },
});
const square = new mojs.Shape({
  ..._rotate(0.25),
  shape:       'rect',
  stroke:      '#FA6B6E',
  fill:        'none',
  radius:      20,
  strokeWidth: 8,
  angle:       { 0 : 90 },
  strokeDasharray: '100%',
  strokeDashoffset: { '-100%' : '0' },
}).then({
  ..._rotate(0.5),
  strokeDasharray: false,
}).then({
  ..._rotate(0.25),
  strokeDasharray: false,
  opacity:     { 1 : 0 },
});

I did not find any examples of the searched approach and, if it is not possible to make a duration, how can I make something most clearly ?

Thank you for your work and for this library very promising :D

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the mojs.Shape configuration and the .then({}) chain shown in the issue, focusing on how duration and delay are applied to individual properties. Done means establishing whether per-property timing is supported and documenting or demonstrating the clearest way to coordinate rotation, strokeDashoffset, and opacity.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
computer-graphics, frontend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.