Skip to content

Add scroll behavior option to goToPage / allow disabling smooth scrolling #57

@davi-pandektes

Description

@davi-pandektes

Is your feature request related to a problem? Please describe.

There's no way to disable smooth scrolling when calling goToPage() from usePaginationContext. The scroll behavior is hardcoded to "smooth" in multiple places (smoothScrollTo.js, PaginationContext, ElementPageContext, useSearch). In our use case, we navigate to specific pages programmatically when users click references in a sidebar — the smooth animation feels laggy and disorienting when jumping 20+ pages.

Describe the solution you'd like

Add an optional behavior parameter to goToPage:

goToPage(page: number, options?: { behavior?: 'smooth' | 'instant' })

Or a global scroll behavior config on RPProvider:

<RPProvider src={url} scrollBehavior="instant">

Describe alternatives you've considered

  • CSS scroll-behavior: auto — doesn't work because scrollTo() is called with explicit behavior: "smooth", which overrides the CSS property.
  • scrollToElement from useElementPageContext supports { behavior: 'instant' }, but it requires an element index and isn't a drop-in replacement for goToPage.
  • We currently use a custom webpack loader that replaces all "smooth" strings in the library with "instant" at build time — it works but it's a brittle workaround.

Additional context

The hardcoded "smooth" behavior exists in:

  • dist/utils/smoothScrollTo.js
  • dist/contexts/ElementPageContext.js (default param)
  • dist/utils/hooks/useSearch.js
  • dist/PaginationContext-*.js (minified default parameter and comparison)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions