Skip to content

Instantly share code, notes, and snippets.

@KoryNunn
Created October 27, 2015 05:01
Show Gist options
  • Select an option

  • Save KoryNunn/4dcaf102e4f80cceca3b to your computer and use it in GitHub Desktop.

Select an option

Save KoryNunn/4dcaf102e4f80cceca3b to your computer and use it in GitHub Desktop.
requirebin sketch
// require() some stuff from npm (like you were using browserify)
// and then hit Run Code to run it on the right
var laidout = require('laidout');
var textHolder = document.createElement('span');
textHolder.innerText = 'Hello world';
laidout(textHolder, function(){
document.body.innerHTML += '<br />laidout detection ' +textHolder.offsetWidth;
});
document.body.appendChild(textHolder);
document.body.innerHTML += '<br />Initial detection ' + textHolder.offsetWidth;
require=function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({laidout:[function(require,module,exports){function checkElement(element){if(!element){return false}var parentNode=element.parentNode;while(parentNode){if(parentNode===element.ownerDocument){return true}parentNode=parentNode.parentNode}return false}module.exports=function laidout(element,callback){if(checkElement(element)){return callback()}var recheckElement=function(){if(checkElement(element)){document.removeEventListener("DOMNodeInserted",recheckElement);callback()}};document.addEventListener("DOMNodeInserted",recheckElement)}},{}]},{},[]);var laidout=require("laidout");var textHolder=document.createElement("span");textHolder.innerText="Hello world";laidout(textHolder,function(){document.body.innerHTML+="<br />laidout detection "+textHolder.offsetWidth});document.body.appendChild(textHolder);document.body.innerHTML+="<br />Initial detection "+textHolder.offsetWidth;
{
"name": "requirebin-sketch",
"version": "1.0.0",
"dependencies": {
"laidout": "1.0.0"
}
}
<!-- contents of this file will be placed inside the <body> -->
<!-- contents of this file will be placed inside the <head> -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment