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(frame)
  }

  function handleResize () {
    if (called) return
    called = true
    window.requestAnimationFrame(function () {
      called = false
      cb(el)
    })
  }
}
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')

  
  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(frame)
  }

  function handleResize () {
    if (called) return
    called = true
    window.requestAnimationFrame(function () {
      called = false
      cb(el)
    })
  }
}
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 ( frame ) } function handleResize ( ) { if ( called ) return called = true window . requestAnimationFrame ( function ( ) { called = false cb ( el ) } ) } }
Trigger a callback when an element is resized
Trigger a callback when an element is resized