3 lines
1.1 KiB
JavaScript
3 lines
1.1 KiB
JavaScript
define("local_treestudyplan/util/browserbuttonevents",["exports","./debugger"],(function(_exports,_debugger){var obj;Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.addBrowserButtonEvent=function(backwardCB){let forwardCB=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,reloadCB=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;debug.log("Registering navigation events",backwardCB,forwardCB,reloadCB);addEventListener("popstate",(e=>{const positionLastShown=Number(sessionStorage.getItem("positionLastShown"));let position=history.state;null===position&&(position=positionLastShown+1,history.replaceState(position,"")),sessionStorage.setItem("positionLastShown",String(position));const direction=Math.sign(position-positionLastShown);debug.log("Travel direction is "+direction),-1==direction&&backwardCB&&backwardCB(),1==direction&&forwardCB&&forwardCB(),0==direction&&reloadCB&&reloadCB()}))};const debug=new(_debugger=(obj=_debugger)&&obj.__esModule?obj:{default:obj}).default("browserbuttonevents")}));
|
|
|
|
//# sourceMappingURL=browserbuttonevents.min.js.map
|