-
Notifications
You must be signed in to change notification settings - Fork 2.2k
feat(widgets): Add ScrollbarWidget #10068
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
0db85c1
Add ScrollbarWidget
Pessimistress 96b7d0b
add css variables to docs
Pessimistress 477087d
rebase and fix build
Pessimistress e0a5f9b
address comments
Pessimistress c708f44
address comments
Pessimistress 057f307
fine tune range input behavior
Pessimistress File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
|
|
||
| # ScrollbarWidget | ||
|
|
||
| <img src="https://img.shields.io/badge/from-v9.3-green.svg?style=flat-square" alt="from v9.3" /> | ||
|
|
||
| This widget renders a scrollbar UI that mimics the native HTML scrolling behavior. It works with the [OrthographicView](../core/orthographic-view.md) to create a "scrollable" canvas of arbitrary size. | ||
|
|
||
| ## Usage | ||
|
|
||
| ```ts | ||
| import {Deck, OrthographicView} from '@deck.gl/core'; | ||
| import {ScrollbarWidget} from '@deck.gl/widgets'; | ||
|
|
||
| new Deck({ | ||
| views: new OrthographicView(), | ||
| widgets: [ | ||
| new ScrollbarWidget({ | ||
| viewId: 'ortho-view', | ||
| contentBounds: [ | ||
| [0, 0, 0], | ||
| [100000, 100, 0] | ||
| ], | ||
| placement: 'bottom-right', | ||
| orientation: 'horizontal', | ||
| captureWheel: true | ||
| }) | ||
| ] | ||
| }); | ||
| ``` | ||
|
|
||
| ## Types | ||
|
|
||
| ### `ScrollbarWidgetProps` | ||
|
|
||
| The `ScrollbarWidget` accepts the generic [`WidgetProps`](../core/widget.md#widgetprops) and: | ||
|
|
||
| #### contentBounds ([min: number[], max: number[]]) | ||
|
|
||
| The full extent of the scrollable content, in world coordinates. | ||
| The widget relies on this value to calculate the position and size of the slider button and track. | ||
| If not supplied, the scrollbar will always be hidden. | ||
|
|
||
| #### orientation (string, optional) | ||
|
|
||
| Direction of the scrollbar. `'horizontal'` scrolls the camera along the X axis, and `'vertical'` scrolls the camera along the Y axis. | ||
|
|
||
| * Default: `'vertical'` | ||
|
|
||
| #### stepSize (number, optional) | ||
|
|
||
| Pixels scrolled when clicked on the navigation buttons. | ||
|
|
||
| * Default: 1/10 of the viewport size | ||
|
|
||
| #### pageSize (number, optional) | ||
|
|
||
| Pixels scrolled when clicked on the track. | ||
|
|
||
| * Default: 100% of the viewport size | ||
|
|
||
| #### startButtonAriaLabel (string, optional) | ||
|
|
||
| Label of the step button at the start. | ||
|
|
||
| * Default: `'Scroll left'` if horizontal, `'Scroll up'` if vertical | ||
|
|
||
|
|
||
| #### endButtonAriaLabel (string, optional) | ||
|
|
||
| Label of the step button at the end. | ||
|
|
||
| * Default: `'Scroll right'` if horizontal, `'Scroll down'` if vertical | ||
|
|
||
| #### captureWheel (boolean, optional) | ||
|
|
||
| If `true`, mouse wheel events over the canvas will be intercepted by this scrollbar. This is useful when the app wants to simulate the HTML native page scrolling behavior. | ||
|
|
||
| * Default: `false` | ||
|
|
||
| #### decorations (ScrollbarDecoration[], optional) | ||
|
|
||
| Custom markers to overlay on the track. | ||
| This can serve as visual reference or highlights of areas of interest even when they are outside of the current viewport. | ||
|
|
||
|
|
||
| ### ScrollbarDecoration | ||
|
|
||
| A `ScrollbarDecoration` object | ||
|
|
||
| - `contentBounds` ([min: number[], max: number[]]) - world position that the decoration represents | ||
| - `color` (string) - CSS color of the decoration | ||
| - `title` (string, optional) - Tooltip when the decoration is hovered | ||
| - `onClick` (function, optional) - Callback when the decoration is clicked. | ||
| Receives the following parameters: | ||
| + `event` (MouseEvent) | ||
| Return `true` to mark the event as handled, and prevent the default behavior. | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it make sense to implement this pattern on other widget event callbacks? |
||
|
|
||
|
|
||
| ## Styles | ||
|
|
||
| Learn more about how to replace icons in the [styling guide](/docs/api-reference/widgets/styling#replacing-icons). | ||
|
|
||
| | Name | Type | Default | | ||
| | -------- | --------- | ------------ | | ||
| | `--range-step-button-size` | [Dimension](https://developer.mozilla.org/en-US/docs/Web/CSS/dimension) | `24px` | | ||
| | `--range-track-size` | [Dimension](https://developer.mozilla.org/en-US/docs/Web/CSS/dimension) | `16px` | | ||
| | `--range-thumb-size` | [Dimension](https://developer.mozilla.org/en-US/docs/Web/CSS/dimension) | `10px` | | ||
| | `--range-track-color` | [Color](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value) | `#888` | | ||
| | `--range-thumb-color` | [Color](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value) | `#444` | | ||
| | `--range-decoration-active-color` | [Color](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value) | `gold` | | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.