From c139df8fdfc5c9f1053abc488f13d1b373715329 Mon Sep 17 00:00:00 2001 From: kdxcxs Date: Sun, 6 Dec 2020 13:34:01 +0800 Subject: [PATCH] fix(YooBackground): make background image also move in the first 10 seconds --- src/ui/YooBackground.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/ui/YooBackground.js b/src/ui/YooBackground.js index df8a9a6..ae44fbf 100644 --- a/src/ui/YooBackground.js +++ b/src/ui/YooBackground.js @@ -10,6 +10,17 @@ export default function YooBackground() { zIndex: -1, }, }); + // The animation won't play for the first 10 seconds + // if we just use setInterval. So we start the animation + // at the component mounted just for the first 10 seconds. + Animated.timing(imgPosition, { + toValue: { + x: -Math.floor(Math.random() * 5000), + y: -Math.floor(Math.random() * 3000), + }, + duration: 10000, + useNativeDriver: true, + }).start(); setInterval(() => { Animated.timing(imgPosition, { toValue: {