Incident cloning

All Incidents (including Groups and Clips) can create a clone of themselves via the method “clone” which returns a clone of the Incident.

clone method accepts (optionally) two arguments: attrs and props. If provided the attrs and props will either overwrite the original values of the original Incident or add the keys if not present.

For example:

const myIncident = new Anime.Anime({
animatedAttrs: {
left:200px’,
top:50px’
}
},
{
duration: 1000,
selector: '.a'
});
const myIncident_clone = myIncident.clone({
‘animatedAttrs.width’:300px’,
‘animatedAttrs.background’: ‘red’
}, {
duration: 500,
delay: 200
});

Will produce a new Incident of the same class (Anime) only with the following attributes:

{
animatedAttrs:{
width:300px’, // changed
top:50px’, // copied
background: ‘red’ // added
}
}

and the following properties:

{
selector: '.a', // copied
duration: 500, // changed
delay: 200 // added
}