Last active
March 16, 2019 00:31
-
-
Save mmousawy/b10ceeb97c31dcd8a308d44bbb3d369d to your computer and use it in GitHub Desktop.
Revisions
-
mmousawy revised this gist
Mar 16, 2019 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,8 +1,11 @@ // Easy immediately invoked function expression (IIFE) to find the current scrollbar width in browser // Returns a number of scrollbar width in pixels const scrollBarWidth = (() => { const a = document.createElement('div'); document.body.appendChild(a).style.overflowY = 'scroll'; const w = a.offsetWidth - a.clientWidth; a.remove(); return w; })(); console.log(scrollBarWidth); -
mmousawy created this gist
Mar 16, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ // Easy immediately invoked function expression (IIFE) to find the current scrollbar width in browser const scrollBarWidth = (() => { const a = document.createElement('div'); document.body.appendChild(a).style.overflowY = 'scroll'; return a.offsetWidth - a.clientWidth; })(); console.log(scrollBarWidth);