nl_tokens: Trigger a callback when an element is resized
pl_tokens: function observeResize ( el , cb ) { assert . ok ( isDom ( el ) , 'observe-resize: el should be a valid DOM element' ) assert . equal ( typeof cb , 'function' , 'observe-resize: cb should be type function' ) // Make this function a noop in non-browser environments if ( typeof window !== 'object' ) return var called = false var frame = document . createElement ( 'iframe' ) frame . setAttribute ( 'class' , '__observe-resize__' ) el . appendChild ( frame ) assert . ok ( frame . contentWindow , 'observe-resize: no contentWindow detected - cannot start observing' ) frame . contentWindow . onresize = handleResize return function stopObserving ( ) { if ( frame . parentNode ) frame . parentNode . removeChild ( <mask> ) } function handleResize ( ) { if ( called ) return called = true window . requestAnimationFrame ( function ( ) { called = false cb ( el ) } ) } }