utils/positionSticky.js

/**
 * Checks to see CSS position sticky is supported
 *
 * @module positionSticky
 * @return {boolean} - true if position:sticky is supported by the browser
 */
const positionSticky = {
	isSupported: null,
	supported() {
		if ( null === this.isSupported ) {
			const el = document.createElement( 'div' );
			const { style } = el;
			style.cssText = 'position:sticky;position:-webkit-sticky;position:-ms-sticky;';
			this.isSupported = - 1 !== style.position.indexOf( 'sticky' );
		}
		return this.isSupported;
	},
};

export default positionSticky;