How to use the ember-in-viewport/-private/raf-admin.startRAF 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 / services / in-viewport.js View on Github external
scheduleOnce('afterRender', this, () => {
        // grab the user added callbacks when we enter/leave the element
        const {
          enterCallback = noop,
          exitCallback = noop
        } = this.getCallbacks(element) || {};
        // this isn't using the same functions as the mixin case, but that is b/c it is a bit harder to unwind.
        // So just rewrote it with pure functions for now
        startRAF(
          element,
          configOptions,
          enterCallback,
          exitCallback,
          this.addRAF.bind(this, element.id),
          this.removeRAF.bind(this, element.id)
        );
      });
    }
github DockYard / ember-in-viewport / addon / mixins / in-viewport.js View on Github external
const isTearingDown = this.isDestroyed || this.isDestroying;
        const viewportEntered = element.getAttribute('data-in-viewport-entered') === "true";
        if (!isTearingDown && (viewportSpy || viewportEntered)) {
          set(this, 'viewportEntered', true);
          this.trigger('didEnterViewport');
        }
      }
      const exitCallback = () => {
        const isTearingDown = this.isDestroyed || this.isDestroying;
        if (!isTearingDown && viewportSpy) {
          set(this, 'viewportEntered', false);
          this.trigger('didExitViewport');
        }
      }

      startRAF(
        element,
        { scrollableArea, viewportTolerance, viewportSpy },
        enterCallback,
        exitCallback,
        inViewport.addRAF.bind(inViewport, element.id),
        inViewport.removeRAF.bind(inViewport, element.id)
      );
    } else {
      return scheduleOnce('afterRender', this, () => {
        this._setViewportEntered(element);
      });
    }
  },