Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to reuse MotorCortex incidents

I have a clip that I develop and I want to reuse a fade in incident instead o creating a new incident every time is this possible? The way I am doing it at the moment looks like this:\

const attrs = {animatedAttrs:{opacity:1}}
const props = {selector:".elem",duration:1000}
const fadeInOne = new CSSEffect(attrs,props)
const fadeInTwo = new CSSEffect(attrs,props)
clip.addIncindet(fadeOne,1000)
// do something else and then later on
clip.addIncident(fadeTwo,1000)

Is there a better way to do this?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

To accomplish what you want you could do the following:

const attrs = {animatedAttrs:{opacity:1}}
const props = {selector:".elem",duration:1000}
const fadeIn = () => new CSSEffect(attrs,props)

clip.addIncindet(fadeIn(),1000)
// do something else and then later on
clip.addIncident(fadeIn(),1000)

Note *: you could add argument to the fadeIn function and make some of the data dynamic such as the selector or the duration, or event add different easing.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading