Skip to content

Conversation

@haohuynhtn2005
Copy link

@haohuynhtn2005 haohuynhtn2005 commented Dec 11, 2025

Emulate scrollbar feature in overlay plugin

The current method getScrollbarSize in overlay plugin does not work properly. It produce layout shift:

  1. On phone, overlay plugin adds padding right to the body
  2. On PC when the body does not have overflow content, the plugin still add padding right the body

Desire result

  1. Do not add body padding right on phone
  2. Do not add body padding right when body does not have overlay content

Fix

Calculate the scollbar size before setting body overflow hidden when open overlay

  1. bodyWidth = getComputedStyle(document.body).width;
  2. scrollbarSize = window.innerWidth - bodyWidth

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant