Skip to content

Commit

Permalink
Merge pull request #67 from react-component/rename-ant-scrolling-effect
Browse files Browse the repository at this point in the history
refactor: rename switch-scrolling-effect to ant-scrolling-effect
  • Loading branch information
afc163 authored Dec 16, 2019
2 parents 5bda2b8 + ed2ce98 commit 5265cd1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
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

0 comments on commit 5265cd1

Please sign in to comment.