2308091b13
## What - Deprecate overlayscrollbars as we decided to follow the native behavior - rework on performances (avoid calling recoil states too much at field level which is quite expensive) - Also implements: https://github.com/twentyhq/core-team-issues/issues/569 --------- Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
39 lines
1.2 KiB
TypeScript
39 lines
1.2 KiB
TypeScript
import { ScrollWrapperComponentInstanceContext } from '@/ui/utilities/scroll/states/contexts/ScrollWrapperComponentInstanceContext';
|
|
import { useAvailableComponentInstanceIdOrThrow } from '@/ui/utilities/state/component-state/hooks/useAvailableComponentInstanceIdOrThrow';
|
|
|
|
export const useToggleScrollWrapper = (targetComponentInstanceId?: string) => {
|
|
const instanceId = useAvailableComponentInstanceIdOrThrow(
|
|
ScrollWrapperComponentInstanceContext,
|
|
targetComponentInstanceId,
|
|
);
|
|
|
|
const toggleScrollXWrapper = (isEnabled: boolean) => {
|
|
if (isEnabled) {
|
|
document
|
|
.getElementById(`scroll-wrapper-${instanceId}`)
|
|
?.classList.add('scroll-wrapper-x-enabled');
|
|
} else {
|
|
document
|
|
.getElementById(`scroll-wrapper-${instanceId}`)
|
|
?.classList.remove('scroll-wrapper-x-enabled');
|
|
}
|
|
};
|
|
|
|
const toggleScrollYWrapper = (isEnabled: boolean) => {
|
|
if (isEnabled) {
|
|
document
|
|
.getElementById(`scroll-wrapper-${instanceId}`)
|
|
?.classList.add('scroll-wrapper-y-enabled');
|
|
} else {
|
|
document
|
|
.getElementById(`scroll-wrapper-${instanceId}`)
|
|
?.classList.remove('scroll-wrapper-y-enabled');
|
|
}
|
|
};
|
|
|
|
return {
|
|
toggleScrollXWrapper,
|
|
toggleScrollYWrapper,
|
|
};
|
|
};
|