Skip to content

Commit a87a8db

Browse files
jeypcfemioladeji
authored andcommitted
Fix animate (#1)
* fix animate
1 parent fb42e36 commit a87a8db

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

src/fadezoom.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,11 @@ export const FadeZoom = React.forwardRef<SlideshowRef, ZoomProps>((props, ref) =
145145
}
146146
};
147147

148+
const animate = () => {
149+
requestAnimationFrame(animate);
150+
tweenGroup.current.update();
151+
};
152+
148153
const transitionSlide = (newIndex: number) => {
149154
const existingTweens = tweenGroup.current.getAll();
150155
if (!existingTweens.length) {
@@ -154,11 +159,6 @@ export const FadeZoom = React.forwardRef<SlideshowRef, ZoomProps>((props, ref) =
154159
clearTimeout(timeout.current);
155160
const value = { opacity: 0, scale: 1 };
156161

157-
const animate = () => {
158-
requestAnimationFrame(animate);
159-
tweenGroup.current.update();
160-
};
161-
162162
animate();
163163

164164
const tween = new TWEEN.Tween(value, tweenGroup.current)

src/slide.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,11 @@ export const Slide = React.forwardRef<SlideshowRef, SlideProps>((props, ref) =>
280280
}
281281
};
282282

283+
const animate = () => {
284+
requestAnimationFrame(animate);
285+
tweenGroup.current.update();
286+
};
287+
283288
const transitionSlide = (toIndex: number, animationDuration?: number) => {
284289
const transitionDuration = animationDuration || props.transitionDuration;
285290
const currentIndex = index;
@@ -302,10 +307,6 @@ export const Slide = React.forwardRef<SlideshowRef, SlideProps>((props, ref) =>
302307
})
303308
.start();
304309
tween.easing(getEasing(props.easing));
305-
const animate = () => {
306-
requestAnimationFrame(animate);
307-
tweenGroup.current.update();
308-
};
309310

310311
animate();
311312

0 commit comments

Comments
 (0)