@@ -69,7 +69,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
69
69
r =" 16"
70
70
stroke-width =" 50"
71
71
stroke-dasharray =" 157"
72
- :style =" getRunningStyle() "
72
+ :style =" runningStyle "
73
73
/>
74
74
</g >
75
75
<!-- dot
@@ -247,6 +247,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
247
247
</template >
248
248
249
249
<script setup>
250
+ import { computed , inject , ref } from ' vue'
250
251
import TaskState from ' @/model/TaskState.model'
251
252
252
253
const props = defineProps ({
@@ -268,26 +269,30 @@ const props = defineProps({
268
269
},
269
270
})
270
271
271
- function getRunningStyle () {
272
+ /**
273
+ * @type {import('vue').Ref<number>}
274
+ * @see @/components/cylc/workspace/Widget.vue
275
+ */
276
+ const animResetTime = inject (' animResetTime' , () => ref (0 ), true )
277
+
278
+ const runningStyle = computed (() => {
272
279
if (
273
280
props .task .state === TaskState .RUNNING .name &&
274
281
props .startTime &&
275
282
props .task .task ? .meanElapsedTime
276
283
) {
277
- // job start time in ms (UTC)
278
- const startTime = Date .parse (props .startTime )
279
- // current time in ms (UTC)
280
- const now = Date .now ()
284
+ // current time in ms (UTC); updates whenever widget is unhidden
285
+ const now = Math .max (Date .now (), animResetTime .value )
281
286
// job elapsed time in ms
282
- const elapsedTime = now - startTime
287
+ const elapsedTime = now - Date . parse ( props . startTime )
283
288
return {
284
289
animationDuration: ` ${ props .task .task .meanElapsedTime } s` ,
285
290
animationDelay: ` -${ elapsedTime} ms` ,
286
291
animationFillMode: ' forwards' ,
287
292
}
288
293
}
289
294
return {}
290
- }
295
+ })
291
296
292
297
/**
293
298
* Returns the translation required to position the ".modifier" nicely in
0 commit comments