Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ Whether character is entered.

improve shake when page scroll bar hidden

`switchScrollingEffect` change body style, and add a class `switch-scrolling-effect` when called, so if you page look abnormal, please check this
`switchScrollingEffect` change body style, and add a class `ant-scrolling-effect` when called, so if you page look abnormal, please check this

```js
import switchScrollingEffect from "./src/switchScrollingEffect";
Expand Down
5 changes: 3 additions & 2 deletions src/switchScrollingEffect.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default close => {
}

// https://github.com/ant-design/ant-design/issues/19729
const scrollingEffectClassName = 'switch-scrolling-effect';
const scrollingEffectClassName = 'ant-scrolling-effect';
const scrollingEffectClassNameReg = new RegExp(
`${scrollingEffectClassName}`,
'g',
Expand All @@ -41,7 +41,8 @@ export default close => {
width: `calc(100% - ${scrollBarSize}px)`,
});
if (!scrollingEffectClassNameReg.test(bodyClassName)) {
document.body.className = `${bodyClassName} ${scrollingEffectClassName}`;
const addClassName = `${bodyClassName} ${scrollingEffectClassName}`;
document.body.className = addClassName.trim();
}
}
};
6 changes: 4 additions & 2 deletions tests/switchScrollingEffect.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import switchScrollingEffect from '../src/switchScrollingEffect';
import { spyElementPrototypes } from '../src/test/domHook';
import getScrollBarSize from '../src/getScrollBarSize';

jest.mock('../src/getScrollBarSize', () => jest.fn().mockImplementation(() => 20));
jest.mock('../src/getScrollBarSize', () =>
jest.fn().mockImplementation(() => 20),
);

/**
* Jest dom default window innerWidth is 1024, innerHeight is 768
Expand Down Expand Up @@ -35,7 +37,7 @@ describe('switchScrollingEffect', () => {
switchScrollingEffect();

expect(document.body.style.cssText).toBe('position: relative;');
expect(document.body.className).toBe(' switch-scrolling-effect');
expect(document.body.className).toBe('ant-scrolling-effect');

// when closed
switchScrollingEffect(true);
Expand Down