repo_description: A decentralized messaging and sharing app built on top of Secure Scuttlebutt (SSB).
repo_topics: decentralized decentralized-messaging electron javascript linux macos nodejs off-grid offline p2p scuttlebutt server social social-network ssb windows
code: module.exports = ExpanderHook
  
  function ExpanderHook (needsExpand) {
    return expander.bind(null, needsExpand)
  }
  
  function expander (needsExpand, element) {
    const handler = { handleEvent, needsExpand, element }
    handleEvent.call(handler)
  
    if (element.querySelector('img')) {
      // just in case images are still loading
      setTimeout(handleEvent.bind(handler), 200)
      element.addEventListener('mouseover', handler)
      return element.removeEventListener.bind(element, 'mouseover', handler)
    }
  }
  
  function handleEvent () {
    const { needsExpand, element } = this
    if (!needsExpand()) {
      if (element.firstElementChild && element.firstElementChild.clientHeight + 5 > element.clientHeight) {
        needsExpand.set(true)
      }
    }
  }
  