How to use stickybits - 10 common examples

To help you get started, we’ve selected a few stickybits 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 pubpub / pubpub / client / containers / Pub / PubMeta / PubMeta.js View on Github external
useEffect(() => {
		const cleanup = () => {
			if (stickyRef.current) {
				try {
					stickyRef.current.cleanup();
				} catch (_) {
					// This sometimes fails if the element's parent has been unmounted. That's okay.
				}
			}
		};
		if (shouldUseSticky(metaMode)) {
			stickyRef.current = stickybits('.pub-meta-component', {
				stickyBitStickyOffset: 35,
				useStickyClasses: true,
			});
		} else if (stickyRef.current) {
			cleanup();
		}
		return cleanup;
	}, [metaMode]);
github pubpub / pubpub / client / containers / Pub / PubDocument / PubHistory / PubHistory.js View on Github external
useEffect(() => {
		stickyRef.current = stickybits('.pub-history-component', {
			stickyBitStickyOffset: 35,
			useStickyClasses: true,
		});
		return () => {
			if (stickyRef.current) {
				try {
					stickyRef.current.cleanup();
				} catch (_) {
					// This sometimes fails if the element's parent has been unmounted. That's okay.
				}
			}
		};
	}, []);
github pubpub / pubpub / client / containers / Pub / PubDocument / PubHeaderFormatting.js View on Github external
useEffect(() => {
		stickyInstanceRef.current = stickybits('.pub-draft-header-component', {
			stickyBitStickyOffset: 35,
			useStickyClasses: true,
		});
		return () => {
			if (stickyInstanceRef.current) {
				stickyInstanceRef.current.cleanup();
			}
		};
	}, []);
github pubpub / pubpub / client / components / PubHeader / PubHeader.js View on Github external
recalculateStickyOffset() {
		const nextOffsetHeight = this.headerRef.current.offsetHeight;
		if (nextOffsetHeight !== this.offsetHeight) {
			this.offsetHeight = nextOffsetHeight;
			this.stickyInstance.cleanup();
			this.stickyInstance = stickybits('.pub-header-component', {
				stickyBitStickyOffset: 35 - this.offsetHeight,
				useStickyClasses: true,
			});
		}
	}
github wasedatime / wasedatime-web / client / src / js / components / syllabus / AddedCourseList.js View on Github external
this.createStickyWrapper = () => {
      if (this.wrapper) {
        this.stickyWrapper = stickybits(this.wrapper, {
          stickyBitStickyOffset:
            parseInt(headerHeight, 10) + parseInt(semesterTabsHeight, 10)
        });
      }
    };
github geosolutions-it / MapStore2 / web / client / components / misc / enhancers / stickySupport.jsx View on Github external
componentDidMount() {
            this._stickybits = this._node && stickybits(this._node, {
                scrollEl: this.props.scrollContainerSelector,
                noStyles: true,
                useGetBoundingClientRect: true
            });
            this.update(this.props.scrollContainerSelector);
        }
github wasedatime / wasedatime-web / client / src / js / components / syllabus / SearchBar.js View on Github external
this.createStickyWrapper = () => {
      if (this.wrapper) {
        this.stickyWrapper = stickybits(this.wrapper, {
          stickyBitStickyOffset: parseInt(headerHeight, 10)
        });
      }
    };
github pubpub / pubpub / client / components / PubHeader / PubHeader.js View on Github external
componentDidMount() {
		this.setState({ isMounted: true });
		this.offsetHeight = this.headerRef.current.offsetHeight;
		this.stickyInstance = stickybits('.pub-header-component', {
			stickyBitStickyOffset: 35 - this.offsetHeight,
			useStickyClasses: true,
		});
		window.addEventListener('resize', this.handleResize);
	}
github pubpub / pubpub / client / containers / Pub / PubHeader / PubHeader.js View on Github external
useEffect(() => {
		if (!isDocMode) {
			return () => {};
		}
		setIsMounted(true);
		const nextOffsetHeight = headerRef.current.offsetHeight;
		const stickyInstance = stickybits('.pub-header-component', {
			stickyBitStickyOffset: 35 - nextOffsetHeight,
			useStickyClasses: true,
		});

		return () => {
			stickyInstance.cleanup();
		};
	}, [pubData, windowWidth, isDocMode]);
github pubpub / pubpub / client / components / PubDraftHeader / PubDraftHeader.js View on Github external
componentDidMount() {
		this.stickyInstance = stickybits('.pub-draft-header-component', {
			stickyBitStickyOffset: 35,
		});
	}

stickybits

Stickybits is a lightweight alternative to `position: sticky` polyfills

MIT
Latest version published 2 years ago

Package Health Score

59 / 100
Full package analysis

Popular stickybits functions