diff --git a/plugins/woocommerce-blocks/assets/js/base/hooks/use-position-relative-to-viewport.js b/plugins/woocommerce-blocks/assets/js/base/hooks/use-position-relative-to-viewport.js index 31444b50ad5..06e94e7f457 100644 --- a/plugins/woocommerce-blocks/assets/js/base/hooks/use-position-relative-to-viewport.js +++ b/plugins/woocommerce-blocks/assets/js/base/hooks/use-position-relative-to-viewport.js @@ -2,7 +2,6 @@ * External dependencies */ import { useRef, useLayoutEffect, useState } from '@wordpress/element'; -import { getIntersectionObserver } from '@woocommerce/base-utils'; /** @typedef {import('react')} React */ @@ -50,7 +49,7 @@ export const usePositionRelativeToViewport = () => { ] = useState( '' ); const referenceElementRef = useRef( null ); const intersectionObserver = useRef( - getIntersectionObserver( + new IntersectionObserver( ( entries ) => { if ( entries[ 0 ].isIntersecting ) { setPositionRelativeToViewport( 'visible' ); diff --git a/plugins/woocommerce-blocks/assets/js/base/utils/get-intersection-observer.js b/plugins/woocommerce-blocks/assets/js/base/utils/get-intersection-observer.js deleted file mode 100644 index 47025bff609..00000000000 --- a/plugins/woocommerce-blocks/assets/js/base/utils/get-intersection-observer.js +++ /dev/null @@ -1,26 +0,0 @@ -/** @typedef {import('window').IntersectionObserverCallback} IntersectionObserverCallback */ - -/** - * Util that returns an IntersectionObserver if supported by the browser. If - * it's not supported, it returns a shim object with the methods to prevent JS - * errors. Notice it's a shim, not a polyfill. If the browser doesn't support - * IntersectionObserver, the methods returned by this function will do nothing. - * - * @param {IntersectionObserverCallback} callback Callback function for the - * Intersection Observer. - * @param {Object} options Intersection Observer options. - * @return {Object|IntersectionObserver} Intersection Observer if available, - * otherwise a shim object. - * - * @todo Remove IntersectionObserver shim when we drop IE11 support. - */ -export const getIntersectionObserver = ( callback, options ) => { - if ( typeof IntersectionObserver !== 'function' ) { - return { - observe: () => void null, - unobserve: () => void null, - }; - } - - return new IntersectionObserver( callback, options ); -}; diff --git a/plugins/woocommerce-blocks/assets/js/base/utils/index.js b/plugins/woocommerce-blocks/assets/js/base/utils/index.js index 59ebbab1835..4090cadc9c5 100644 --- a/plugins/woocommerce-blocks/assets/js/base/utils/index.js +++ b/plugins/woocommerce-blocks/assets/js/base/utils/index.js @@ -3,7 +3,6 @@ export * from './address'; export * from './shipping-rates'; export * from './legacy-events'; export * from './render-frontend'; -export * from './get-intersection-observer'; export * from './get-valid-block-attributes'; export * from './product-data'; export * from './derive-selected-shipping-rates';