Skip to content

Commit 4a41739

Browse files
authored
2.4.3 (#53)
* Notivue - Move `isMouse` util to /Notivue * Pkg - Edit tests workflow * Core - Deprecate `syncTransitionStyles` add add `transitionStyles` config * Core - Set transition config prop as whole * Core - Remove deprecated transitions test * Pkg - Bump 2.4.3
1 parent 6b29277 commit 4a41739

16 files changed

+25
-83
lines changed

.github/workflows/tests.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ name: Tests
22

33
on:
44
pull_request:
5+
branches:
6+
- main
57
push:
68
branches:
7-
- '*'
9+
- main
810
tags-ignore:
911
- '*'
1012
workflow_call:

packages/notivue/Notivue/composables/useMouseEvents.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { computed } from 'vue'
22

3-
import { isMouse } from '@/core/utils'
3+
import { isMouse } from '@/Notivue/utils'
44
import { useStore } from '@/core/useStore'
55

66
export function useMouseEvents() {

packages/notivue/Notivue/composables/useTouchEvents.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { computed, onBeforeUnmount } from 'vue'
22

33
import { useStore } from '@/core/useStore'
4-
import { isMouse } from '@/core/utils'
4+
import { isMouse } from '@/Notivue/utils'
55

66
/**
77
* The logic follows this pattern:

packages/notivue/Notivue/utils.ts

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import type { NotivueItem } from 'notivue'
22

3+
export const isMouse = (e: PointerEvent) => e.pointerType === 'mouse'
4+
35
export function getAriaLabel(item: NotivueItem) {
46
return `${item.title ? `${item.title}: ` : ''}${item.message}`
57
}

packages/notivue/NotivueSwipe/NotivueSwipe.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
} from 'vue'
1313
1414
import { useStore } from '@/core/useStore'
15-
import { isMouse } from '@/core/utils'
15+
import { isMouse } from '@/Notivue/utils'
1616
import { NotificationTypeKeys as NType } from '@/core/constants'
1717
import { DEFAULT_PROPS, DEBOUNCE, RETURN_DUR } from './constants'
1818

packages/notivue/core/constants.ts

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ export const DEFAULT_CONFIG: NotivueConfigRequired = {
6262
notifications: DEFAULT_NOTIFICATION_OPTIONS,
6363
limit: Infinity,
6464
avoidDuplicates: false,
65+
transition: 'transform 0.35s cubic-bezier(0.5, 1, 0.25, 1)',
6566
animations: {
6667
enter: CLASS_PREFIX + 'enter',
6768
leave: CLASS_PREFIX + 'leave',

packages/notivue/core/createNotivue.ts

-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ function createInstance(startOnCreation: boolean) {
8080
store.items.clear()
8181
store.queue.clear()
8282
store.items.clearLifecycleEvents()
83-
store.animations.resetTransitionStyles()
8483

8584
setPush(createPushMock())
8685
unwatchStore.forEach((unwatch) => unwatch())

packages/notivue/core/createStore.ts

+1-41
Original file line numberDiff line numberDiff line change
@@ -167,37 +167,11 @@ export function createAnimations(
167167
queue: QueueSlice,
168168
elements: ElementsSlice
169169
) {
170-
let tStyles = ['0.35s', 'cubic-bezier(0.5, 1, 0.25, 1)']
171-
172170
return {
173171
isReducedMotion: ref(false),
174-
transitionStyles: null as null | Pick<CSSProperties, 'transitionDuration' | 'transitionTimingFunction'>, // prettier-ignore
175172
setReducedMotion(newVal: boolean) {
176173
this.isReducedMotion.value = newVal
177174
},
178-
resetTransitionStyles() {
179-
this.transitionStyles = null
180-
},
181-
syncTransitionStyles() {
182-
const { enter } = config.animations.value
183-
184-
if (!enter) {
185-
tStyles = ['0s', 'ease']
186-
} else {
187-
const animEl = elements.root.value?.querySelector(`.${enter}`)
188-
if (animEl) {
189-
console.log('Syncing transition styles')
190-
191-
const style = window.getComputedStyle(animEl)
192-
tStyles = [style.animationDuration, style.animationTimingFunction]
193-
}
194-
}
195-
196-
this.transitionStyles = {
197-
transitionDuration: tStyles[0],
198-
transitionTimingFunction: tStyles[1],
199-
}
200-
},
201175
playLeave(id: string, { isDestroy = false, isUserTriggered = false } = {}) {
202176
const { leave = '' } = config.animations.value
203177
const item = items.get(id)
@@ -247,19 +221,6 @@ export function createAnimations(
247221
})
248222
},
249223
updatePositions({ isImmediate = false } = {}) {
250-
if (!this.transitionStyles) {
251-
// Runs the first time a notification is rendered
252-
window.requestAnimationFrame(() => {
253-
this.syncTransitionStyles()
254-
window.requestAnimationFrame(() => {
255-
this.updatePositionsImpl(isImmediate)
256-
})
257-
})
258-
} else {
259-
this.updatePositionsImpl(isImmediate)
260-
}
261-
},
262-
updatePositionsImpl(isImmediate: boolean) {
263224
console.log('Updating positions')
264225

265226
const isReduced = this.isReducedMotion.value || isImmediate
@@ -276,9 +237,8 @@ export function createAnimations(
276237

277238
items.update(id, {
278239
positionStyles: {
279-
willChange: 'transform',
280240
transform: `translate3d(0, ${accPrevHeights}px, 0)`,
281-
...(isReduced ? { transition: 'none' } : this.transitionStyles),
241+
transition: isReduced ? 'none' : config.transition.value,
282242
},
283243
})
284244

packages/notivue/core/createStoreWatchers.ts

-9
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,5 @@ export function createStoreWatchers(store: NotivueStore) {
3030
},
3131
{ flush: 'post' }
3232
),
33-
34-
watch(
35-
() => store.config.animations.value.enter,
36-
(newEnter, prevEnter) => {
37-
if (newEnter !== prevEnter) {
38-
store.animations.resetTransitionStyles()
39-
}
40-
}
41-
),
4233
]
4334
}

packages/notivue/core/types.ts

+11
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,17 @@ export interface NotivueConfig {
7777
notifications?: Partial<NotificationTypesOptions>
7878
/** Animation classes for `enter`, `leave` and `clearAll`. */
7979
animations?: NotivueAnimations
80+
/** Transition property applied when repositioning notifications. Must match the following pattern:
81+
*
82+
* `transform <duration> <timing-function>`
83+
*
84+
* @example
85+
*
86+
* ```ts
87+
* transition: 'transform 0.35s cubic-bezier(0.5, 1, 0.25, 1)'
88+
* ```
89+
*/
90+
transition?: string
8091
/** Tag or element to which the stream will be teleported. */
8192
teleportTo?: string | HTMLElement | false
8293
/** Notifications limit. Defaults to `Infinity`. */

packages/notivue/core/utils.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ import type {
1414

1515
export const isSSR = typeof window === 'undefined'
1616

17-
export const isMouse = (e: PointerEvent) => e.pointerType === 'mouse'
18-
1917
export function mergeDeep<T extends Obj>(target: T, source: Record<string, any>): T {
2018
const merged: T = { ...target }
2119

@@ -96,6 +94,7 @@ export const internalKeys: (keyof InternalKeys)[] = [
9694
'timeout',
9795
'resumedAt',
9896
'remaining',
97+
// Maybe in future releases these could be exposed
9998
'animationAttrs',
10099
'positionStyles',
101100
]

packages/notivue/nuxt/module.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"name": "notivue/nuxt",
33
"configKey": "notivue",
4-
"version": "2.4.2"
4+
"version": "2.4.3"
55
}

packages/notivue/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "notivue",
3-
"version": "2.4.2",
3+
"version": "2.4.3",
44
"private": false,
55
"description": "Powerful toast notification system for Vue and Nuxt",
66
"keywords": [

tests/Notivue/transitions-properties.cy.ts

-21
This file was deleted.
File renamed without changes.

tests/cypress/support/commands-notivue.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,5 @@ Cypress.Commands.add('checkTransitions', (element: HTMLElement, height: number)
123123
.wrap(element)
124124
.should('have.attr', 'style')
125125
.and('include', `transform: translate3d(0px, ${height}px, 0px)`)
126-
.and('include', 'transition-duration: 0.35s')
127-
.and('include', 'transition-property: transform')
128-
.and('include', 'transition-timing-function: cubic-bezier(0.5, 1, 0.25, 1)')
126+
.and('include', 'transition: transform 0.35s cubic-bezier(0.5, 1, 0.25, 1)')
129127
)

0 commit comments

Comments
 (0)