瀏覽代碼

Update vertical slider effects

Ensure vertical styles are reverted when slider unmounts.
pull/1/head
TheoryOfNekomata 1 年之前
父節點
當前提交
d00424d0a5
共有 1 個檔案被更改,包括 14 行新增6 行删除
  1. +14
    -6
      packages/web-kitchensink-reactnext/src/categories/number/react/components/Slider/index.tsx

+ 14
- 6
packages/web-kitchensink-reactnext/src/categories/number/react/components/Slider/index.tsx 查看文件

@@ -137,19 +137,27 @@ export const Slider = React.forwardRef<SliderDerivedElement, SliderProps>(({
}

const {current: slider} = ref;
const parent = slider?.parentElement as HTMLElement;
const grandParent = parent?.parentElement as HTMLElement;

const isNotFirefox = browser !== 'firefox';
if (isNotFirefox && orient === 'vertical' && slider) {
const parent = slider.parentElement as HTMLElement;
const grandParent = parent.parentElement as HTMLElement;
const trueHeight = slider!.parentElement!.clientWidth;
const trueWidth = slider!.parentElement!.clientHeight;
const shouldEffectExecute = isNotFirefox && orient === 'vertical' && slider && parent && grandParent;
if (shouldEffectExecute) {
const trueHeight = parent.clientWidth;
const trueWidth = parent.clientHeight;

grandParent.dataset.height = grandParent.clientHeight.toString();
grandParent.dataset.width = grandParent.clientWidth.toString();
grandParent.style.height = trueHeight + 'px';
grandParent.style.width = trueWidth + 'px';
}

return () => {
if (slider && isNotFirefox) {
if (shouldEffectExecute) {
grandParent.style.height = grandParent.dataset.height + 'px';
grandParent.style.width = grandParent.dataset.width + 'px';
grandParent.removeAttribute('data-height');
grandParent.removeAttribute('data-width');
}
};
}, [ref, orient, browser]);


Loading…
取消
儲存