anime icon indicating copy to clipboard operation
anime copied to clipboard

Wrap animations (properties) in a defined key.

Open infacto opened this issue 5 years ago • 1 comments

Currently you just define the animation properties like scale or opacity etc. in the root config object which also contains other not related properties for options like autoplay and targets etc. This can be a bit dangerous. Because property-name collisions.

Simple example:

var battery = {
  charged: '0%',
  cycles: 120,
  duration: 42
}

anime({
  targets: battery,
  charged: '100%',
  cycles: 130,
  round: 1,
  easing: 'linear'
});

// How to animate "duration" from the battery object without passing the pre-defined props "duration" of Anime?

Maybe not the best example, but collisions with this design is possible. Should be something like this:

var battery = {
  charged: '0%',
  cycles: 120,
  duration: 42
}

anime({
  targets: '',
  duration: 300,
  round: 1,
  easing: 'linear',
  props: {
    charged: '100%',
    cycles: 130,
    duration: 100
  }
});

"props" or "properties" or "keys" or "animate" or whatever...

Or is this already possible? Wrapping the properties to animate in another scope to prevent collisions with pre-defined options.

[email protected]

infacto avatar May 19 '20 08:05 infacto

Looks like that now there is 0 info in console. If lib will migrating to ts - this case will be solve in linting IDE level. But idea with props - nice.

Ridvanovskyy avatar Jul 28 '20 20:07 Ridvanovskyy