From 9df1ebac57498a292071db7939a41f8abe74b705 Mon Sep 17 00:00:00 2001 From: Dan Grebb Date: Tue, 26 Sep 2023 10:22:47 -0400 Subject: [PATCH] feat(front): disables all page transitions via --- front/src/lib/_utils/index.js | 8 ++++++++ front/src/lib/components/PageTransition.svelte | 6 +----- .../lib/components/TransitionElasticFly.svelte | 18 ++++++++++++++++-- front/src/lib/components/TransitionFade.svelte | 5 ++++- 4 files changed, 29 insertions(+), 8 deletions(-) diff --git a/front/src/lib/_utils/index.js b/front/src/lib/_utils/index.js index 400d3c162..560c760b5 100644 --- a/front/src/lib/_utils/index.js +++ b/front/src/lib/_utils/index.js @@ -31,3 +31,11 @@ export const isElementOutsideViewport = (element) => { rect.top > window.innerHeight ); }; + +/** + * Determine if a browser/system setting prefers reduced motion + * @returns boolean + */ +export const motionless = () => { + return window.matchMedia('(prefers-reduced-motion: reduce)').matches; +}; diff --git a/front/src/lib/components/PageTransition.svelte b/front/src/lib/components/PageTransition.svelte index 1466fe2dc..5e6903ca6 100644 --- a/front/src/lib/components/PageTransition.svelte +++ b/front/src/lib/components/PageTransition.svelte @@ -1,14 +1,10 @@ {#key transitionKey} @@ -56,8 +70,8 @@ class="transition-elastic-fly-container {classList ? classList : ''}" on:outrostart={animateOut} on:introstart={animateIn} - out:fly|global={{ x: -1000, duration, easing: circInOut }} - in:fly|global={{ x: -1000, duration, delay, easing: circInOut }} + out:motion|global={{ fn: fly, x: -1000, duration, easing: circInOut }} + in:motion|global={{ fn: fly, x: -1000, duration, delay, easing: circInOut }} > diff --git a/front/src/lib/components/TransitionFade.svelte b/front/src/lib/components/TransitionFade.svelte index ed70f43e9..5e65e7845 100644 --- a/front/src/lib/components/TransitionFade.svelte +++ b/front/src/lib/components/TransitionFade.svelte @@ -1,4 +1,5 @@