How to use subscribe-ui-event - 10 common examples

To help you get started, we’ve selected a few subscribe-ui-event 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 yahoo / react-i13n / src / libs / ComponentSpecs.js View on Github external
componentDidMount() {
    const self = this;
    const reactI13n = self._getReactI13n();
    if (!reactI13n) {
      return;
    }

    // bind the click event for i13n component if it's enabled
    if (self.props.bindClickEvent) {
      self.clickEventListener = listen(ReactDOM.findDOMNode(self), 'click', clickHandler.bind(self));
    }

    const domNode = ReactDOM.findDOMNode(self);
    self._i13nNode.setDOMNode(domNode);

    // enable viewport checking if enabled
    if (reactI13n.isViewportEnabled()) {
      self._viewportDetector = new ViewportDetector(domNode, self._getViewportOptions(), () => {
        self._handleEnterViewport();
      });
      if (pageInitViewportDetected) {
        self._viewportDetector.init();
      } else {
        self._triggerPageInitViewportDetection();
      }
    }
github yahoo / react-i13n / src / libs / ViewportDetector.js View on Github external
ViewportDetector.prototype.init = function (skipInitDetection) {
  // detect viewport and execute handler if it's initially in the viewport
  if (!skipInitDetection) {
    this._detectViewport();
  }

  if (!this._enteredViewport) {
    this._subscribers = [subscribe('scrollEnd', this._detectViewport.bind(this), this._options)];
  }
};
github yahoo / react-stickynode / src / Sticky.jsx View on Github external
TRANSFORM_PROP = M.prefixed('transform');
            }
        }

        // when mount, the scrollTop is not necessary on the top
        this.scrollTop = docBody.scrollTop + docEl.scrollTop;

        if (this.props.enabled) {
            this.setState({activated: true});
            this.updateInitialDimension();
            this.update();
        }
        // bind the listeners regardless if initially enabled - allows the component to toggle sticky functionality
        this.subscribers = [
            subscribe('scrollStart', this.handleScrollStart.bind(this), {useRAF: true}),
            subscribe('scroll', this.handleScroll.bind(this), {useRAF: true, enableScrollInfo: true}),
            subscribe('resize', this.handleResize.bind(this), {enableResizeInfo: true})
        ];
    }
github yahoo / react-stickynode / src / Sticky.jsx View on Github external
}
        }

        // when mount, the scrollTop is not necessary on the top
        this.scrollTop = docBody.scrollTop + docEl.scrollTop;

        if (this.props.enabled) {
            this.setState({activated: true});
            this.updateInitialDimension();
            this.update();
        }
        // bind the listeners regardless if initially enabled - allows the component to toggle sticky functionality
        this.subscribers = [
            subscribe('scrollStart', this.handleScrollStart.bind(this), {useRAF: true}),
            subscribe('scroll', this.handleScroll.bind(this), {useRAF: true, enableScrollInfo: true}),
            subscribe('resize', this.handleResize.bind(this), {enableResizeInfo: true})
        ];
    }
github yahoo / react-stickynode / src / Sticky.jsx View on Github external
canEnableTransforms = M.csstransforms3d;
                TRANSFORM_PROP = M.prefixed('transform');
            }
        }

        // when mount, the scrollTop is not necessary on the top
        this.scrollTop = docBody.scrollTop + docEl.scrollTop;

        if (this.props.enabled) {
            this.setState({activated: true});
            this.updateInitialDimension();
            this.update();
        }
        // bind the listeners regardless if initially enabled - allows the component to toggle sticky functionality
        this.subscribers = [
            subscribe('scrollStart', this.handleScrollStart.bind(this), {useRAF: true}),
            subscribe('scroll', this.handleScroll.bind(this), {useRAF: true, enableScrollInfo: true}),
            subscribe('resize', this.handleResize.bind(this), {enableResizeInfo: true})
        ];
    }
github wavesplatform / wavesplatform.com / src / common / utils / viewport.js View on Github external
constructor() {
    this._handleScroll = this._handleScroll.bind(this);
    this._handleResize = this._handleResize.bind(this);

    subscribe('scroll', this._handleScroll, {
      useRAF: true,
      enableScrollInfo: true,
    });

    subscribe('touchmove', this._handleScroll, {
      useRAF: true,
      enableScrollInfo: true,
    });

    subscribe('resize', this._handleResize, {
      useRAF: true,
      enableResizeInfo: true,
    });

    this._handleScroll(null, {
      scroll: {
        top: canUseDOM ? window.pageYOffset : 0,
      },
    });

    this._handleResize(null, {
      resize: {
        width: canUseDOM ? window.innerWidth : 0,
        height: canUseDOM ? window.innerHeight : 0,
      },
    });
github yahoo / react-i13n / src / mixins / viewport / ViewportMixin.js View on Github external
subscribeViewportEvents: function (options) {
        this.subscription = subscribe('scrollEnd', this._detectViewport, options || {});
    },
github wavesplatform / wavesplatform.com / src / common / utils / viewport.js View on Github external
subscribe(eventName, handler, options = {}) {
    return subscribe(eventName, handler, {
      useRAF: true,
      ...options,
    });
  }
}
github wavesplatform / wavesplatform.com / src / common / utils / viewport.js View on Github external
constructor() {
    this._handleScroll = this._handleScroll.bind(this);
    this._handleResize = this._handleResize.bind(this);

    subscribe('scroll', this._handleScroll, {
      useRAF: true,
      enableScrollInfo: true,
    });

    subscribe('touchmove', this._handleScroll, {
      useRAF: true,
      enableScrollInfo: true,
    });

    subscribe('resize', this._handleResize, {
      useRAF: true,
      enableResizeInfo: true,
    });

    this._handleScroll(null, {
      scroll: {
github wavesplatform / wavesplatform.com / src / common / components / Scrim / index.js View on Github external
componentDidMount() {
    this._scrollEvent = subscribe('scroll', this.handleScroll, {
      useRAF: true,
    });

    this._resizeEvent = subscribe('resize', this.handleResize, {
      useRAF: true,
      throttleRate: 300,
    });

    setInterval(() => {
      const rect = this.$root.getBoundingClientRect();
      const top = rect.top + viewport.pageY;
      const bottom = top + rect.height;

      this.height = rect.height;
      this.startPx = bottom - 0.5 * viewport.height;
      this.endPx = bottom;

subscribe-ui-event

A single, throttle built-in solution to subscribe to browser UI Events.

Unrecognized
Latest version published 4 years ago

Package Health Score

69 / 100
Full package analysis

Popular subscribe-ui-event functions