rough-notation icon indicating copy to clipboard operation
rough-notation copied to clipboard

Question: Delay annotate or annotationGroup from running

Open TedGoas opened this issue 3 years ago • 1 comments

Hey thanks again for making this!

I'm a JS novice and am wondering how to delay an annotate or annotationGroup group from running for 500ms or 1s or something. Is this an option in ag.show();? Or should we be using setTimeout() or something similar?

Any suggestions would be a big help. Thanks!

TedGoas avatar Apr 11 '21 20:04 TedGoas

I was able to achieve this by wrapping everything in a setTimeout function. I'm sure there's a better way to do this, but this achieves what I was looking for:

 setTimeout(function () {
    const annotate = RoughNotation.annotate;
    const annotationGroup = RoughNotation.annotationGroup;
    const $ = (t) => document.querySelector(t);
    {
        const a1 = annotate($('.box-blue'), { type: 'box', color: '#3BC9DB', animationDuration: 500 });
        const a2 = annotate($('.box-green'), { type: 'box', color: '#059669', animationDuration: 500 });
        const ag = annotationGroup([a1, a2]);
        ag.show();
    }
}, 500)();

TedGoas avatar Apr 13 '21 00:04 TedGoas