diff --git a/src/components/molecules/grain-pull-to-refresh.js b/src/components/molecules/grain-pull-to-refresh.js index fc7fdef..24bb1fe 100644 --- a/src/components/molecules/grain-pull-to-refresh.js +++ b/src/components/molecules/grain-pull-to-refresh.js @@ -13,11 +13,17 @@ export class GrainPullToRefresh extends LitElement { static styles = css` :host { - display: block; + display: flex; + flex-direction: column; + flex: 1; overflow: hidden; + min-height: 100%; } .container { position: relative; + flex: 1; + display: flex; + flex-direction: column; } .indicator { position: absolute; diff --git a/src/components/pages/grain-app.js b/src/components/pages/grain-app.js index 4281240..d94861e 100644 --- a/src/components/pages/grain-app.js +++ b/src/components/pages/grain-app.js @@ -30,7 +30,8 @@ export class GrainApp extends LitElement { overflow: hidden; } #outlet { - display: block; + display: flex; + flex-direction: column; position: fixed; top: 48px; left: 0; @@ -39,6 +40,10 @@ export class GrainApp extends LitElement { overflow-y: auto; -webkit-overflow-scrolling: touch; } + #outlet > * { + flex: 0 0 auto; + min-height: 100%; + } `; firstUpdated() { diff --git a/src/components/pages/grain-copyright.js b/src/components/pages/grain-copyright.js index d59235b..2dfdc31 100644 --- a/src/components/pages/grain-copyright.js +++ b/src/components/pages/grain-copyright.js @@ -5,12 +5,12 @@ export class GrainCopyright extends LitElement { static styles = css` :host { display: block; + width: 100%; max-width: var(--feed-max-width); - margin: 0 auto; - min-height: 100vh; - min-height: 100dvh; + min-height: 100%; padding-bottom: 80px; background: var(--color-bg-primary); + align-self: center; } .header { display: flex; diff --git a/src/components/pages/grain-create-gallery.js b/src/components/pages/grain-create-gallery.js index 017bcf1..9044868 100644 --- a/src/components/pages/grain-create-gallery.js +++ b/src/components/pages/grain-create-gallery.js @@ -54,11 +54,11 @@ export class GrainCreateGallery extends LitElement { static styles = css` :host { display: block; + width: 100%; max-width: var(--feed-max-width); - margin: 0 auto; - min-height: 100vh; - min-height: 100dvh; + min-height: 100%; background: var(--color-bg-primary); + align-self: center; } .header { display: flex; diff --git a/src/components/pages/grain-edit-profile.js b/src/components/pages/grain-edit-profile.js index 5a26dbe..46996ec 100644 --- a/src/components/pages/grain-edit-profile.js +++ b/src/components/pages/grain-edit-profile.js @@ -48,12 +48,12 @@ export class GrainEditProfile extends LitElement { static styles = css` :host { display: block; + width: 100%; max-width: var(--feed-max-width); - margin: 0 auto; - min-height: 100vh; - min-height: 100dvh; + min-height: 100%; padding-bottom: 80px; background: var(--color-bg-primary); + align-self: center; } .header { display: flex; diff --git a/src/components/pages/grain-privacy.js b/src/components/pages/grain-privacy.js index 9e29ec1..7d1acd5 100644 --- a/src/components/pages/grain-privacy.js +++ b/src/components/pages/grain-privacy.js @@ -5,12 +5,12 @@ export class GrainPrivacy extends LitElement { static styles = css` :host { display: block; + width: 100%; max-width: var(--feed-max-width); - margin: 0 auto; - min-height: 100vh; - min-height: 100dvh; + min-height: 100%; padding-bottom: 80px; background: var(--color-bg-primary); + align-self: center; } .header { display: flex; diff --git a/src/components/pages/grain-profile.js b/src/components/pages/grain-profile.js index 0200d0b..e47fa6a 100644 --- a/src/components/pages/grain-profile.js +++ b/src/components/pages/grain-profile.js @@ -25,7 +25,9 @@ export class GrainProfile extends LitElement { static styles = css` :host { - display: block; + display: flex; + flex-direction: column; + min-height: 100%; } .error { padding: var(--space-lg); diff --git a/src/components/pages/grain-settings.js b/src/components/pages/grain-settings.js index 8f1b44c..f4d0042 100644 --- a/src/components/pages/grain-settings.js +++ b/src/components/pages/grain-settings.js @@ -12,12 +12,12 @@ export class GrainSettings extends LitElement { static styles = css` :host { display: block; + width: 100%; max-width: var(--feed-max-width); - margin: 0 auto; - min-height: 100vh; - min-height: 100dvh; + min-height: 100%; padding-bottom: 80px; background: var(--color-bg-primary); + align-self: center; } .header { display: flex; diff --git a/src/components/pages/grain-terms.js b/src/components/pages/grain-terms.js index f9a19ee..624262b 100644 --- a/src/components/pages/grain-terms.js +++ b/src/components/pages/grain-terms.js @@ -5,12 +5,12 @@ export class GrainTerms extends LitElement { static styles = css` :host { display: block; + width: 100%; max-width: var(--feed-max-width); - margin: 0 auto; - min-height: 100vh; - min-height: 100dvh; + min-height: 100%; padding-bottom: 80px; background: var(--color-bg-primary); + align-self: center; } .header { display: flex; diff --git a/src/components/templates/grain-feed-layout.js b/src/components/templates/grain-feed-layout.js index 91b9bac..70c8635 100644 --- a/src/components/templates/grain-feed-layout.js +++ b/src/components/templates/grain-feed-layout.js @@ -3,12 +3,17 @@ import { LitElement, html, css } from 'lit'; export class GrainFeedLayout extends LitElement { static styles = css` :host { - display: block; + display: flex; + flex-direction: column; + flex: 1; max-width: var(--feed-max-width); margin: 0 auto; min-height: 100%; background: var(--color-bg-primary); } + ::slotted(grain-pull-to-refresh) { + flex: 1; + } `; render() { diff --git a/src/router.js b/src/router.js index a9eae09..a3d6dcf 100644 --- a/src/router.js +++ b/src/router.js @@ -98,8 +98,8 @@ class Router { const pathname = location.pathname; // Save scroll position of current page before switching - if (this.#currentPath) { - this.#scrollCache.set(this.#currentPath, window.scrollY); + if (this.#currentPath && this.#outlet) { + this.#scrollCache.set(this.#currentPath, this.#outlet.scrollTop); } // Skip if same path @@ -130,7 +130,9 @@ class Router { cached.element.dispatchEvent(new CustomEvent('grain:activated')); // Restore scroll position after paint requestAnimationFrame(() => { - window.scrollTo(0, this.#scrollCache.get(pathname) || 0); + if (this.#outlet) { + this.#outlet.scrollTop = this.#scrollCache.get(pathname) || 0; + } }); return; } @@ -148,7 +150,9 @@ class Router { // Restore saved scroll position, or start at top for new pages requestAnimationFrame(() => { - window.scrollTo(0, this.#scrollCache.get(pathname) || 0); + if (this.#outlet) { + this.#outlet.scrollTop = this.#scrollCache.get(pathname) || 0; + } }); } }