TitleSite: Fix longer delay after first transition
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-04-21 15:05:33 +02:00
parent 5b4fe1c6d6
commit ecc69e3206
3 changed files with 21 additions and 11 deletions

View File

@@ -1,7 +1,9 @@
import anime from 'animejs' import anime from 'animejs'
import ScrollOut from 'scroll-out' import ScrollOut from 'scroll-out'
import { animDelay } from 'utils/store' import { firstLoad, animDurationLong, animDelay } from 'utils/store'
let firstLoadValue
firstLoad.subscribe(store => firstLoadValue = store)
/* /*
** Transition In ** Transition In
@@ -14,7 +16,7 @@ export const animateIn = (scope, init) => {
translateZ: [0, 0], translateZ: [0, 0],
easing: 'easeOutQuart', easing: 'easeOutQuart',
duration: 1000, duration: 1000,
delay: anime.stagger(40, { start: init ? 0 : animDelay }), delay: anime.stagger(40, { start: init ? 0 : (firstLoadValue) ? animDurationLong : animDelay }),
autoplay: false autoplay: false
}) })
@@ -22,6 +24,9 @@ export const animateIn = (scope, init) => {
const title = ScrollOut({ const title = ScrollOut({
once: true, once: true,
targets: scope, targets: scope,
onShown: () => letters.restart() onShown: () => {
console.log('TitleSite show')
letters.restart()
}
}) })
} }

View File

@@ -5,9 +5,11 @@
import { import {
pageReady, pageReady,
pageAnimation, pageAnimation,
firstLoad,
animDuration, animDuration,
animDelay, animDelay,
animPanelDelay animPanelDelay,
animPanelShortDelay
} from 'utils/store' } from 'utils/store'
// Components // Components
import TitleSite from 'atoms/TitleSite' import TitleSite from 'atoms/TitleSite'
@@ -20,7 +22,6 @@
$: animateIn = $pageAnimation $: animateIn = $pageAnimation
let scope let scope
let show = false let show = false
let firstLoad = true
let previousPage = '' let previousPage = ''
// Check if path is excluded // Check if path is excluded
@@ -31,7 +32,9 @@
// Show transition if page is not excluded // Show transition if page is not excluded
if (!isExcluded(previousPage) || !isExcluded(page.path)) { if (!isExcluded(previousPage) || !isExcluded(page.path)) {
pageReady.set(false) pageReady.set(false)
process.browser && requestAnimationFrame(() => show = false) process.browser && requestAnimationFrame(() => {
show = false
})
} }
// Update page for viewer navigation checking // Update page for viewer navigation checking
@@ -45,12 +48,12 @@
// Show transition // Show transition
show = true show = true
// Run the page animation // Run the page animation
process.browser && requestAnimationFrame(() => animateIn()) process.browser && requestAnimationFrame(animateIn)
// Change loader icon as the loader shown already // Change loader icon as the loader shown already
firstLoad = false firstLoad.set(false)
// Scroll to page top // Scroll to page top
window.scrollTo(0,0) window.scrollTo(0,0)
}, firstLoad ? animPanelDelay : 600) }, $firstLoad ? animPanelDelay : animPanelShortDelay)
} }
}) })
</script> </script>
@@ -61,7 +64,7 @@
in:fly={{ y: 24, duration: 800, easing: quartOut }} in:fly={{ y: 24, duration: 800, easing: quartOut }}
out:fly={{ y: -window.innerHeight/2, duration: animDuration, easing: quartInOut }} out:fly={{ y: -window.innerHeight/2, duration: animDuration, easing: quartInOut }}
> >
{#if firstLoad} {#if $firstLoad}
<TitleSite init={true} /> <TitleSite init={true} />
{:else} {:else}
<IconGlobe width="44" color="#fff" animated="true" /> <IconGlobe width="44" color="#fff" animated="true" />

View File

@@ -24,15 +24,17 @@ export let currentLocation = writable()
export let currentPhotos = writable() export let currentPhotos = writable()
// State // State
export let pageReady = writable(false, () => {})
export let fullscreen = writable(undefined, () => {}) export let fullscreen = writable(undefined, () => {})
/* ========================================================================== /* ==========================================================================
Animation related Animation related
========================================================================== */ ========================================================================== */
export let firstLoad = writable(true, () => {})
export let pageReady = writable(false, () => {})
export let pageAnimation = writable(() => {}, () => {}) export let pageAnimation = writable(() => {}, () => {})
export const animDelay = 900 export const animDelay = 900
export const animPanelDelay = 900 export const animPanelDelay = 900
export const animPanelShortDelay = 600
export const animDuration = 1400 export const animDuration = 1400
export const animDurationLong = 1800 export const animDurationLong = 1800