Skip to content

Commit c2a94d3

Browse files
committed
Avoid reflow when closing the drawer
1 parent 84c62f7 commit c2a94d3

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/iapi-frontend.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -191,17 +191,16 @@ store< MiniCart >(
191191

192192
disableScrollingOnBody() {
193193
const { isOpen } = getContext< MiniCartContext >();
194-
const { body } = document;
195-
const scrollBarWidth =
196-
window.innerWidth - document.documentElement.clientWidth;
197-
198194
if ( isOpen ) {
199-
Object.assign( body.style, {
195+
Object.assign( document.body.style, {
200196
overflow: 'hidden',
201-
paddingRight: scrollBarWidth + 'px',
197+
paddingRight:
198+
window.innerWidth -
199+
document.documentElement.clientWidth +
200+
'px',
202201
} );
203202
} else {
204-
Object.assign( body.style, {
203+
Object.assign( document.body.style, {
205204
overflow: '',
206205
paddingRight: 0,
207206
} );

0 commit comments

Comments
 (0)