Rocky_Mountain_Vending/.pnpm-store/v10/files/34/c6bc9bf53b0c95dba377deb8184a7e64734d2ff4f37f523065204c6bfedbdf1c9e9e9080158315aa1d2b3f5f2553b75223a72b964b8de6a0ea88771a42bdc2
DMleadgen 46d973904b
Initial commit: Rocky Mountain Vending website
Next.js website for Rocky Mountain Vending company featuring:
- Product catalog with Stripe integration
- Service areas and parts pages
- Admin dashboard with Clerk authentication
- SEO optimized pages with JSON-LD structured data

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 16:22:15 -07:00

36 lines
No EOL
1.8 KiB
Text

import { warnOnce } from '../../utils/warn-once';
/**
* Run function with `scroll-behavior: auto` applied to `<html/>`.
* This css change will be reverted after the function finishes.
*/ export function disableSmoothScrollDuringRouteTransition(fn, options = {}) {
// if only the hash is changed, we don't need to disable smooth scrolling
// we only care to prevent smooth scrolling when navigating to a new page to avoid jarring UX
if (options.onlyHashChange) {
fn();
return;
}
const htmlElement = document.documentElement;
const hasDataAttribute = htmlElement.dataset.scrollBehavior === 'smooth';
if (!hasDataAttribute) {
// Warn if smooth scrolling is detected but no data attribute is present
if (process.env.NODE_ENV === 'development' && getComputedStyle(htmlElement).scrollBehavior === 'smooth') {
warnOnce('Detected `scroll-behavior: smooth` on the `<html>` element. To disable smooth scrolling during route transitions, ' + 'add `data-scroll-behavior="smooth"` to your <html> element. ' + 'Learn more: https://nextjs.org/docs/messages/missing-data-scroll-behavior');
}
// No smooth scrolling configured, run directly without style manipulation
fn();
return;
}
// Proceed with temporarily disabling smooth scrolling
const existing = htmlElement.style.scrollBehavior;
htmlElement.style.scrollBehavior = 'auto';
if (!options.dontForceLayout) {
// In Chrome-based browsers we need to force reflow before calling `scrollTo`.
// Otherwise it will not pickup the change in scrollBehavior
// More info here: https://github.com/vercel/next.js/issues/40719#issuecomment-1336248042
htmlElement.getClientRects();
}
fn();
htmlElement.style.scrollBehavior = existing;
}
//# sourceMappingURL=disable-smooth-scroll.js.map