Skip to content

Commit b7a96af

Browse files
committed
v2.10.0
1 parent b78db4f commit b7a96af

File tree

9 files changed

+217
-74
lines changed

9 files changed

+217
-74
lines changed

README.md

Lines changed: 58 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -376,9 +376,9 @@ Indicates whether you can drag the scrollbar handles for scrolling.
376376

377377
| type | default |
378378
| :--- | :--- |
379-
| `boolean` | `false` |
379+
| `boolean \| 'instant'` | `false` |
380380

381-
> __Note__: This options requires the **ClickScrollPlugin** to work.
381+
> __Note__: If set to `true` the **ClickScrollPlugin** is required.
382382
383383
Indicates whether you can click on the scrollbar track for scrolling.
384384

@@ -442,13 +442,55 @@ type Options = {
442442
autoHideDelay: number;
443443
// Whether the scrollbar's auto hide behavior is suspended until a scroll happened.
444444
autoHideSuspend: boolean;
445-
// Whether its possible to drag the handle of a scrollbar to scroll the viewport.
445+
// Whether it is possible to drag the handle of a scrollbar to scroll the viewport.
446446
dragScroll: boolean;
447-
// Whether its possible to click the track of a scrollbar to scroll the viewport.
448-
clickScroll: boolean;
447+
// Whether it is possible to click the track of a scrollbar to scroll the viewport.
448+
clickScroll: ScrollbarsClickScrollBehavior;
449449
// An array of pointer types that shall be supported.
450450
pointers: string[] | null;
451451
};
452+
453+
// The overflow behavior of an axis.
454+
type OverflowBehavior =
455+
// No scrolling is possible and the content is clipped.
456+
| 'hidden'
457+
// No scrolling is possible and the content isn't clipped.
458+
| 'visible'
459+
// Scrolling is possible if there is an overflow.
460+
| 'scroll'
461+
/**
462+
* If the other axis has no overflow the behavior is similar to `visible`.
463+
* If the other axis has overflow the behavior is similar to `hidden`.
464+
*/
465+
| 'visible-hidden'
466+
/**
467+
* If the other axis has no overflow the behavior is similar to `visible`.
468+
* If the other axis has overflow the behavior is similar to `scroll`.
469+
*/
470+
| 'visible-scroll';
471+
472+
// The scrollbars visibility behavior.
473+
type ScrollbarsVisibilityBehavior =
474+
// The scrollbars are always visible.
475+
| 'visible'
476+
// The scrollbars are always hidden.
477+
| 'hidden'
478+
// The scrollbars are only visibile if there is overflow.
479+
| 'auto';
480+
481+
// The scrollbars auto hide behavior
482+
type ScrollbarsAutoHideBehavior =
483+
// The scrollbars are never hidden automatically.
484+
| 'never'
485+
// The scrollbars are hidden unless the user scrolls.
486+
| 'scroll'
487+
// The scrollbars are hidden unless the pointer moves in the host element or the user scrolls.
488+
| 'move'
489+
// The scrollbars are hidden if the pointer leaves the host element or unless the user scrolls.
490+
| 'leave';
491+
492+
// The scrollbar click scroll behavior.
493+
type ScrollbarsClickScrollBehavior = boolean | 'instant';
452494
};
453495
```
454496

@@ -588,7 +630,7 @@ const osInstance = OverlayScrollbars(document.body, {});
588630
| parameter | type | description |
589631
| :--- | :--- | :--- |
590632
| newOptions | `PartialOptions` | The new (partial) options which should be applied. |
591-
| pure | `boolean / undefined` | Whether the options should be reset before the new options are added. |
633+
| pure | `boolean \| undefined` | Whether the options should be reset before the new options are added. |
592634

593635
| returns | description |
594636
| :--- | :--- |
@@ -601,7 +643,7 @@ const osInstance = OverlayScrollbars(document.body, {});
601643
| parameter | type | description |
602644
| :--- | :--- | :--- |
603645
| eventListeners | `EventListeners` | An object which contains the added listeners. The fields are the event names and the listeners. |
604-
| pure | `boolean / undefined` | Whether all already added event listeners should be removed before the new listeners are added. |
646+
| pure | `boolean \| undefined` | Whether all already added event listeners should be removed before the new listeners are added. |
605647

606648
| returns | description |
607649
| :--- | :--- |
@@ -657,7 +699,7 @@ const osInstance = OverlayScrollbars(document.body, {});
657699

658700
| parameter | type | description |
659701
| :--- | :--- | :--- |
660-
| force | `boolean / undefined` | Whether the update should force the cache to be invalidated. |
702+
| force | `boolean \| undefined` | Whether the update should force the cache to be invalidated. |
661703

662704
| returns | description |
663705
| :--- | :--- |
@@ -689,7 +731,7 @@ const osInstance = OverlayScrollbars(document.body, {});
689731

690732
| returns | description |
691733
| :--- | :--- |
692-
| `object / undefined` | An object which describes the plugins instance modules instance or `undefined` if no instance was found. |
734+
| `object \| undefined` | An object which describes the plugins instance modules instance or `undefined` if no instance was found. |
693735

694736
#### TypeScript
695737

@@ -834,7 +876,7 @@ OverlayScrollbars.plugin(SomePlugin);
834876

835877
| parameter | type | description |
836878
| :--- | :--- | :--- |
837-
| newNonce | `string / undefined` | The nonce attribute for inline styles. |
879+
| newNonce | `string \| undefined` | The nonce attribute for inline styles. |
838880

839881
### `plugin(plugin): object | undefined`
840882

@@ -846,7 +888,7 @@ OverlayScrollbars.plugin(SomePlugin);
846888

847889
| returns | description |
848890
| :--- | :--- |
849-
| `object / void` | An object describing the plugin's static module instance or `void` if no instance was found. |
891+
| `object \| void` | An object describing the plugin's static module instance or `void` if no instance was found. |
850892

851893
### `plugin(plugins): (object | void)[]`
852894

@@ -858,7 +900,7 @@ OverlayScrollbars.plugin(SomePlugin);
858900

859901
| returns | description |
860902
| :--- | :--- |
861-
| `(object / void)[]` | An array describing the plugins static modules instances or `undefined` if no instance was found. |
903+
| `(object \| void)[]` | An array describing the plugins static modules instances or `undefined` if no instance was found. |
862904

863905
#### TypeScript
864906

@@ -1050,10 +1092,10 @@ Custom themes can be done in several ways. The easiest and fastest way is to use
10501092
| `.os-scrollbar-rtl` | Indicates a `RTL` direction of the host element the scrollbar belongs to. |
10511093
| `.os-scrollbar-horizontal` | The root element of a horizontal scrollbar. |
10521094
| `.os-scrollbar-vertical` | The root element of a vertical scrollbar. |
1053-
| `.os-scrollbar-handle-interactive` | Indicates that the handle inside the scrollbar is interactive (`scrollbars.dragScroll` is `true`). |
1054-
| `.os-scrollbar-track-interactive` | Indicates that the track inside the scrollbar is interactive (`scrollbars.clickScroll` is `true`). |
1055-
| `.os-scrollbar-track` | The track element. This is the track of the nested handle element. If `scrollbars.clickScroll` is `true` this is the element users can click to change the scroll offset. |
1056-
| `.os-scrollbar-handle` | The handle element. If `scrollbars.dragScroll` is `true` this is the handle users can drag to change the scroll offset. |
1095+
| `.os-scrollbar-handle-interactive` | Indicates that the handle inside the scrollbar is interactive (`scrollbars.dragScroll` is not `false`). |
1096+
| `.os-scrollbar-track-interactive` | Indicates that the track inside the scrollbar is interactive (`scrollbars.clickScroll` is not `false`). |
1097+
| `.os-scrollbar-track` | The track element. This is the track of the nested handle element. If `scrollbars.clickScroll` is not `false` this is the element users can click to change the scroll offset. |
1098+
| `.os-scrollbar-handle` | The handle element. If `scrollbars.dragScroll` is not `false` this is the handle users can drag to change the scroll offset. |
10571099

10581100
If you create your own theme, please only use the classes listed above. All other classes are modifier classes used to change visibility, alignment and pointer-events of the scrollbars.
10591101

packages/overlayscrollbars/CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Changelog
22

3+
## 2.10.0
4+
5+
### Features
6+
7+
- The options `scrollbars.clickScroll` now supports the value `'instant'`. The `ClickScrollPlugin` is not required for it to work. [#645](https://github.com/KingSora/OverlayScrollbars/issues/645)
8+
9+
### Improvements
10+
11+
- Rewrite `clickScroll` animation for better performance and to support in and out easing for a smoother animation.
12+
313
## 2.9.2
414

515
### Improvements

packages/overlayscrollbars/README.md

Lines changed: 58 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -376,9 +376,9 @@ Indicates whether you can drag the scrollbar handles for scrolling.
376376

377377
| type | default |
378378
| :--- | :--- |
379-
| `boolean` | `false` |
379+
| `boolean \| 'instant'` | `false` |
380380

381-
> __Note__: This options requires the **ClickScrollPlugin** to work.
381+
> __Note__: If set to `true` the **ClickScrollPlugin** is required.
382382
383383
Indicates whether you can click on the scrollbar track for scrolling.
384384

@@ -442,13 +442,55 @@ type Options = {
442442
autoHideDelay: number;
443443
// Whether the scrollbar's auto hide behavior is suspended until a scroll happened.
444444
autoHideSuspend: boolean;
445-
// Whether its possible to drag the handle of a scrollbar to scroll the viewport.
445+
// Whether it is possible to drag the handle of a scrollbar to scroll the viewport.
446446
dragScroll: boolean;
447-
// Whether its possible to click the track of a scrollbar to scroll the viewport.
448-
clickScroll: boolean;
447+
// Whether it is possible to click the track of a scrollbar to scroll the viewport.
448+
clickScroll: ScrollbarsClickScrollBehavior;
449449
// An array of pointer types that shall be supported.
450450
pointers: string[] | null;
451451
};
452+
453+
// The overflow behavior of an axis.
454+
type OverflowBehavior =
455+
// No scrolling is possible and the content is clipped.
456+
| 'hidden'
457+
// No scrolling is possible and the content isn't clipped.
458+
| 'visible'
459+
// Scrolling is possible if there is an overflow.
460+
| 'scroll'
461+
/**
462+
* If the other axis has no overflow the behavior is similar to `visible`.
463+
* If the other axis has overflow the behavior is similar to `hidden`.
464+
*/
465+
| 'visible-hidden'
466+
/**
467+
* If the other axis has no overflow the behavior is similar to `visible`.
468+
* If the other axis has overflow the behavior is similar to `scroll`.
469+
*/
470+
| 'visible-scroll';
471+
472+
// The scrollbars visibility behavior.
473+
type ScrollbarsVisibilityBehavior =
474+
// The scrollbars are always visible.
475+
| 'visible'
476+
// The scrollbars are always hidden.
477+
| 'hidden'
478+
// The scrollbars are only visibile if there is overflow.
479+
| 'auto';
480+
481+
// The scrollbars auto hide behavior
482+
type ScrollbarsAutoHideBehavior =
483+
// The scrollbars are never hidden automatically.
484+
| 'never'
485+
// The scrollbars are hidden unless the user scrolls.
486+
| 'scroll'
487+
// The scrollbars are hidden unless the pointer moves in the host element or the user scrolls.
488+
| 'move'
489+
// The scrollbars are hidden if the pointer leaves the host element or unless the user scrolls.
490+
| 'leave';
491+
492+
// The scrollbar click scroll behavior.
493+
type ScrollbarsClickScrollBehavior = boolean | 'instant';
452494
};
453495
```
454496

@@ -588,7 +630,7 @@ const osInstance = OverlayScrollbars(document.body, {});
588630
| parameter | type | description |
589631
| :--- | :--- | :--- |
590632
| newOptions | `PartialOptions` | The new (partial) options which should be applied. |
591-
| pure | `boolean / undefined` | Whether the options should be reset before the new options are added. |
633+
| pure | `boolean \| undefined` | Whether the options should be reset before the new options are added. |
592634

593635
| returns | description |
594636
| :--- | :--- |
@@ -601,7 +643,7 @@ const osInstance = OverlayScrollbars(document.body, {});
601643
| parameter | type | description |
602644
| :--- | :--- | :--- |
603645
| eventListeners | `EventListeners` | An object which contains the added listeners. The fields are the event names and the listeners. |
604-
| pure | `boolean / undefined` | Whether all already added event listeners should be removed before the new listeners are added. |
646+
| pure | `boolean \| undefined` | Whether all already added event listeners should be removed before the new listeners are added. |
605647

606648
| returns | description |
607649
| :--- | :--- |
@@ -657,7 +699,7 @@ const osInstance = OverlayScrollbars(document.body, {});
657699

658700
| parameter | type | description |
659701
| :--- | :--- | :--- |
660-
| force | `boolean / undefined` | Whether the update should force the cache to be invalidated. |
702+
| force | `boolean \| undefined` | Whether the update should force the cache to be invalidated. |
661703

662704
| returns | description |
663705
| :--- | :--- |
@@ -689,7 +731,7 @@ const osInstance = OverlayScrollbars(document.body, {});
689731

690732
| returns | description |
691733
| :--- | :--- |
692-
| `object / undefined` | An object which describes the plugins instance modules instance or `undefined` if no instance was found. |
734+
| `object \| undefined` | An object which describes the plugins instance modules instance or `undefined` if no instance was found. |
693735

694736
#### TypeScript
695737

@@ -834,7 +876,7 @@ OverlayScrollbars.plugin(SomePlugin);
834876

835877
| parameter | type | description |
836878
| :--- | :--- | :--- |
837-
| newNonce | `string / undefined` | The nonce attribute for inline styles. |
879+
| newNonce | `string \| undefined` | The nonce attribute for inline styles. |
838880

839881
### `plugin(plugin): object | undefined`
840882

@@ -846,7 +888,7 @@ OverlayScrollbars.plugin(SomePlugin);
846888

847889
| returns | description |
848890
| :--- | :--- |
849-
| `object / void` | An object describing the plugin's static module instance or `void` if no instance was found. |
891+
| `object \| void` | An object describing the plugin's static module instance or `void` if no instance was found. |
850892

851893
### `plugin(plugins): (object | void)[]`
852894

@@ -858,7 +900,7 @@ OverlayScrollbars.plugin(SomePlugin);
858900

859901
| returns | description |
860902
| :--- | :--- |
861-
| `(object / void)[]` | An array describing the plugins static modules instances or `undefined` if no instance was found. |
903+
| `(object \| void)[]` | An array describing the plugins static modules instances or `undefined` if no instance was found. |
862904

863905
#### TypeScript
864906

@@ -1050,10 +1092,10 @@ Custom themes can be done in several ways. The easiest and fastest way is to use
10501092
| `.os-scrollbar-rtl` | Indicates a `RTL` direction of the host element the scrollbar belongs to. |
10511093
| `.os-scrollbar-horizontal` | The root element of a horizontal scrollbar. |
10521094
| `.os-scrollbar-vertical` | The root element of a vertical scrollbar. |
1053-
| `.os-scrollbar-handle-interactive` | Indicates that the handle inside the scrollbar is interactive (`scrollbars.dragScroll` is `true`). |
1054-
| `.os-scrollbar-track-interactive` | Indicates that the track inside the scrollbar is interactive (`scrollbars.clickScroll` is `true`). |
1055-
| `.os-scrollbar-track` | The track element. This is the track of the nested handle element. If `scrollbars.clickScroll` is `true` this is the element users can click to change the scroll offset. |
1056-
| `.os-scrollbar-handle` | The handle element. If `scrollbars.dragScroll` is `true` this is the handle users can drag to change the scroll offset. |
1095+
| `.os-scrollbar-handle-interactive` | Indicates that the handle inside the scrollbar is interactive (`scrollbars.dragScroll` is not `false`). |
1096+
| `.os-scrollbar-track-interactive` | Indicates that the track inside the scrollbar is interactive (`scrollbars.clickScroll` is not `false`). |
1097+
| `.os-scrollbar-track` | The track element. This is the track of the nested handle element. If `scrollbars.clickScroll` is not `false` this is the element users can click to change the scroll offset. |
1098+
| `.os-scrollbar-handle` | The handle element. If `scrollbars.dragScroll` is not `false` this is the handle users can drag to change the scroll offset. |
10571099

10581100
If you create your own theme, please only use the classes listed above. All other classes are modifier classes used to change visibility, alignment and pointer-events of the scrollbars.
10591101

packages/overlayscrollbars/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "overlayscrollbars",
33
"private": true,
4-
"version": "2.9.2",
4+
"version": "2.10.0",
55
"description": "A javascript scrollbar plugin that hides the native scrollbars, provides custom styleable overlay scrollbars, and preserves the native functionality and feel.",
66
"author": "Rene Haas | KingSora",
77
"license": "MIT",

packages/overlayscrollbars/src/options.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,11 @@ export type ScrollbarsAutoHideBehavior =
137137
/** The scrollbars are hidden if the pointer leaves the host element or unless the user scrolls. */
138138
| 'leave';
139139

140+
/**
141+
* The scrollbar click scroll behavior.
142+
*/
143+
export type ScrollbarsClickScrollBehavior = boolean | 'instant';
144+
140145
/**
141146
* The options of a OverlayScrollbars instance.
142147
*/
@@ -198,7 +203,7 @@ export type Options = {
198203
/** Whether it is possible to drag the handle of a scrollbar to scroll the viewport. */
199204
dragScroll: boolean;
200205
/** Whether it is possible to click the track of a scrollbar to scroll the viewport. */
201-
clickScroll: boolean;
206+
clickScroll: ScrollbarsClickScrollBehavior;
202207
/**
203208
* An array of pointer types which shall be supported.
204209
* Common pointer types are: `mouse`, `pen` and `touch`.

packages/overlayscrollbars/src/plugins/optionsValidationPlugin/optionsValidationPlugin.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type {
44
OverflowBehavior,
55
ScrollbarsVisibilityBehavior,
66
ScrollbarsAutoHideBehavior,
7+
ScrollbarsClickScrollBehavior,
78
} from '~/options';
89
import type { OptionsTemplate, OptionsTemplateValue } from './validation';
910
import type { StaticPlugin } from '~/plugins';
@@ -26,9 +27,10 @@ export const OptionsValidationPlugin = /* @__PURE__ */ (() => ({
2627
'visible hidden auto';
2728
const scrollbarsAutoHideAllowedValues: OptionsTemplateValue<ScrollbarsAutoHideBehavior> =
2829
'never scroll leavemove';
30+
const scrollbarsClickScrollAllowedValues: OptionsTemplateValue<ScrollbarsClickScrollBehavior> =
31+
[booleanAllowedValues, oTypes.string];
2932

3033
const optionsTemplate: OptionsTemplate<Options> = {
31-
// resize: resizeAllowedValues, // none || both || horizontal || vertical || n || b ||
3234
paddingAbsolute: booleanAllowedValues, // true || false
3335
showNativeOverlaidScrollbars: booleanAllowedValues, // true || false
3436
update: {
@@ -38,17 +40,17 @@ export const OptionsValidationPlugin = /* @__PURE__ */ (() => ({
3840
ignoreMutation: [oTypes.function, oTypes.null], // function || null
3941
},
4042
overflow: {
41-
x: overflowAllowedValues, // visible-hidden || visible-scroll || hidden || scrol
42-
y: overflowAllowedValues, // visible-hidden || visible-scroll || hidden || scrol
43+
x: overflowAllowedValues, // visible-hidden || visible-scroll || hidden || scroll
44+
y: overflowAllowedValues, // visible-hidden || visible-scroll || hidden || scroll
4345
},
4446
scrollbars: {
4547
theme: [oTypes.string, oTypes.null], // string || null
46-
visibility: scrollbarsVisibilityAllowedValues, // visible || hidden || auto || v ||
48+
visibility: scrollbarsVisibilityAllowedValues, // visible || hidden || auto
4749
autoHide: scrollbarsAutoHideAllowedValues, // never || scroll || leave || move ||
4850
autoHideDelay: numberAllowedValues, // number
4951
autoHideSuspend: booleanAllowedValues, // true || false
5052
dragScroll: booleanAllowedValues, // true || false
51-
clickScroll: booleanAllowedValues, // true || false
53+
clickScroll: scrollbarsClickScrollAllowedValues, // true || false || instant
5254
pointers: [oTypes.array, oTypes.null], // string array
5355
},
5456
/*

0 commit comments

Comments
 (0)