Skip to content

Instantly share code, notes, and snippets.

@kolombet
kolombet / AutoCaptureGLThing.js
Created July 15, 2017 12:26 — forked from gre/AutoCaptureGLThing.js
example that render things offscreen with gl-react – would love if you find a way to make this use-case less hacky
class AutoCaptureGLThing extends Component {
onRef = exportable => {
if (!exportable || this.exporting) return;
this.exporting = true;
exportable.captureFrame(/* see https://projectseptemberinc.gitbooks.io/gl-react/content/docs/api/Surface.html */)
.then(path => { // oops back to node callback pattern via props callback
this.props.onCapture(null, path);
}, error => {
this.props.onCapture(error);
});
@kolombet
kolombet / what-forces-layout.md
Created April 11, 2017 13:16 — 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.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
@kolombet
kolombet / promisesEM.md
Created June 22, 2016 14:10 — forked from dmvaldman/promisesEM.md
Promises as EventEmitters

Promises as EventEmitters

I was trying to understand JavaScript Promises by using various libraries (bluebird, when, Q) and other async approaches.

I read the spec, some blog posts, and looked through some code. I learned how to

@kolombet
kolombet / 0_reuse_code.js
Created October 7, 2015 09:17
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
function scaleAroundPoint(target:DisplayObject, point:Point, scaleFactor:Number):void
{
var m:Matrix = target.transform.matrix;
m.translate( -point.x, -point.y );
m.scale( scaleFactor, scaleFactor);
m.translate( point.x, point.y );
target.transform.matrix = m;
}