From 39124ccc70312c693842070931e53ea6b280215c Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Mon, 2 Jan 2023 21:36:24 +0800 Subject: [PATCH] Add experimental scroll-based effects - Scroll to top = refresh Home - Scroll up/down = show/hide header and compose button - Scroll near bottom = load next statuses - Move Compose button to only at Home instead of 'App' level --- src/app.css | 21 +++++++++++++++- src/app.jsx | 31 +++++------------------ src/pages/home.jsx | 57 +++++++++++++++++++++++++++++++++++++----- src/utils/useScroll.js | 35 ++++++++++++++++++++++++++ 4 files changed, 112 insertions(+), 32 deletions(-) create mode 100644 src/utils/useScroll.js diff --git a/src/app.css b/src/app.css index 361586c0..62ba9ccc 100644 --- a/src/app.css +++ b/src/app.css @@ -90,6 +90,13 @@ a.mention span { grid-template-columns: 1fr 1fr 1fr; align-items: center; user-select: none; + transition: transform 0.5s ease-in-out; +} +.deck header[hidden] { + transform: translateY(-100%); + opacity: 0; + pointer-events: none; + user-select: none; } .deck header > .header-side:last-of-type { text-align: right; @@ -350,6 +357,7 @@ a.mention span { color: inherit; transition: background-color 0.2s ease-out; -webkit-tap-highlight-color: transparent; + animation: appear 0.2s ease-out; } .status-link:is(:hover, :focus) { background-color: var(--link-bg-hover-color); @@ -600,7 +608,18 @@ button.carousel-dot[disabled].active { z-index: 1; box-shadow: 0 3px 8px -1px var(--bg-faded-blur-color), 0 10px 36px -4px var(--button-bg-blur-color); - transition: background-color 0.2s ease-in-out; + transition: all 0.3s ease-in-out; +} +#compose-button[hidden] { + transform: translateY(150%); + pointer-events: none; + user-select: none; +} +#compose-button .icon { + transition: transform 0.3s ease-in-out; +} +#compose-button[hidden] .icon { + transform: rotate(90deg); } #compose-button:is(:hover, :focus) { background-color: var(--button-bg-color); diff --git a/src/app.jsx b/src/app.jsx index 034bc929..903f8d3c 100644 --- a/src/app.jsx +++ b/src/app.jsx @@ -177,31 +177,12 @@ function App() { return ( <> {isLoggedIn && currentDeck && ( - <> - -
- {/* Home will never be unmounted */} -
- +
+ {/* Home will never be unmounted */} +
)} {!isLoggedIn && uiState === 'loading' && }