diff --git a/src/features/reset.ts b/src/features/reset.ts index d3b373b..3a724e3 100644 --- a/src/features/reset.ts +++ b/src/features/reset.ts @@ -69,8 +69,13 @@ export function createReset( const listeners: Record = {}; export function trackResetTime(layer: BaseLayer, reset: GenericReset): Persistent { const resetTime = persistent(new Decimal(0)); - listeners[layer.id] = layer.on("preUpdate", diff => { - resetTime.value = Decimal.add(resetTime.value, diff); + globalBus.on("addLayer", layerBeingAdded => { + if (layer === layerBeingAdded) { + listeners[layer.id]?.(); + listeners[layer.id] = layer.on("preUpdate", diff => { + resetTime.value = Decimal.add(resetTime.value, diff); + }); + } }); globalBus.on("reset", currentReset => { if (currentReset === reset) {