Snap.js icon indicating copy to clipboard operation
Snap.js copied to clipboard

Setinterval timer ever 1 ms

Open brantje opened this issue 11 years ago • 6 comments

Hi there, This line: https://github.com/jakiestfu/Snap.js/blob/develop/snap.js#L207

    cache.animatingInterval = setInterval(function() {
                            utils.dispatchEvent('animating');
                        }, 1);

Sets an interval timer on every 1 ms, why so high? Leave the browser window from ownCloud open for a while, and you will notice the page is getting slow.

Current i fix this by doing:

  var highestTimeoutId = setTimeout(";");
    for (var i = 0; i < highestTimeoutId; i++) {
        clearTimeout(i);
    }
    Snap = null

brantje avatar Jun 30 '14 12:06 brantje

You can get the latest version in v2.0.0-rc1 branch. https://github.com/jakiestfu/Snap.js/tree/v2.0.0-rc1

inDream avatar Jul 02 '14 04:07 inDream

Please publish this release since this behaviour is hidden in the current version, and slow down mobile apps that use it.

lifeisfoo avatar Mar 20 '15 15:03 lifeisfoo

The solution in v2.0.0-rc1 is to remove the animating action hook? Does a hook exists which I can trigger just while the menu is opened?

Ninos avatar Jun 19 '15 11:06 Ninos

still happening here with 2.0.9: https://github.com/nextcloud/server/issues/21459

what I don't understand is why "easeTo" is being called even though nothing is happening. I'd expect this animation thing to be called only when something is happening.

PVince81 avatar Oct 29 '20 22:10 PVince81

I wonder if this setInterval shouldn't simply be a setTimeout so it only sends the event once to notify listeners that animation has started. No need to send it for every frame.

But still: why does the animation never stop ? Maybe the event that the lib listens to is not fired.

I tried adding console.log and with NC I see only this:

close()
easeTo(0)

no callback called. maybe there was no transition in the first place ?

it seems that it doesn't like it when we tell it to ease to a position it's already in. I managed to reduce the damage by adding a check in the caller to "not close if already closed", etc.

But in general I'd expected such checks to exist in the library.

PVince81 avatar Oct 29 '20 22:10 PVince81

It seems that if on triggers open or close while an animation is not finished, it will also create an unfinishable ease animation. This is the case in Nextcloud where we wired up the trigger button to the enter key, so going wild with the enter key during an animation can trigger further easeTo scenarios.

PVince81 avatar Oct 29 '20 22:10 PVince81