@noction/vue-bezier 1.0.5
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/README.md +109 -0
- package/dist/Collapse/CollapseTransition.vue.d.ts +14 -0
- package/dist/Fade/FadeTransition.vue.d.ts +13 -0
- package/dist/Scale/ScaleTransition.vue.d.ts +26 -0
- package/dist/Slide/SlideXLeftTransition.vue.d.ts +22 -0
- package/dist/Slide/SlideXRightTransition.vue.d.ts +22 -0
- package/dist/Slide/SlideYDownTransition.vue.d.ts +22 -0
- package/dist/Slide/SlideYUpTransition.vue.d.ts +22 -0
- package/dist/Zoom/ZoomCenterTransition.vue.d.ts +13 -0
- package/dist/Zoom/ZoomUpTransition.vue.d.ts +22 -0
- package/dist/Zoom/ZoomXTransition.vue.d.ts +22 -0
- package/dist/Zoom/ZoomYTransition.vue.d.ts +22 -0
- package/dist/composable/buildComponentType.d.ts +3 -0
- package/dist/composable/buildEmits.d.ts +2 -0
- package/dist/composable/buildHooks.d.ts +7 -0
- package/dist/composable/buildProps.d.ts +48 -0
- package/dist/composable/buildTag.d.ts +2 -0
- package/dist/composable/index.d.ts +6 -0
- package/dist/index.d.ts +17 -0
- package/dist/style.css +1 -0
- package/dist/vue-bezier.mjs +456 -0
- package/dist/vue-bezier.umd.js +1 -0
- package/dist/web-types.json +156 -0
- package/package.json +63 -0
- package/src/components/Collapse/CollapseTransition.vue +122 -0
- package/src/components/Fade/FadeTransition.vue +52 -0
- package/src/components/Scale/ScaleTransition.vue +76 -0
- package/src/components/Slide/SlideXLeftTransition.vue +73 -0
- package/src/components/Slide/SlideXRightTransition.vue +73 -0
- package/src/components/Slide/SlideYDownTransition.vue +72 -0
- package/src/components/Slide/SlideYUpTransition.vue +74 -0
- package/src/components/Slide/move.scss +1 -0
- package/src/components/Zoom/ZoomCenterTransition.vue +63 -0
- package/src/components/Zoom/ZoomUpTransition.vue +75 -0
- package/src/components/Zoom/ZoomXTransition.vue +75 -0
- package/src/components/Zoom/ZoomYTransition.vue +78 -0
- package/src/components/Zoom/move.scss +1 -0
- package/src/composable/buildComponentType.ts +4 -0
- package/src/composable/buildEmits.ts +7 -0
- package/src/composable/buildHooks.ts +92 -0
- package/src/composable/buildProps.ts +52 -0
- package/src/composable/buildTag.ts +1 -0
- package/src/composable/index.ts +7 -0
- package/src/global-shim.d.ts +1 -0
- package/src/index.ts +62 -0
- package/src/vue-shim.d.ts +5 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<component
|
|
3
|
+
:is="componentType"
|
|
4
|
+
:tag="tag"
|
|
5
|
+
enter-active-class="zoom-in-x"
|
|
6
|
+
move-class="zoom-move"
|
|
7
|
+
leave-active-class="zoom-out-x"
|
|
8
|
+
v-bind="{ ...$attrs, ...hooks }"
|
|
9
|
+
>
|
|
10
|
+
<slot />
|
|
11
|
+
</component>
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<script lang="ts">
|
|
15
|
+
export const customProps = {
|
|
16
|
+
styles: {
|
|
17
|
+
default: () => {
|
|
18
|
+
return {
|
|
19
|
+
animationFillMode: 'both',
|
|
20
|
+
animationTimingFunction: 'cubic-bezier(.55,0,.1,1)'
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
type: Object
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export default {
|
|
28
|
+
inheritAttrs: false
|
|
29
|
+
}
|
|
30
|
+
</script>
|
|
31
|
+
|
|
32
|
+
<script setup lang="ts">
|
|
33
|
+
import {
|
|
34
|
+
buildComponentType,
|
|
35
|
+
buildEmits,
|
|
36
|
+
buildHooks,
|
|
37
|
+
buildProps,
|
|
38
|
+
buildTag
|
|
39
|
+
} from '../../composable'
|
|
40
|
+
|
|
41
|
+
const props = defineProps(buildProps(customProps))
|
|
42
|
+
const emit = defineEmits(buildEmits())
|
|
43
|
+
|
|
44
|
+
const componentType = buildComponentType(props)
|
|
45
|
+
const tag = buildTag(props)
|
|
46
|
+
const hooks = buildHooks(props, emit)
|
|
47
|
+
|
|
48
|
+
</script>
|
|
49
|
+
|
|
50
|
+
<style lang="scss">
|
|
51
|
+
@import 'move';
|
|
52
|
+
|
|
53
|
+
@keyframes zoom-in-x {
|
|
54
|
+
0% {
|
|
55
|
+
opacity: 0;
|
|
56
|
+
transform: scaleX(0);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
50% { opacity: 1; }
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
@keyframes zoom-out-x {
|
|
63
|
+
0% { opacity: 1; }
|
|
64
|
+
|
|
65
|
+
50% {
|
|
66
|
+
opacity: 0;
|
|
67
|
+
transform: scaleX(0);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
100% { opacity: 0; }
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.zoom-in-x { animation-name: zoom-in-x; }
|
|
74
|
+
.zoom-out-x { animation-name: zoom-out-x; }
|
|
75
|
+
</style>
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<component
|
|
3
|
+
:is="componentType"
|
|
4
|
+
:tag="tag"
|
|
5
|
+
enter-active-class="zoom-in-y"
|
|
6
|
+
move-class="zoom-move"
|
|
7
|
+
leave-active-class="zoom-out-y"
|
|
8
|
+
v-bind="{ ...$attrs, ...hooks }"
|
|
9
|
+
>
|
|
10
|
+
<slot />
|
|
11
|
+
</component>
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<script lang="ts">
|
|
15
|
+
export const customProps = {
|
|
16
|
+
styles: {
|
|
17
|
+
default: () => {
|
|
18
|
+
return {
|
|
19
|
+
animationFillMode: 'both',
|
|
20
|
+
animationTimingFunction: 'cubic-bezier(.55,0,.1,1)'
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
type: Object
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export default {
|
|
28
|
+
inheritAttrs: false
|
|
29
|
+
}
|
|
30
|
+
</script>
|
|
31
|
+
|
|
32
|
+
<script setup lang="ts">
|
|
33
|
+
import {
|
|
34
|
+
buildComponentType,
|
|
35
|
+
buildEmits,
|
|
36
|
+
buildHooks,
|
|
37
|
+
buildProps,
|
|
38
|
+
buildTag
|
|
39
|
+
} from '../../composable'
|
|
40
|
+
|
|
41
|
+
const props = defineProps(buildProps(customProps))
|
|
42
|
+
const emit = defineEmits(buildEmits())
|
|
43
|
+
|
|
44
|
+
const componentType = buildComponentType(props)
|
|
45
|
+
const tag = buildTag(props)
|
|
46
|
+
const hooks = buildHooks(props, emit)
|
|
47
|
+
|
|
48
|
+
</script>
|
|
49
|
+
|
|
50
|
+
<style lang="scss">
|
|
51
|
+
@import 'move';
|
|
52
|
+
|
|
53
|
+
@keyframes zoom-in-y {
|
|
54
|
+
0% {
|
|
55
|
+
opacity: 0;
|
|
56
|
+
transform: scaleY(0);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
50% {
|
|
60
|
+
opacity: 1;
|
|
61
|
+
transform: scaleY(1);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
@keyframes zoom-out-y {
|
|
66
|
+
0% { opacity: 1; }
|
|
67
|
+
|
|
68
|
+
50% {
|
|
69
|
+
opacity: 0;
|
|
70
|
+
transform: scaleY(0);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
100% { opacity: 0; }
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.zoom-in-y { animation-name: zoom-in-y; }
|
|
77
|
+
.zoom-out-y { animation-name: zoom-out-y; }
|
|
78
|
+
</style>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.zoom-move { transition: transform .3s ease-out; }
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { BaseTransitionProps, RendererElement } from 'vue'
|
|
2
|
+
|
|
3
|
+
const beforeEnter = (props, el: RendererElement) => {
|
|
4
|
+
const enterDuration = props.duration?.enter ?? props.duration ?? 0
|
|
5
|
+
const enterDelay = props.delay?.enter ?? props.delay ?? 0
|
|
6
|
+
|
|
7
|
+
el.style.animationDuration = `${enterDuration}ms`
|
|
8
|
+
el.style.animationDelay = `${enterDelay}ms`
|
|
9
|
+
|
|
10
|
+
setStyles(props, el)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const beforeLeave = (props, el: RendererElement) => {
|
|
14
|
+
const leaveDuration = props.duration?.leave ?? props.duration ?? 0
|
|
15
|
+
const leaveDelay = props.delay?.leave ?? props.delay ?? 0
|
|
16
|
+
|
|
17
|
+
el.style.animationDuration = `${leaveDuration}ms`
|
|
18
|
+
el.style.animationDelay = `${leaveDelay}ms`
|
|
19
|
+
|
|
20
|
+
setStyles(props, el)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const cleanUpStyles = (props, el: RendererElement) => {
|
|
24
|
+
Object
|
|
25
|
+
.keys(props.styles)
|
|
26
|
+
.forEach(key => {
|
|
27
|
+
const styleValue = props.styles[key]
|
|
28
|
+
|
|
29
|
+
if (styleValue) el.style[key] = ''
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
el.style.animationDuration = ''
|
|
33
|
+
el.style.animationDelay = ''
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const leave = (props, el: RendererElement, done: () => void) => {
|
|
37
|
+
setAbsolutePosition(props, el)
|
|
38
|
+
|
|
39
|
+
const leaveDuration = props.duration?.leave ?? props.duration ?? 0
|
|
40
|
+
const leaveDelay = props.delay?.leave ?? props.delay ?? 0
|
|
41
|
+
|
|
42
|
+
setTimeout(done, leaveDuration + leaveDelay)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const setStyles = (props, el: RendererElement) => {
|
|
46
|
+
setTransformOrigin(props, el)
|
|
47
|
+
|
|
48
|
+
Object
|
|
49
|
+
.keys(props.styles)
|
|
50
|
+
.forEach(key => {
|
|
51
|
+
const styleValue = props.styles[key]
|
|
52
|
+
|
|
53
|
+
if (styleValue) el.style[key] = styleValue
|
|
54
|
+
})
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const setAbsolutePosition = (props, el: RendererElement) => {
|
|
58
|
+
if (props.group) el.style.position = 'absolute'
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const setTransformOrigin = (props, el: RendererElement) => {
|
|
62
|
+
if (props.origin) el.style.transformOrigin = props.origin
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export default (props, emit): BaseTransitionProps => ({
|
|
66
|
+
onAfterEnter: (el: RendererElement) => {
|
|
67
|
+
cleanUpStyles(props, el)
|
|
68
|
+
emit('after-enter', el)
|
|
69
|
+
},
|
|
70
|
+
onAfterLeave: (el: RendererElement) => {
|
|
71
|
+
cleanUpStyles(props, el)
|
|
72
|
+
emit('after-leave', el)
|
|
73
|
+
},
|
|
74
|
+
onBeforeEnter: (el: RendererElement) => {
|
|
75
|
+
beforeEnter(props, el)
|
|
76
|
+
emit('before-enter', el)
|
|
77
|
+
},
|
|
78
|
+
onBeforeLeave: (el: RendererElement) => {
|
|
79
|
+
beforeLeave(props, el)
|
|
80
|
+
emit('before-leave', el)
|
|
81
|
+
},
|
|
82
|
+
onLeave: (el: RendererElement, done: () => void) => {
|
|
83
|
+
leave(props, el, done)
|
|
84
|
+
emit('leave', el, done)
|
|
85
|
+
}
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
export {
|
|
89
|
+
leave,
|
|
90
|
+
setAbsolutePosition,
|
|
91
|
+
setStyles
|
|
92
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
const defaultProps = {
|
|
2
|
+
/**
|
|
3
|
+
* Transition delay. Number for specifying the same delay for enter/leave transitions
|
|
4
|
+
* Object style {enter: 300, leave: 300} for specifying explicit durations for enter/leave
|
|
5
|
+
*/
|
|
6
|
+
delay: {
|
|
7
|
+
default: 0,
|
|
8
|
+
type: [Number, Object]
|
|
9
|
+
},
|
|
10
|
+
/**
|
|
11
|
+
* Transition duration. Number for specifying the same duration for enter/leave transitions
|
|
12
|
+
* Object style {enter: 300, leave: 300} for specifying explicit durations for enter/leave
|
|
13
|
+
*/
|
|
14
|
+
duration: {
|
|
15
|
+
default: 300,
|
|
16
|
+
type: [Number, Object]
|
|
17
|
+
},
|
|
18
|
+
/**
|
|
19
|
+
* Whether the component should be a `transition-group` component.
|
|
20
|
+
*/
|
|
21
|
+
group: Boolean,
|
|
22
|
+
/**
|
|
23
|
+
* Transform origin property https://tympanus.net/codrops/css_reference/transform-origin/.
|
|
24
|
+
* Can be specified with styles as well but it's shorter with this prop
|
|
25
|
+
*/
|
|
26
|
+
origin: {
|
|
27
|
+
default: '',
|
|
28
|
+
type: String
|
|
29
|
+
},
|
|
30
|
+
/**
|
|
31
|
+
* Element styles that are applied during transition. These styles are applied on @beforeEnter and @beforeLeave hooks
|
|
32
|
+
*/
|
|
33
|
+
styles: {
|
|
34
|
+
default: () => ({
|
|
35
|
+
animationFillMode: 'both',
|
|
36
|
+
animationTimingFunction: 'ease-out'
|
|
37
|
+
}),
|
|
38
|
+
type: Object
|
|
39
|
+
},
|
|
40
|
+
/**
|
|
41
|
+
* Transition tag, in case the component is a `transition-group`
|
|
42
|
+
*/
|
|
43
|
+
tag: {
|
|
44
|
+
default: 'span',
|
|
45
|
+
type: String
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export default (customProps?: Record<string, unknown>) => ({
|
|
50
|
+
...defaultProps,
|
|
51
|
+
...(customProps || {})
|
|
52
|
+
})
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default props => props.tag
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import buildComponentType from './buildComponentType'
|
|
2
|
+
import buildEmits from './buildEmits'
|
|
3
|
+
import buildHooks from './buildHooks'
|
|
4
|
+
import buildProps from './buildProps'
|
|
5
|
+
import buildTag from './buildTag'
|
|
6
|
+
|
|
7
|
+
export { buildComponentType, buildEmits, buildHooks, buildProps, buildTag }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
declare const VERSION: string
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import PrivateCollapseTransition from './components/Collapse/CollapseTransition.vue'
|
|
2
|
+
|
|
3
|
+
import PrivateFadeTransition from './components/Fade/FadeTransition.vue'
|
|
4
|
+
|
|
5
|
+
import PrivateScaleTransition from './components/Scale/ScaleTransition.vue'
|
|
6
|
+
|
|
7
|
+
import PrivateSlideXLeftTransition from './components/Slide/SlideXLeftTransition.vue'
|
|
8
|
+
import PrivateSlideXRightTransition from './components/Slide/SlideXRightTransition.vue'
|
|
9
|
+
import PrivateSlideYDownTransition from './components/Slide/SlideYDownTransition.vue'
|
|
10
|
+
import PrivateSlideYUpTransition from './components/Slide/SlideYUpTransition.vue'
|
|
11
|
+
|
|
12
|
+
import PrivateZoomCenterTransition from './components/Zoom/ZoomCenterTransition.vue'
|
|
13
|
+
import PrivateZoomUpTransition from './components/Zoom/ZoomUpTransition.vue'
|
|
14
|
+
import PrivateZoomXTransition from './components/Zoom/ZoomXTransition.vue'
|
|
15
|
+
import PrivateZoomYTransition from './components/Zoom/ZoomYTransition.vue'
|
|
16
|
+
|
|
17
|
+
const components = {
|
|
18
|
+
CollapseTransition: PrivateCollapseTransition,
|
|
19
|
+
FadeTransition: PrivateFadeTransition,
|
|
20
|
+
ScaleTransition: PrivateScaleTransition,
|
|
21
|
+
SlideXLeftTransition: PrivateSlideXLeftTransition,
|
|
22
|
+
SlideXRightTransition: PrivateSlideXRightTransition,
|
|
23
|
+
SlideYDownTransition: PrivateSlideYDownTransition,
|
|
24
|
+
SlideYUpTransition: PrivateSlideYUpTransition,
|
|
25
|
+
ZoomCenterTransition: PrivateZoomCenterTransition,
|
|
26
|
+
ZoomUpTransition: PrivateZoomUpTransition,
|
|
27
|
+
ZoomXTransition: PrivateZoomXTransition,
|
|
28
|
+
ZoomYTransition: PrivateZoomYTransition
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export {
|
|
32
|
+
PrivateCollapseTransition as CollapseTransition,
|
|
33
|
+
PrivateFadeTransition as FadeTransition,
|
|
34
|
+
PrivateScaleTransition as ScaleTransition,
|
|
35
|
+
PrivateSlideXLeftTransition as SlideXLeftTransition,
|
|
36
|
+
PrivateSlideXRightTransition as SlideXRightTransition,
|
|
37
|
+
PrivateSlideYDownTransition as SlideYDownTransition,
|
|
38
|
+
PrivateSlideYUpTransition as SlideYUpTransition,
|
|
39
|
+
PrivateZoomCenterTransition as ZoomCenterTransition,
|
|
40
|
+
PrivateZoomUpTransition as ZoomUpTransition,
|
|
41
|
+
PrivateZoomXTransition as ZoomXTransition,
|
|
42
|
+
PrivateZoomYTransition as ZoomYTransition
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function install (app) {
|
|
46
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
47
|
+
// @ts-ignore
|
|
48
|
+
if (app.$_v3SFCTransitionsInstalled) return
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
50
|
+
// @ts-ignore
|
|
51
|
+
app.$_v3SFCTransitionsInstalled = true
|
|
52
|
+
|
|
53
|
+
Object
|
|
54
|
+
.entries(components)
|
|
55
|
+
.forEach(([key, component]) =>
|
|
56
|
+
app.component(key, component)
|
|
57
|
+
)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export default {
|
|
61
|
+
install
|
|
62
|
+
}
|