preline icon indicating copy to clipboard operation
preline copied to clipboard

Fix get body current scrollbar size overlay

Open haohuynhtn2005 opened this issue 4 weeks ago • 0 comments

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

haohuynhtn2005 avatar Dec 11 '25 06:12 haohuynhtn2005