Skip to content
This repository was archived by the owner on Oct 19, 2021. It is now read-only.

Commit dcdc8ec

Browse files
asudohiangfleming
authored andcommitted
perf(floating-menu): reduce forced synchronous layout (#79)
1 parent bb1a90d commit dcdc8ec

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

components/OverflowMenu.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ class OverflowMenu extends Component {
4545
};
4646

4747
componentDidMount() {
48-
this.getMenuPosition();
48+
requestAnimationFrame(() => {
49+
this.getMenuPosition();
50+
});
4951
this.hResize = OptimizedResize.add(() => {
5052
this.getMenuPosition();
5153
});

components/Tooltip.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ class Tooltip extends Component {
2929
};
3030

3131
componentDidMount() {
32-
this.getTriggerPosition();
32+
requestAnimationFrame(() => {
33+
this.getTriggerPosition();
34+
});
3335
}
3436

3537
getTriggerPosition = () => {

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,10 @@
137137
"coverageDirectory": "./coverage",
138138
"moduleNameMapper": {
139139
"^.+\\.(scss)$": "<rootDir>/lib/styleMock.js"
140-
}
140+
},
141+
"setupFiles": [
142+
"<rootDir>/setup-jest.js"
143+
]
141144
},
142145
"lint-staged": {
143146
"*.js": [

setup-jest.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
window.requestAnimationFrame = (callback) => { callback(); };

0 commit comments

Comments
 (0)