How we can stop/pause animation?

21 views
Skip to first unread message

Alyona Rodina

unread,
Nov 30, 2021, 7:45:43 PM11/30/21
to Paper.js
Could you please help with stopping animation?

I see the view has pause() method. But not sure why it gives me errors.
This is rotation, for example. How we can pause it. 

circles.current.onFrame = (event) => {
circles.current.rotate(1, Paper.view.center);
};

Thank you for your quick response!
Alyona

asensi...@gmail.com

unread,
Dec 1, 2021, 3:40:43 AM12/1/21
to Paper.js
Hi,

It is hard to tell why you have an error because you only posted a small part of your code.
Here's a sketch demonstrating how it can work.

const circle = new Path.Circle({
    center: view.center + 50,
    radius: 50,
    fillColor: 'orange'
});

circle.onFrame = (event) => {
    circle.rotate(1, view.center);
};

let playing = true;

function onMouseDown() {
    if (playing) {
        view.pause();
        playing = false;
    } else {

        view.play();
        playing = true;
    }
}

new PointText({
    content: 'click to play or pause animation',
    point: view.center,
    justification: 'center'
});


Alyona Rodina

unread,
Dec 1, 2021, 9:22:27 AM12/1/21
to Paper.js
Thank you so much!! Will try this. 
Reply all
Reply to author
Forward
0 new messages