mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 12:56:41 +07:00
fixed scroll bugs on photoswipe open
This commit is contained in:
parent
05f09c382c
commit
f87a7882f4
2 changed files with 27 additions and 16 deletions
24
src/utils/hooks/useBlockBackButton.ts
Normal file
24
src/utils/hooks/useBlockBackButton.ts
Normal file
|
@ -0,0 +1,24 @@
|
|||
import { useEffect } from 'react';
|
||||
import { history } from '~/redux/store';
|
||||
|
||||
/**
|
||||
* useBlockBackButton - blocks back navigation and calls {callback}
|
||||
* @param callback
|
||||
*/
|
||||
export const useBlockBackButton = (callback?: () => void) => {
|
||||
useEffect(
|
||||
() =>
|
||||
history.listen((newLocation, action) => {
|
||||
if (action !== 'POP') {
|
||||
return;
|
||||
}
|
||||
|
||||
history.goForward();
|
||||
|
||||
if (callback) {
|
||||
callback();
|
||||
}
|
||||
}),
|
||||
[callback, history]
|
||||
);
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue