mirror of
https://github.com/tenrok/OverlayScrollbars.git
synced 2026-06-23 08:30:37 +03:00
set scroll-behavior to 'auto' when pressing any scrollbar
This commit is contained in:
@@ -8,6 +8,7 @@ export const dataAttributeHostOverflowX = `${dataAttributeHost}-overflow-x`;
|
|||||||
export const dataAttributeHostOverflowY = `${dataAttributeHost}-overflow-y`;
|
export const dataAttributeHostOverflowY = `${dataAttributeHost}-overflow-y`;
|
||||||
export const dataValueHostOverflowVisible = 'overflowVisible';
|
export const dataValueHostOverflowVisible = 'overflowVisible';
|
||||||
export const dataValueHostScrollbarHidden = 'scrollbarHidden';
|
export const dataValueHostScrollbarHidden = 'scrollbarHidden';
|
||||||
|
export const dataValueHostScrollbarPressed = 'scrollbarPressed';
|
||||||
export const dataValueHostUpdating = 'updating';
|
export const dataValueHostUpdating = 'updating';
|
||||||
export const classNamePadding = 'os-padding';
|
export const classNamePadding = 'os-padding';
|
||||||
export const classNameViewport = 'os-viewport';
|
export const classNameViewport = 'os-viewport';
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import {
|
|||||||
parent,
|
parent,
|
||||||
closest,
|
closest,
|
||||||
push,
|
push,
|
||||||
|
attrClass,
|
||||||
} from '~/support';
|
} from '~/support';
|
||||||
import { getPlugins, clickScrollPluginName } from '~/plugins';
|
import { getPlugins, clickScrollPluginName } from '~/plugins';
|
||||||
import { getEnvironment } from '~/environment';
|
import { getEnvironment } from '~/environment';
|
||||||
@@ -17,6 +18,8 @@ import {
|
|||||||
classNameScrollbarHandle,
|
classNameScrollbarHandle,
|
||||||
classNameScrollbarInteraction,
|
classNameScrollbarInteraction,
|
||||||
classNameScrollbarWheel,
|
classNameScrollbarWheel,
|
||||||
|
dataAttributeHost,
|
||||||
|
dataValueHostScrollbarPressed,
|
||||||
} from '~/classnames';
|
} from '~/classnames';
|
||||||
import type { XY } from '~/support';
|
import type { XY } from '~/support';
|
||||||
import type { ClickScrollPluginInstance } from '~/plugins';
|
import type { ClickScrollPluginInstance } from '~/plugins';
|
||||||
@@ -71,7 +74,8 @@ const releasePointerCaptureEvents = 'pointerup pointerleave pointercancel lostpo
|
|||||||
|
|
||||||
const createInteractiveScrollEvents = (
|
const createInteractiveScrollEvents = (
|
||||||
options: ReadonlyOptions,
|
options: ReadonlyOptions,
|
||||||
doc: Document,
|
hostElm: HTMLElement,
|
||||||
|
documentElm: Document,
|
||||||
scrollbarStructure: ScrollbarStructure,
|
scrollbarStructure: ScrollbarStructure,
|
||||||
scrollOffsetElement: HTMLElement,
|
scrollOffsetElement: HTMLElement,
|
||||||
structureSetupState: () => StructureSetupState,
|
structureSetupState: () => StructureSetupState,
|
||||||
@@ -103,6 +107,7 @@ const createInteractiveScrollEvents = (
|
|||||||
const isDragScroll =
|
const isDragScroll =
|
||||||
closest(pointerDownEvent.target as Node, `.${classNameScrollbarHandle}`) === _handle;
|
closest(pointerDownEvent.target as Node, `.${classNameScrollbarHandle}`) === _handle;
|
||||||
const pointerCaptureElement = isDragScroll ? _handle : _track;
|
const pointerCaptureElement = isDragScroll ? _handle : _track;
|
||||||
|
attrClass(hostElm, dataAttributeHost, dataValueHostScrollbarPressed, true);
|
||||||
|
|
||||||
if (continuePointerDown(pointerDownEvent, options, isDragScroll)) {
|
if (continuePointerDown(pointerDownEvent, options, isDragScroll)) {
|
||||||
const instantClickScroll = !isDragScroll && pointerDownEvent.shiftKey;
|
const instantClickScroll = !isDragScroll && pointerDownEvent.shiftKey;
|
||||||
@@ -128,8 +133,9 @@ const createInteractiveScrollEvents = (
|
|||||||
};
|
};
|
||||||
|
|
||||||
const offFns = [
|
const offFns = [
|
||||||
on(doc, releasePointerCaptureEvents, releasePointerCapture),
|
attrClass.bind(0, hostElm, dataAttributeHost, dataValueHostScrollbarPressed),
|
||||||
on(doc, 'selectstart', (event: Event) => preventDefault(event), {
|
on(documentElm, releasePointerCaptureEvents, releasePointerCapture),
|
||||||
|
on(documentElm, 'selectstart', (event: Event) => preventDefault(event), {
|
||||||
_passive: false,
|
_passive: false,
|
||||||
}),
|
}),
|
||||||
on(_track, releasePointerCaptureEvents, releasePointerCapture),
|
on(_track, releasePointerCaptureEvents, releasePointerCapture),
|
||||||
@@ -222,6 +228,7 @@ export const createScrollbarsSetupEvents =
|
|||||||
createRootClickStopPropagationEvents(_scrollbar, documentElm),
|
createRootClickStopPropagationEvents(_scrollbar, documentElm),
|
||||||
createInteractiveScrollEvents(
|
createInteractiveScrollEvents(
|
||||||
options,
|
options,
|
||||||
|
hostElm,
|
||||||
documentElm,
|
documentElm,
|
||||||
scrollbarStructure,
|
scrollbarStructure,
|
||||||
scrollOffsetElm,
|
scrollOffsetElm,
|
||||||
|
|||||||
@@ -168,6 +168,11 @@ html[data-overlayscrollbars] > body {
|
|||||||
overflow-y: scroll;
|
overflow-y: scroll;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[data-overlayscrollbars~='scrollbarPressed'],
|
||||||
|
[data-overlayscrollbars~='scrollbarPressed'] .os-viewport {
|
||||||
|
scroll-behavior: auto !important;
|
||||||
|
}
|
||||||
|
|
||||||
.os-padding,
|
.os-padding,
|
||||||
.os-viewport {
|
.os-viewport {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
export * from '~/support/dom/animation';
|
|
||||||
export * from '~/support/dom/attribute';
|
export * from '~/support/dom/attribute';
|
||||||
export * from '~/support/dom/class';
|
export * from '~/support/dom/class';
|
||||||
export * from '~/support/dom/create';
|
export * from '~/support/dom/create';
|
||||||
|
|||||||
+1
-1
@@ -28,7 +28,7 @@ export const animateNumber = (
|
|||||||
): ((complete?: boolean) => void) => {
|
): ((complete?: boolean) => void) => {
|
||||||
let animationFrameId = 0;
|
let animationFrameId = 0;
|
||||||
const timeStart = animationCurrentTime();
|
const timeStart = animationCurrentTime();
|
||||||
const finalDuration = Math.max(0, duration);
|
const finalDuration = max(0, duration);
|
||||||
const frame = (complete?: boolean) => {
|
const frame = (complete?: boolean) => {
|
||||||
const timeNow = animationCurrentTime();
|
const timeNow = animationCurrentTime();
|
||||||
const timeElapsed = timeNow - timeStart;
|
const timeElapsed = timeNow - timeStart;
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
export * from '~/support/utils/animation';
|
||||||
export * from '~/support/utils/array';
|
export * from '~/support/utils/array';
|
||||||
export * from '~/support/utils/equal';
|
export * from '~/support/utils/equal';
|
||||||
export * from '~/support/utils/function';
|
export * from '~/support/utils/function';
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
import { animateNumber } from '~/support/dom/animation';
|
import { animateNumber } from '~/support/utils/animation';
|
||||||
|
|
||||||
jest.useFakeTimers();
|
jest.useFakeTimers();
|
||||||
|
|
||||||
@@ -1,3 +1,6 @@
|
|||||||
|
* {
|
||||||
|
scroll-behavior: smooth;
|
||||||
|
}
|
||||||
body {
|
body {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|||||||
Reference in New Issue
Block a user