diff --git a/README.md b/README.md index 181e63c..9376fc3 100644 --- a/README.md +++ b/README.md @@ -32,8 +32,7 @@ An unofficial add-on for the Next.js App Router. It draws slide transitions betw - Edge-swipe Back (`swipeBack`) with a preview of the previous screen. - Scroll offset restored per history entry (`preserveScroll`). - Document scrolling by default (`window.scrollTo`, `window.scrollY` keep working); an independent scroll container also works (`scrollTarget`). -- `appShell`: the provider fills the viewport, the document never scrolls, and only the content area (or each page's `scrollTarget`) scrolls. Header and footer slots are optional. -- The browser's own scrollbar is hidden on ``, `` and the scroll areas; the drawn scrollbar replaces it. +- Only the scrollbar changes, never the scroller: the document still scrolls, so `window.scrollTo`, `window.scrollY`, `scrollTop` and `scroll` events behave as without the package. The browser's own scrollbar is hidden on `` and ``, and the drawn scrollbar replaces it. - A vertical scrollbar drawn with [OverlayScrollbars](https://github.com/KingSora/OverlayScrollbars): its track stays between fixed headers, footers and tab bars, follows whichever scroller is moving, and can be dragged or clicked. - `edgeBounce`: optional touch bounce at scroll boundaries on non-Apple touch devices. - `skipSlideQueryKeys`: skip the page slide when only a popup query parameter changes. diff --git a/docs/REFERENCE.md b/docs/REFERENCE.md index 9ec5242..a2d9ec2 100644 --- a/docs/REFERENCE.md +++ b/docs/REFERENCE.md @@ -303,36 +303,6 @@ The scroll offset and native scroll range stay at the boundary. The effect respects reduced motion. Keep fixed bars outside the moving surface, for example as siblings of `scrollTarget` or in the provider slots. -### Run as an app shell - -Set `appShell` to make the provider fill the viewport like a native app. The -document stops scrolling, so the browser never shows a scrollbar on `` or -``. The `header`, `persistent` and `footer` slots stay put, and only the -content area between them scrolls, with the drawn scrollbar inside that area. -Leave out `header` and `footer` and let each page render its own bars, then -point `scrollTarget` at the page's scrolling area. `appShell` implies -`scrollMode="container"`. - -```tsx -// Shared bars from the layout -} footer={}> - {children} - - -// Or bars owned by each page - - {children} - -// app/detail/page.tsx -
-
…
-
…
-
-``` - -Without `appShell`, window mode also hides the native scrollbar on `` -and `` and draws its own, but the document itself keeps scrolling. - ### Use an independent scroll container Set `scrollMode="container"` to keep scrolling inside a bounded provider. diff --git a/examples/next-app/app/with/layout.tsx b/examples/next-app/app/with/layout.tsx index 08b3ef8..d6e2813 100644 --- a/examples/next-app/app/with/layout.tsx +++ b/examples/next-app/app/with/layout.tsx @@ -10,7 +10,7 @@ const modalRoutes = stays.map(stay => `/with/stay/${stay.id}/book`); export default function WithLayout({children}: {children: ReactNode}) { return
- } footer={}> + } footer={}> {children}
diff --git a/src/next/index.tsx b/src/next/index.tsx index 9b601b7..bbf0bed 100644 --- a/src/next/index.tsx +++ b/src/next/index.tsx @@ -44,12 +44,6 @@ export interface StackflowProviderProps { preserveScroll?: boolean; /** Scroll the browser document or a provider-owned container. Defaults to 'window'. */ scrollMode?: 'container' | 'window'; - /** - * Fill the viewport like a native app. The document stops scrolling, so no - * browser scrollbar appears on or ; each page scrolls its own - * `scrollTarget` area. Implies `scrollMode="container"`. Defaults to false. - */ - appShell?: boolean; /** Select a scroll container, or the scrollbar's display area in window mode. */ scrollTarget?: string; /** Add touch-only bounce where Apple-style native rubber-banding is unavailable. */ @@ -78,8 +72,7 @@ export interface StackflowProviderProps { className?: string; style?: CSSProperties; } -export function StackflowProvider({children,header,footer,persistent,animation='ios',preserveScroll=true,scrollMode: requestedScrollMode='window',appShell=false,scrollTarget,edgeBounce=false,fixedTargets,modalRoutes,transitionRoutes,skipSlideQueryKeys,transitionTarget,swipeBack=false,maxEntries=32,navigationTimeout=4000,waitForPage=false,skeletonRoutes,loading,locale,className='',style}: StackflowProviderProps) { - const scrollMode = appShell ? 'container' : requestedScrollMode; +export function StackflowProvider({children,header,footer,persistent,animation='ios',preserveScroll=true,scrollMode='window',scrollTarget,edgeBounce=false,fixedTargets,modalRoutes,transitionRoutes,skipSlideQueryKeys,transitionTarget,swipeBack=false,maxEntries=32,navigationTimeout=4000,waitForPage=false,skeletonRoutes,loading,locale,className='',style}: StackflowProviderProps) { const viewport=useRef(null); const scrollbar = useRef(null); const fixed = useRef([]); @@ -147,7 +140,7 @@ export function StackflowProvider({children,header,footer,persistent,animation=' {footer &&
{footer}
} ; return -
+
{header &&
{header}
}
{children}
diff --git a/src/next/style.css b/src/next/style.css index 3dee7dc..7d45ed9 100644 --- a/src/next/style.css +++ b/src/next/style.css @@ -85,17 +85,13 @@ html[data-stackflow-direction][data-stackflow-modal=exit]::view-transition-new(s } .stackflow-next-viewport{position:relative;flex:1;min-height:0;overflow:clip}.stackflow-next-header,.stackflow-next-footer,.stackflow-next-persistent{flex:none} -/* The drawn scrollbar replaces the browser's. Hide the native one on the - document and on (some apps scroll the body) on every engine. */ -html:has(.stackflow-next:is([data-stackflow-scroll-mode=window],[data-stackflow-app-shell])), -html:has(.stackflow-next:is([data-stackflow-scroll-mode=window],[data-stackflow-app-shell])) > body{scrollbar-width:none} -html:has(.stackflow-next:is([data-stackflow-scroll-mode=window],[data-stackflow-app-shell]))::-webkit-scrollbar, -html:has(.stackflow-next:is([data-stackflow-scroll-mode=window],[data-stackflow-app-shell])) > body::-webkit-scrollbar{display:none;width:0;height:0} -/* App shell: the provider fills the viewport and the document never scrolls. - Each page scrolls its own scrollTarget area. */ -html:has(.stackflow-next[data-stackflow-app-shell]), -html:has(.stackflow-next[data-stackflow-app-shell]) > body{height:100%;overflow:hidden;overscroll-behavior:none} -.stackflow-next[data-stackflow-app-shell]{position:fixed;inset:0;height:auto} +/* The document keeps scrolling natively (window.scrollTo, scrollY, scroll + events). Only the browser's scrollbar is hidden, on and on + for apps that scroll the body, and the drawn scrollbar replaces it. */ +html:has(.stackflow-next[data-stackflow-scroll-mode=window]), +html:has(.stackflow-next[data-stackflow-scroll-mode=window]) > body{scrollbar-width:none} +html:has(.stackflow-next[data-stackflow-scroll-mode=window])::-webkit-scrollbar, +html:has(.stackflow-next[data-stackflow-scroll-mode=window]) > body::-webkit-scrollbar{display:none;width:0;height:0} .stackflow-next[data-stackflow-scroll-mode=window]{height:auto;min-height:100dvh;--stackflow-slide-y:0 100dvh} [data-stackflow-scroll-mode=window] > .stackflow-next-viewport{display:flex;flex-direction:column;flex:1 0 auto;overflow:visible} [data-stackflow-scroll-mode=window] .stackflow-next-content:not([data-stackflow-slide-snapshot]){flex:1 0 auto;height:auto;overflow:visible;overscroll-behavior:auto}