UNPKG

@moxy/react-page-swapper

Version:

An orchestrator that eases out the implementation of page transitions

16 lines (13 loc) 400 B
import _wrap from "lodash/wrap"; let popState = false; if (typeof window !== 'undefined') { window.addEventListener('popstate', () => { popState = true; }); history.pushState = _wrap(history.pushState, (pushState, ...args) => { popState = false; pushState.apply(history, args); }); } const isHistoryEntryFromPopState = () => popState; export default isHistoryEntryFromPopState;