UNPKG

@saber2pr/router

Version:

> react-router-dom by hooks api.

21 lines (20 loc) 756 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /* * @Author: saber2pr * @Date: 2019-06-04 14:39:57 * @Last Modified by: saber2pr * @Last Modified time: 2019-06-04 14:57:25 */ var HistoryStore_1 = require("./HistoryStore"); var execute_1 = require("./execute"); function push(url, scrollReset) { if (scrollReset === void 0) { scrollReset = true; } HistoryStore_1.HistoryStore.current = execute_1.execute(HistoryStore_1.HistoryStore.get(), url); window.history.pushState(url, null, url); scrollReset && window.scroll(0, 0); } exports.push = push; window.onpopstate = function (event) { return (HistoryStore_1.HistoryStore.current = execute_1.execute(HistoryStore_1.HistoryStore.get(), event.state)); };