mirror of
https://github.com/responsively-org/responsively-app
synced 2024-09-20 22:31:59 +00:00
Prevent reloading for same page URL hash change, Fixes #100
This commit is contained in:
parent
d5bc371913
commit
c49730c1e0
1 changed files with 18 additions and 0 deletions
|
@ -116,10 +116,28 @@ export function onAddressChange(newURL, force) {
|
|||
return;
|
||||
}
|
||||
|
||||
const isHashDiff = isHashOnlyChange(newURL, address);
|
||||
|
||||
if (isHashDiff) {
|
||||
return;
|
||||
}
|
||||
|
||||
dispatch(newAddress(newURL));
|
||||
};
|
||||
}
|
||||
|
||||
function isHashOnlyChange(newURL, oldURL) {
|
||||
if (!newURL || !oldURL) {
|
||||
return false;
|
||||
}
|
||||
let diff = newURL.replace(oldURL, '').trim();
|
||||
if (diff.startsWith('/')) {
|
||||
diff = diff.substring(1);
|
||||
}
|
||||
|
||||
return diff.startsWith('#');
|
||||
}
|
||||
|
||||
export function onZoomChange(newLevel) {
|
||||
return (dispatch: Dispatch, getState: RootStateType) => {
|
||||
const {
|
||||
|
|
Loading…
Reference in a new issue