Skip to content

Commit d7aa46c

Browse files
authored
Merge pull request #33 from swup/update-examples
Update animation examples
2 parents 6bc5bdd + 39fd7fb commit d7aa46c

File tree

1 file changed

+10
-18
lines changed

1 file changed

+10
-18
lines changed

README.md

+10-18
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,11 @@ Basic usage examples for a fade transition implemented in popular animation libr
141141
to: '(.*)',
142142
in: async () => {
143143
const container = document.querySelector('#swup');
144-
await container.animate([{ opacity: 0 }, { opacity: 1 }], 500).finished;
144+
await container.animate([{ opacity: 0 }, { opacity: 1 }], 250).finished;
145145
},
146146
out: async () => {
147147
const container = document.querySelector('#swup');
148-
await container.animate([{ opacity: 1 }, { opacity: 0 }], 500).finished;
148+
await container.animate([{ opacity: 1 }, { opacity: 0 }], 250).finished;
149149
}
150150
}
151151
```
@@ -156,15 +156,11 @@ Basic usage examples for a fade transition implemented in popular animation libr
156156
{
157157
from: '(.*)',
158158
to: '(.*)',
159-
out: (done) => {
160-
const container = document.querySelector('#swup');
161-
container.style.opacity = 1;
162-
gsap.to(container, { opacity: 0, duration: 0.5, onComplete: done });
159+
out: async () => {
160+
await gsap.to('#swup', { opacity: 0, duration: 0.25 });
163161
},
164-
in: (done) => {
165-
const container = document.querySelector('#swup');
166-
container.style.opacity = 0;
167-
gsap.to(container, { opacity: 1, duration: 0.5, onComplete: done });
162+
in: async () => {
163+
await gsap.fromTo('#swup', { opacity: 0 }, { opacity: 1, duration: 0.25 });
168164
}
169165
}
170166
```
@@ -175,15 +171,11 @@ Basic usage examples for a fade transition implemented in popular animation libr
175171
{
176172
from: '(.*)',
177173
to: '(.*)',
178-
out: (done) => {
179-
const container = document.querySelector('#swup');
180-
container.style.opacity = 1;
181-
anime({ targets: container, opacity: 0, duration: 500, complete: done });
174+
out: async () => {
175+
await anime({ targets: '#swup', opacity: 0, duration: 250, easing: 'linear' }).finished;
182176
},
183-
in: (done) => {
184-
const container = document.querySelector('#swup');
185-
container.style.opacity = 0;
186-
anime({ targets: container, opacity: 1, duration: 500, complete: done });
177+
in: async () => {
178+
await anime({ targets: '#swup', opacity: [0, 1], duration: 250, easing: 'linear' }).finished;
187179
}
188180
}
189181
```

0 commit comments

Comments
 (0)