@@ -176,7 +176,7 @@ const swiping = ref(false)
176
176
const swipeOut = ref (false )
177
177
const offsetBeforeRemove = ref (0 )
178
178
const initialHeight = ref (0 )
179
- const dragStartTime = ref < Date | null >( null )
179
+ let dragStartTime: number = 0
180
180
const toastRef = ref <HTMLLIElement | null >(null )
181
181
const isFront = computed (() => props .index === 0 )
182
182
const isVisible = computed (() => props .index + 1 <= props .visibleToasts )
@@ -290,7 +290,7 @@ const handleCloseToast = () => {
290
290
291
291
const onPointerDown = (event : PointerEvent ) => {
292
292
if (disabled .value || ! dismissible .value ) return
293
- dragStartTime . value = new Date ()
293
+ dragStartTime = Date . now ()
294
294
offsetBeforeRemove .value = offset .value
295
295
// Ensure we maintain correct pointer capture even when going outside of the toast (e.g. when swiping)
296
296
;(event .target as HTMLElement ).setPointerCapture (event .pointerId )
@@ -309,7 +309,7 @@ const onPointerUp = (event: PointerEvent) => {
309
309
.replace (' px' , ' ' ) || 0
310
310
)
311
311
312
- const timeTaken = new Date (). getTime () - dragStartTime ! . value ! . getTime ()
312
+ const timeTaken = ( Date . now () - dragStartTime ) || 50
313
313
const velocity = Math .abs (swipeAmount ) / timeTaken
314
314
315
315
// Remove only if treshold is met
@@ -362,16 +362,16 @@ watchEffect((onInvalidate) => {
362
362
const pauseTimer = () => {
363
363
if (lastCloseTimerStartTimeRef .value < closeTimerStartTimeRef .value ) {
364
364
// Get the elapsed time since the timer started
365
- const elapsedTime = new Date (). getTime () - closeTimerStartTimeRef .value
365
+ const elapsedTime = Date . now () - closeTimerStartTimeRef .value
366
366
367
367
remainingTime .value = remainingTime .value - elapsedTime
368
368
}
369
369
370
- lastCloseTimerStartTimeRef .value = new Date (). getTime ()
370
+ lastCloseTimerStartTimeRef .value = Date . now ()
371
371
}
372
372
373
373
const startTimer = () => {
374
- closeTimerStartTimeRef .value = new Date (). getTime ()
374
+ closeTimerStartTimeRef .value = Date . now ()
375
375
// Let the toast know it has started
376
376
timeoutId = setTimeout (() => {
377
377
props .toast .onAutoClose ?.(props .toast )
0 commit comments