mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-09 09:45:42 +02:00
Merge pull request #18336 from Snuffleupagus/InternalRenderTask-cancel-cancelAnimationFrame
Cancel the `requestAnimationFrame` in the API when cancelling rendering
This commit is contained in:
commit
53aca5fab1
1 changed files with 8 additions and 1 deletions
|
@ -3254,6 +3254,8 @@ class RenderTask {
|
|||
* @ignore
|
||||
*/
|
||||
class InternalRenderTask {
|
||||
#rAF = null;
|
||||
|
||||
static #canvasInUse = new WeakSet();
|
||||
|
||||
constructor({
|
||||
|
@ -3353,6 +3355,10 @@ class InternalRenderTask {
|
|||
this.running = false;
|
||||
this.cancelled = true;
|
||||
this.gfx?.endDrawing();
|
||||
if (this.#rAF) {
|
||||
window.cancelAnimationFrame(this.#rAF);
|
||||
this.#rAF = null;
|
||||
}
|
||||
InternalRenderTask.#canvasInUse.delete(this._canvas);
|
||||
|
||||
this.callback(
|
||||
|
@ -3391,7 +3397,8 @@ class InternalRenderTask {
|
|||
|
||||
_scheduleNext() {
|
||||
if (this._useRequestAnimationFrame) {
|
||||
window.requestAnimationFrame(() => {
|
||||
this.#rAF = window.requestAnimationFrame(() => {
|
||||
this.#rAF = null;
|
||||
this._nextBound().catch(this._cancelBound);
|
||||
});
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue