Skip to content

Commit

Permalink
fix(hideVisually): remove clip-path from hideVisually
Browse files Browse the repository at this point in the history
The use of `clip-path` harms performance during scroll events in Chrome. In the meantime, browsers
can fall back to using `clip` until this bug in Chrome is fixed.
  • Loading branch information
ughitsaaron authored and bhough committed Sep 7, 2019
1 parent b0762e9 commit b8ef2ba
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
8 changes: 6 additions & 2 deletions docs/assets/polished.js
Original file line number Diff line number Diff line change
Expand Up @@ -1399,7 +1399,6 @@
* 'div': {
* 'border': '0',
* 'clip': 'rect(0 0 0 0)',
* 'clipPath': 'inset(50%)',
* 'height': '1px',
* 'margin': '-1px',
* 'overflow': 'hidden',
Expand All @@ -1410,10 +1409,15 @@
* }
*/
function hideVisually() {
// Note: The use of `clip-path` causes performance degredation on scroll events in Chrome.
// For more information, see:
// * h5bp/html5-boilerplate#2021
// * zurb/foundation-sites#10914
// * twbs/bootstrap#24906
return {
border: '0',
clip: 'rect(0 0 0 0)',
clipPath: 'inset(50%)',
// clipPath: 'inset(50%)',
height: '1px',
margin: '-1px',
overflow: 'hidden',
Expand Down
1 change: 0 additions & 1 deletion docs/docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2002,7 +2002,6 @@ <h3 class='fl m0' id='hidevisually'>
<span class="hljs-string">'div'</span>: {
<span class="hljs-string">'border'</span>: <span class="hljs-string">'0'</span>,
<span class="hljs-string">'clip'</span>: <span class="hljs-string">'rect(0 0 0 0)'</span>,
<span class="hljs-string">'clipPath'</span>: <span class="hljs-string">'inset(50%)'</span>,
<span class="hljs-string">'height'</span>: <span class="hljs-string">'1px'</span>,
<span class="hljs-string">'margin'</span>: <span class="hljs-string">'-1px'</span>,
<span class="hljs-string">'overflow'</span>: <span class="hljs-string">'hidden'</span>,
Expand Down
8 changes: 6 additions & 2 deletions src/mixins/hideVisually.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import type { Styles } from '../types/style'
* 'div': {
* 'border': '0',
* 'clip': 'rect(0 0 0 0)',
* 'clipPath': 'inset(50%)',
* 'height': '1px',
* 'margin': '-1px',
* 'overflow': 'hidden',
Expand All @@ -32,10 +31,15 @@ import type { Styles } from '../types/style'
* }
*/
export default function hideVisually(): Styles {
// Note: The use of `clip-path` causes performance degredation on scroll events in Chrome.
// For more information, see:
// * h5bp/html5-boilerplate#2021
// * zurb/foundation-sites#10914
// * twbs/bootstrap#24906
return {
border: '0',
clip: 'rect(0 0 0 0)',
clipPath: 'inset(50%)',
// clipPath: 'inset(50%)',
height: '1px',
margin: '-1px',
overflow: 'hidden',
Expand Down
1 change: 0 additions & 1 deletion src/mixins/test/__snapshots__/hideVisually.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ exports[`hideVisually should return the CSS in JS 1`] = `
Object {
"border": "0",
"clip": "rect(0 0 0 0)",
"clipPath": "inset(50%)",
"height": "1px",
"margin": "-1px",
"overflow": "hidden",
Expand Down

0 comments on commit b8ef2ba

Please sign in to comment.