Skip to content

Instantly share code, notes, and snippets.

View allejo's full-sized avatar
🐢
mr. tortle says hi

Vladimir Jimenez allejo

🐢
mr. tortle says hi
View GitHub Profile
@allejo
allejo / what-forces-layout.md
Created January 6, 2022 20:10 — 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
@allejo
allejo / onblur.jsx
Last active May 10, 2019 17:42 — forked from pstoica/OnBlurComponent.jsx
onBlur for entire react component
var HelloMessage = React.createClass({
render: function() {
return <div tabIndex="1" onBlur={this.onBlur}>
Hello <input type="text" value="wat"/>
</div>;
},
onBlur: function(e) {
var currentTarget = e.currentTarget;
@allejo
allejo / map-reverse.scss
Created November 17, 2015 07:28 — forked from seanislegend/map-reverse.scss
Reverse the order of a SASS map.
@function mapReverse ($map) {
$result: null;
@if type-of($map) == "map" {
$keys: map-keys($map);
$map-reversed: ();
@for $i from length($keys) through 1 {
$map-reversed: map-merge(
$map-reversed,