mirror of
https://github.com/tenrok/OverlayScrollbars.git
synced 2026-06-09 01:32:28 +03:00
improve website
This commit is contained in:
@@ -1,34 +0,0 @@
|
||||
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
|
||||
|
||||
## Getting Started
|
||||
|
||||
First, run the development server:
|
||||
|
||||
```bash
|
||||
npm run dev
|
||||
# or
|
||||
yarn dev
|
||||
```
|
||||
|
||||
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
|
||||
|
||||
You can start editing the page by modifying `pages/index.tsx`. The page auto-updates as you edit the file.
|
||||
|
||||
[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.ts`.
|
||||
|
||||
The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages.
|
||||
|
||||
## Learn More
|
||||
|
||||
To learn more about Next.js, take a look at the following resources:
|
||||
|
||||
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
|
||||
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
|
||||
|
||||
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!
|
||||
|
||||
## Deploy on Vercel
|
||||
|
||||
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
|
||||
|
||||
Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
|
||||
@@ -463,6 +463,66 @@ OverlayScrollbars.plugin([SizeObserverPlugin, ClickScrollPlugin]);
|
||||
|
||||
You can write and publish your own Plugins. This section is a work in progress.
|
||||
|
||||
## FAQ
|
||||
|
||||
<details>
|
||||
<summary>
|
||||
How do I <code>get</code> the <code>scroll position</code> of an element I applied the OverlayScrollbars to?
|
||||
</summary>
|
||||
<br />
|
||||
|
||||
If you applied `OverlayScrollbars` to the `body` element you can use [`window.scrollX`](https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollX), [`window.scrollY`](https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollY) or any other native api.
|
||||
|
||||
If the plugin was applied to any other element you have to get the `instance` first. With the instance you can get the `viewport` element. With this element you can use [`element.scrollTop`](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollTop), [`element.scrollLeft`](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollLeft) or any other native api.
|
||||
|
||||
```js
|
||||
const { viewport } = osInstance.elements();
|
||||
const { scrollLeft, scrollTop } = viewport;
|
||||
```
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>
|
||||
How do I <code>set</code> the <code>scroll position</code> of an element I applied the OverlayScrollbars to?
|
||||
</summary>
|
||||
<br />
|
||||
|
||||
If you applied `OverlayScrollbars` to the `body` element you can scroll it with [`window.scroll`](https://developer.mozilla.org/en-US/docs/Web/API/Window/scroll), [`window.scrollTo`](https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollTo), [`window.scrollBy`](https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollBy) or any other native api.
|
||||
|
||||
If the plugin was applied to any other element you have to get the `instance` first. With the instance you can get the `viewport` element. With this element you can use [`element.scroll`](https://developer.mozilla.org/en-US/docs/Web/API/Element/scroll), [`element.scrollTo`](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollTo), [`element.scrollBy`](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollBy) or any other native api.
|
||||
|
||||
```js
|
||||
const { viewport } = osInstance.elements();
|
||||
viewport.scrollTo({ top: 0 });
|
||||
```
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>
|
||||
Is it possible to <code>limit / adjust the scrollbar handle length</code>?
|
||||
</summary>
|
||||
<br />
|
||||
|
||||
You can adjust a scrollbars handle length by setting a `min-width / min-height` and `max-width / max-height` style:
|
||||
|
||||
```css
|
||||
/* horizontal boundaries */
|
||||
.os-scrollbar-horizontal .os-scrollbar-handle {
|
||||
min-width: 50px;
|
||||
max-width: 200px;
|
||||
}
|
||||
/* vertical boundaries */
|
||||
.os-scrollbar-vertical .os-scrollbar-handle {
|
||||
min-height: 40px;
|
||||
max-height: 40px;
|
||||
}
|
||||
```
|
||||
|
||||
You can assign the same value to both properties to force the scrollbar to be always the same size.
|
||||
Setting the `width` and `height` properties won't work since those are set by the plugin automatically.
|
||||
|
||||
</details>
|
||||
|
||||
## Feature comparison to `v1`
|
||||
|
||||
- The `scroll` function is missing. Planned as a `plugin`. (WIP)
|
||||
|
||||
Reference in New Issue
Block a user