How to use the ember-in-viewport/utils/find-elem function in ember-in-viewport

To help you get started, we’ve selected a few ember-in-viewport examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DockYard / ember-in-viewport / addon / mixins / in-viewport.js View on Github external
get(this, 'viewportListeners').forEach((listener) => {
        let { context, event } = listener;
        context = get(this, 'scrollableArea') || context;
        let elem = findElem(context);
        let { evtListener } = this._evtListenerClosures.find((closure) => event === closure.event) || {};

        elem.removeEventListener(event, evtListener, false);
      });
    }
github DockYard / ember-in-viewport / addon / mixins / in-viewport.js View on Github external
_bindListeners(context = null, event = null, element = null) {
    assert('You must pass a valid context to _bindListeners', context);
    assert('You must pass a valid event to _bindListeners', event);

    let elem = findElem(context);

    let evtListener = (() => this._debouncedEvent('_setViewportEntered', element));
    this._evtListenerClosures.push({ event: event, evtListener });
    elem.addEventListener(event, evtListener, false);
  },
github DockYard / ember-in-viewport / addon / mixins / in-viewport.js View on Github external
_bindScrollDirectionListener(sensitivity = 1) {
    assert('sensitivity cannot be 0', sensitivity);

    const contextEl = get(this, 'scrollableArea') || window;
    const elem = findElem(contextEl);

    this._debouncedEventHandler = this._debouncedEvent.bind(this, '_triggerDidScrollDirection', elem, sensitivity);
    elem.addEventListener('scroll', this._debouncedEventHandler, { passive: true });
  },
github DockYard / ember-in-viewport / addon / mixins / in-viewport.js View on Github external
_unbindScrollDirectionListener() {
    const elementId = get(this, 'elementId');
    const context = get(this, 'scrollableArea') || window;
    const elem = findElem(context);

    if (elem) {
      elem.removeEventListener('scroll', this._debouncedEventHandler, { passive: true });
      delete lastPosition[elementId];
      delete lastDirection[elementId];
    }
  },