How to use the raf.cancel function in raf

To help you get started, we’ve selected a few raf 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 jcblw / react-sprite-animator / src / index.js View on Github external
componentWillUnmount () {
    this.unmounting = true
    this.animationId !== null && raf.cancel(this.animationId)
  }
github Prinzhorn / scrollmeister / src / components / MeisterComponent.js View on Github external
disconnectedCallback() {
		//This happens when the element is moved inside the DOM using sth. like insertBefore.
		//In this case we will just ignore the disconnectedCallback, because the Node is not actually disconnected.
		//It is safe to leave the behaviors attached, because stuff like nextSibling and parentElement are defined.
		//A connectedCallback will follow right away.
		//https://twitter.com/WebReflection/status/984400317801476097
		if (this.isConnected) {
			return;
		}

		this._scheduledBatchUpdate = false;
		raf.cancel(this._batchHandle);
		delete this._batchHandle;

		Scrollmeister.detachAllBehaviors(this);

		Scrollmeister.componentDisconnected(this);
	}
github kenjiSpecial / webgl-sketch-dojo / sketches / theme / noise / noise01 / app.js View on Github external
window.addEventListener('keydown', function(ev){
    if(ev.keyCode == 27){
        if(isAnimation) raf.cancel(id);
        else    id = raf(animate);

        isAnimation = !isAnimation;
    }
});
github malte-wessel / react-custom-scrollbars / src / Scrollbars / index.js View on Github external
raf(callback) {
        if (this.timer) raf.cancel(this.timer);
        this.timer = raf(() => {
            this.timer = undefined;
            callback();
        });
    },
github lucafalasco / preact-custom-scrollbars / src / Scrollbars / index.js View on Github external
componentWillUnmount = () => {
    this.unsetDomStyles()
    this.removeListeners()
    caf(this.requestFrame)
    clearTimeout(this.hideTracksTimeout)
    clearInterval(this.detectScrollingInterval)
  }
github malte-wessel / react-custom-scrollbars / src / Scrollbars / index.js View on Github external
componentWillUnmount() {
        this.removeListeners();
        caf(this.requestFrame);
        clearTimeout(this.hideTracksTimeout);
        clearInterval(this.detectScrollingInterval);
    },
github ameyms / react-animated-number / src / AnimatedNumber.jsx View on Github external
endTween() {
        raf.cancel(this.tweenHandle);
        this.setState({
            ...this.state,
            currentValue: this.props.value
        });
    }
github SubmarineInteractive / Lux-Operon / src / components / HomeTransitionCanvas / index.js View on Github external
update() {

    if( this.updateActive ) {
      this.render();
      this.raf = raf( this.update );
    } else {
      raf.cancel( this.raf );
    }
  }

raf

requestAnimationFrame polyfill for node and the browser

MIT
Latest version published 6 years ago

Package Health Score

74 / 100
Full package analysis