@thinkpixellab-public/px-vue 4.1.18 → 4.1.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/components/PxFloat.vue
CHANGED
|
@@ -368,13 +368,15 @@ export default {
|
|
|
368
368
|
setTimeout(() => {
|
|
369
369
|
// floating-ui
|
|
370
370
|
|
|
371
|
+
this.popupPositioned = true;
|
|
372
|
+
|
|
371
373
|
if (nv) {
|
|
372
374
|
let reference = this.getReferenceElement();
|
|
373
375
|
let popup = this.$refs.popup;
|
|
374
376
|
|
|
375
377
|
this.updatePosition(reference, popup);
|
|
376
378
|
|
|
377
|
-
if (this.autoUpdate) {
|
|
379
|
+
if (this.autoUpdate && reference && popup) {
|
|
378
380
|
this.cleanup = autoUpdate(reference, popup, () =>
|
|
379
381
|
this.updatePosition(reference, popup),
|
|
380
382
|
);
|
|
@@ -420,8 +422,6 @@ export default {
|
|
|
420
422
|
// see watcher for transitionVisible
|
|
421
423
|
}
|
|
422
424
|
|
|
423
|
-
this.popupPositioned = true;
|
|
424
|
-
|
|
425
425
|
// show and hide events (also see beforeshow/beforehide in visibleValue watcher)
|
|
426
426
|
|
|
427
427
|
if (nv) {
|
|
@@ -37,8 +37,12 @@ export default {
|
|
|
37
37
|
|
|
38
38
|
// TODO rtlAdjust: {type: Boolean, default: false }
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
// if null, use --px-slide-transition-duration variable
|
|
41
|
+
duration: { type: Number, default: null },
|
|
42
|
+
|
|
41
43
|
ease: { type: String, default: 'power3.out' },
|
|
44
|
+
|
|
45
|
+
// if null, use --px-slide-transition-slide-amount variable
|
|
42
46
|
slideAmount: { default: '40vw' },
|
|
43
47
|
},
|
|
44
48
|
|
|
@@ -46,15 +50,36 @@ export default {
|
|
|
46
50
|
return { initialized: false };
|
|
47
51
|
},
|
|
48
52
|
computed: {
|
|
49
|
-
|
|
53
|
+
calcDuration() {
|
|
50
54
|
if (this.disableAnimations || !this.initialized) {
|
|
51
55
|
return 0;
|
|
52
56
|
}
|
|
53
|
-
|
|
57
|
+
|
|
58
|
+
if (this.duration !== null) {
|
|
59
|
+
return this.duration;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const duration = getComputedStyle(this.$el).getPropertyValue(
|
|
63
|
+
'--px-slide-transition-duration',
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
return parseFloat(duration);
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
calcSlideAmount() {
|
|
70
|
+
if (this.slideAmount !== null) {
|
|
71
|
+
return this.slideAmount;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const slideAmount = getComputedStyle(this.$el).getPropertyValue(
|
|
75
|
+
'--px-slide-transition-slide-amount',
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
return slideAmount;
|
|
54
79
|
},
|
|
55
80
|
tweenShared() {
|
|
56
81
|
return {
|
|
57
|
-
duration: this.
|
|
82
|
+
duration: this.calcDuration,
|
|
58
83
|
ease: this.ease,
|
|
59
84
|
};
|
|
60
85
|
},
|
|
@@ -88,7 +113,7 @@ export default {
|
|
|
88
113
|
dir = direction < 0 ? '-' : '';
|
|
89
114
|
}
|
|
90
115
|
|
|
91
|
-
return dir + this.
|
|
116
|
+
return dir + this.calcSlideAmount;
|
|
92
117
|
},
|
|
93
118
|
slideElements(element) {
|
|
94
119
|
if (!element) {
|
|
@@ -138,7 +163,7 @@ export default {
|
|
|
138
163
|
// fade
|
|
139
164
|
gsap.to(element, {
|
|
140
165
|
opacity: 1,
|
|
141
|
-
duration: this.
|
|
166
|
+
duration: this.calcDuration,
|
|
142
167
|
ease: this.ease,
|
|
143
168
|
onStart: () => {
|
|
144
169
|
this.$emit('before-enter');
|
|
@@ -194,7 +219,7 @@ export default {
|
|
|
194
219
|
|
|
195
220
|
gsap.to(element, {
|
|
196
221
|
opacity: 0,
|
|
197
|
-
duration: this.
|
|
222
|
+
duration: this.calcDuration,
|
|
198
223
|
ease: this.ease,
|
|
199
224
|
onStart: () => {
|
|
200
225
|
this.$emit('before-leave');
|
|
@@ -222,6 +247,14 @@ export default {
|
|
|
222
247
|
|
|
223
248
|
<style lang="scss">
|
|
224
249
|
@use '../styles/px.scss' as *;
|
|
250
|
+
|
|
251
|
+
@at-root {
|
|
252
|
+
:root {
|
|
253
|
+
--px-slide-transition-duration: 1s;
|
|
254
|
+
--px-slide-transition-slide-amount: 40vw;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
225
258
|
.px-slides-transition {
|
|
226
259
|
opacity: 0;
|
|
227
260
|
width: 100%;
|
package/package.json
CHANGED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* useBodyClass()
|
|
3
|
-
*
|
|
4
|
-
* This composable lets components add or remove <body> classes in a way that:
|
|
5
|
-
* - SSR-safe (works with Nuxt `useHead` or manual DOM binding)
|
|
6
|
-
* - supports multiple components contributing classes
|
|
7
|
-
* - automatically removes classes on unmount (optional)
|
|
8
|
-
* - works in both Nuxt and plain Vue 3 apps
|
|
9
|
-
*
|
|
10
|
-
* Usage in Nuxt (in a layout):
|
|
11
|
-
* -------------------------------------
|
|
12
|
-
* import { useHead } from '#imports'
|
|
13
|
-
* import { useBodyClass } from '~/composables/useBodyClass'
|
|
14
|
-
*
|
|
15
|
-
* const { bodyClass } = useBodyClass()
|
|
16
|
-
*
|
|
17
|
-
* useHead({
|
|
18
|
-
* bodyAttrs: {
|
|
19
|
-
* class: bodyClass,
|
|
20
|
-
* },
|
|
21
|
-
* })
|
|
22
|
-
*
|
|
23
|
-
* Usage in a Nuxt page or component:
|
|
24
|
-
* -------------------------------------
|
|
25
|
-
* import { useBodyClass } from '~/composables/useBodyClass'
|
|
26
|
-
* const { addBodyClass } = useBodyClass()
|
|
27
|
-
* addBodyClass(['my-page', 'dark'], { autoCleanup: true })
|
|
28
|
-
*
|
|
29
|
-
* Usage in plain Vue 3 (non-Nuxt):
|
|
30
|
-
* -------------------------------------
|
|
31
|
-
* import { useBodyClass } from './composables/useBodyClass'
|
|
32
|
-
* import { watch } from 'vue'
|
|
33
|
-
*
|
|
34
|
-
* const { bodyClass } = useBodyClass()
|
|
35
|
-
*
|
|
36
|
-
* watch(bodyClass, (val) => {
|
|
37
|
-
* if (typeof document !== 'undefined') {
|
|
38
|
-
* document.body.className = val
|
|
39
|
-
* }
|
|
40
|
-
* }, { immediate: true })
|
|
41
|
-
*
|
|
42
|
-
* In a component:
|
|
43
|
-
* import { useBodyClass } from './composables/useBodyClass'
|
|
44
|
-
* const { addBodyClass } = useBodyClass()
|
|
45
|
-
* addBodyClass('fullscreen')
|
|
46
|
-
*/
|
|
47
|
-
|
|
48
|
-
import { useState } from '#app';
|
|
49
|
-
import { computed, onUnmounted } from 'vue';
|
|
50
|
-
|
|
51
|
-
export function useBodyClass() {
|
|
52
|
-
const _bodyClasses = useState('body-classes', () => new Set());
|
|
53
|
-
|
|
54
|
-
function normalize(input) {
|
|
55
|
-
return Array.isArray(input) ? input : [input];
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function addBodyClass(classNames, { autoCleanup = true } = {}) {
|
|
59
|
-
const classes = normalize(classNames);
|
|
60
|
-
|
|
61
|
-
classes.forEach(c => _bodyClasses.value.add(c));
|
|
62
|
-
|
|
63
|
-
if (autoCleanup) {
|
|
64
|
-
onUnmounted(() => {
|
|
65
|
-
classes.forEach(c => _bodyClasses.value.delete(c));
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function removeBodyClass(classNames) {
|
|
71
|
-
normalize(classNames).forEach(c => _bodyClasses.value.delete(c));
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function toggleBodyClass(className, condition) {
|
|
75
|
-
if (condition) {
|
|
76
|
-
_bodyClasses.value.add(className);
|
|
77
|
-
} else {
|
|
78
|
-
_bodyClasses.value.delete(className);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const bodyClass = computed(() => Array.from(_bodyClasses.value).join(' '));
|
|
83
|
-
|
|
84
|
-
return {
|
|
85
|
-
addBodyClass,
|
|
86
|
-
removeBodyClass,
|
|
87
|
-
toggleBodyClass,
|
|
88
|
-
bodyClass,
|
|
89
|
-
};
|
|
90
|
-
}
|