@@ -20,27 +20,27 @@ yarn add svelte-transitioner
20
20
This plugin adds the following hooks:
21
21
- ` onGlobalInit ` : a hook responsible for executing custom code when mounting any of the child components
22
22
- ` onInit ` : a hook responsible for executing custom code on the current component
23
- - ` onGlobalEnter ` : a hook that can execute the same custom transition when mounting any of the child components
24
- - ` onEnter ` : a hook that can execute a transition when mounting a component
25
- - ` onGlobalLeave ` : a hook that can execute the same custom transition when unmounting any of the child components
26
- - ` onLeave ` : a hook that can execute a transition when unmounting a component
23
+ - ` globalIntro ` : a hook that can execute the same custom transition when mounting any of the child components
24
+ - ` intro ` : a hook that can execute a transition when mounting a component
25
+ - ` globalOutro ` : a hook that can execute the same custom transition when unmounting any of the child components
26
+ - ` outro ` : a hook that can execute a transition when unmounting a component
27
27
28
28
for the ` on*Init ` hooks, they will be called like the following:
29
29
``` Javascript
30
30
onInit ((node ) => {
31
31
// node is the current mounted node
32
32
})
33
33
```
34
- as for the ` on*Enter ` or ` on*Leave ` , it can be called in two ways:
34
+ as for the ` *intro ` or ` *outro ` callbacks , it can be used in two ways:
35
35
``` Javascript
36
- onEnter ((node , t ) => {
36
+ intro ((node , t ) => {
37
37
// node is the current mounted node
38
38
// t is the current transition animation
39
39
// 1000 is the duration of the transition
40
40
}, 1000 )
41
41
42
42
// Or you can use a GSAP Timeline callback instead, like the following
43
- onGlobalEnter ((node ) => {
43
+ intro ((node ) => {
44
44
const tl = gsap .timeline ({
45
45
paused: true
46
46
})
@@ -63,15 +63,15 @@ So for example in a SvelteKit project, we can have the following:
63
63
` /routes/__layout.svelte ` :
64
64
``` Svelte
65
65
<script>
66
- import { onGlobalInit, onGlobalEnter, onGlobalLeave , TransitionLayout } from 'svelte-transitioner'
66
+ import { onGlobalInit, globalIntro, globalOutro , TransitionLayout } from 'svelte-transitioner'
67
67
68
68
onGlobalInit((node) => {
69
69
70
70
})
71
- onGlobalEnter ((node) => {
71
+ globalIntro ((node) => {
72
72
return gsap.timeline({ paused: true })
73
73
})
74
- onGlobalLeave ((node, t) => {
74
+ globalOutro ((node, t) => {
75
75
76
76
})
77
77
</script>
@@ -82,15 +82,15 @@ So for example in a SvelteKit project, we can have the following:
82
82
` /routes/index.svelte ` :
83
83
``` Svelte
84
84
<script>
85
- import { onInit, onEnter, onLeave , Transitioner } from 'svelte-transitioner'
85
+ import { onInit, intro, outro , Transitioner } from 'svelte-transitioner'
86
86
87
87
onInit((node) => {
88
88
89
89
})
90
- onEnter ((node) => {
90
+ intro ((node) => {
91
91
return gsap.timeline({ paused: true })
92
92
})
93
- onLeave ((node, t) => {
93
+ outro ((node, t) => {
94
94
95
95
})
96
96
</script>
@@ -102,15 +102,15 @@ So for example in a SvelteKit project, we can have the following:
102
102
` /routes/one.svelte ` :
103
103
``` Svelte
104
104
<script>
105
- import { onInit, onEnter, onLeave , Transitioner } from 'svelte-transitioner'
105
+ import { onInit, intro, outro , Transitioner } from 'svelte-transitioner'
106
106
107
107
onInit((node) => {
108
108
109
109
})
110
- onEnter ((node) => {
110
+ intro ((node) => {
111
111
return gsap.timeline({ paused: true })
112
112
})
113
- onLeave ((node, t) => {
113
+ outro ((node, t) => {
114
114
115
115
})
116
116
</script>
0 commit comments