Skip to content

Instantly share code, notes, and snippets.

View liuyib's full-sized avatar

云泥 liuyib

View GitHub Profile
@liuyib
liuyib / .cz-config.js
Created May 22, 2019 05:32 — forked from leohxj/.cz-config.js
cz-customizable with emoji
'use strict';
module.exports = {
types: [
{
value: 'WIP',
name : '💪 WIP: Work in progress'
},
{
@liuyib
liuyib / format-detection.html
Created July 15, 2020 07:46 — forked from yuezk/format-detection.html
HTML format-detection meta tag
<meta name="format-detection" content="telephone=no">
<meta name="format-detection" content="date=no">
<meta name="format-detection" content="address=no">
<meta name="format-detection" content="email=no">
@liuyib
liuyib / useRect.js
Created June 7, 2021 16:13 — forked from morajabi/useRect.js
useRect — getBoundingClientRect() React Hook with resize handler
import { useLayoutEffect, useCallback, useState } from 'react'
export const useRect = (ref) => {
const [rect, setRect] = useState(getRect(ref ? ref.current : null))
const handleResize = useCallback(() => {
if (!ref.current) {
return
}
@liuyib
liuyib / what-forces-layout.md
Created July 29, 2022 02:22 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent