// Abandon the run in flight — the alternative to stop(), which keeps what stands
layout.cancel(): thisAbandon the run in flight — the alternative to stop(), which keeps what stands. The impl is asked to cancel() (or stop() when it has no cancel), and once its run settles the scope's nodes go back to where run() found them, a tween under way is dropped where it is, the viewport is left alone, layoutstop fires with cancelled: true, and promise() rejects with CancelledError. A layout that is not running is unchanged.
Returns
thisthis layout, for chaining
Example
const handle = cy.layout({ impl: { async run() { await Promise.resolve(); } } });handle.run();handle.cancel();let cancelled = false;try { await handle.promise(); }catch (error) { cancelled = error instanceof cytoscape.CancelledError; }console.log(cancelled); // true