diff --git a/packages/notivue/Notivue/composables/useRepositioning.ts b/packages/notivue/Notivue/composables/useRepositioning.ts index 27dfaa0..35ce2ad 100644 --- a/packages/notivue/Notivue/composables/useRepositioning.ts +++ b/packages/notivue/Notivue/composables/useRepositioning.ts @@ -2,12 +2,10 @@ import { useWindowSize } from './useWindowSize' import { useResizeListObserver } from './useResizeListObserver' import { useStore } from '@/core/useStore' -import { TransitionType as TType } from '@/core/constants' - export function useRepositioning() { const { elements, animations } = useStore() - useWindowSize(() => animations.updatePositions(TType.IMMEDIATE)) + useWindowSize(() => animations.updatePositions({ isImmediate: true })) useResizeListObserver(elements.items.value, () => animations.updatePositions()) } diff --git a/packages/notivue/core/constants.ts b/packages/notivue/core/constants.ts index 5519fc3..9a9c75b 100644 --- a/packages/notivue/core/constants.ts +++ b/packages/notivue/core/constants.ts @@ -14,11 +14,6 @@ export const NotificationTypeKeys: Record = { PROMISE_REJECT: 'promise-reject', } -export enum TransitionType { - PUSH, - IMMEDIATE, -} - const success: NotificationOptions = { title: '', message: '', diff --git a/packages/notivue/core/createStore.ts b/packages/notivue/core/createStore.ts index eb7dabc..9d8d7c7 100644 --- a/packages/notivue/core/createStore.ts +++ b/packages/notivue/core/createStore.ts @@ -8,7 +8,7 @@ import { } from './utils' import { getSlotItem } from '@/Notivue/utils' -import { DEFAULT_CONFIG, NotificationTypeKeys as NKeys, TransitionType as TType } from './constants' +import { DEFAULT_CONFIG, NotificationTypeKeys as NKeys } from './constants' import type { DeepPartial, @@ -59,7 +59,7 @@ export function createQueue() { this.triggerRef() }, get(id: string) { - return this.entries.value.find(({ id: _id }) => id === _id) + return this.entries.value.find((e) => e.id === id) }, update(id: string, newOptions: DeepPartial) { Object.assign(this.get(id) ?? {}, newOptions) @@ -68,7 +68,7 @@ export function createQueue() { triggerRef(this.entries) }, remove(id: string) { - this.entries.value = this.entries.value.filter(({ id: _id }) => id !== _id) + this.entries.value = this.entries.value.filter((e) => e.id !== id) }, clear() { this.entries.value = [] @@ -97,7 +97,7 @@ export function createItems(config: ConfigSlice, queue: QueueSlice) { this.add(next) }, get(id: string) { - return this.entries.value.find(({ id: _id }) => id === _id) + return this.entries.value.find((e) => e.id === id) }, update(id: string, newOptions: DeepPartial) { Object.assign(this.get(id) ?? {}, newOptions) @@ -109,7 +109,7 @@ export function createItems(config: ConfigSlice, queue: QueueSlice) { this.entries.value = this.entries.value.map(updateItem) }, remove(id: string) { - this.entries.value = this.entries.value.filter(({ id: _id }) => id !== _id) + this.entries.value = this.entries.value.filter((e) => e.id !== id) const shouldDequeue = queue.length > 0 && this.length < config.limit.value if (shouldDequeue) { @@ -211,8 +211,8 @@ export function createAnimations(config: ConfigSlice, items: ItemsSlice, element onAnimationend: () => items.clear(), }) }, - updatePositions(type = TType.PUSH) { - const isReduced = this.isReducedMotion.value || type === TType.IMMEDIATE + updatePositions({ isImmediate = false } = {}) { + const isReduced = this.isReducedMotion.value || isImmediate const leaveClass = config.animations.value.leave let accPrevHeights = 0 diff --git a/packages/notivue/core/createWatchers.ts b/packages/notivue/core/createWatchers.ts index f26a84d..1ef9a3a 100644 --- a/packages/notivue/core/createWatchers.ts +++ b/packages/notivue/core/createWatchers.ts @@ -1,5 +1,4 @@ import { watch } from 'vue' -import { TransitionType as TType } from './constants' import type { NotivueStore } from 'notivue' @@ -7,7 +6,7 @@ export function createWatchers(store: NotivueStore) { watch( store.config.isTopAlign, () => { - store.animations.updatePositions(TType.IMMEDIATE) + store.animations.updatePositions({ isImmediate: true }) }, { flush: 'post' } ) @@ -15,7 +14,7 @@ export function createWatchers(store: NotivueStore) { watch( () => store.items.length, () => { - store.animations.updatePositions(TType.PUSH) + store.animations.updatePositions() }, { flush: 'post' } )