Skip to content

Instantly share code, notes, and snippets.

View guacamoli's full-sized avatar

Sahil Amoli guacamoli

View GitHub Profile

Keybase proof

I hereby claim:

  • I am guacamoli on github.
  • I am guacamoli (https://keybase.io/guacamoli) on keybase.
  • I have a public key ASAXoXjxY7WMPwRpw0Rq8atgoIKsXZT1elvp7eBuG9Zgbgo

To claim this, I am signing this object:

@guacamoli
guacamoli / truncated-node.js
Last active October 24, 2017 23:49
Helper to figure out if a rendered element is truncated
// Working example in jsfiddle: https://jsfiddle.net/Ld2pjabu/5/
// Helper to get the width of any element
function getElementWidth(element) {
return (element && element.getBoundingClientRect) ? element.getBoundingClientRect().width : 0;
}
// Helper to calculate an unbound width
function getUnboundWidth(element) {
// Clone the element in question