Esempio n. 1
0
    this.element.classList[bottom <= window.innerHeight && !isContentBelow ? 'add' : 'remove']('fix-footer--fixed')
  },

  _debounceResize: function () {
    clearTimeout(this._debounceResizeTimer)
    this._debounceResizeTimer = setTimeout(function () {
      if (this._resizeHeight !== window.innerHeight) {
        this._resizeHeight = window.innerHeight
        this._reset()
      }
    }.bind(this), 50)
  },

  init: function () {
    this._debounceResize = this._debounceResize.bind(this)
    window.addEventListener('load', function () {
      this._reset()
      this._resizeHeight = window.innerHeight
      window.addEventListener('resize', this._debounceResize)
    }.bind(this))
  },

  destroy: function () {
    clearTimeout(this._debounceResizeTimer)
    window.removeEventListener('resize', this._debounceResize)
  }
})

handler.register('fix-footer', footerComponent)
Esempio n. 2
0
      }, 50)
    }
  },

  /**
   * Initialize component
   */
  init () {
    this._resizeWidth = window.innerWidth

    this.attachToScrollTarget()
    this._handleFixedPositionedScroll()
    this._setupBackgrounds()

    this._primary.setAttribute('data-primary', 'data-primary')
    this._primary.classList[(this.fixed || this.condenses) ? 'add' : 'remove'](MODIFIER_FIXED)

    SCROLL_EFFECTS.concat(HEADER_SCROLL_EFFECTS).map(effect => this.registerEffect(effect.name, effect))
  },

  /**
   * Destroy component
   */
  destroy () {
    clearTimeout(this._onResizeTimeout)
    this.detachFromScrollTarget()
  }
})

handler.register(MODULE, headerComponent)