mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 04:46:40 +07:00
removed zoom from swiper carousel
This commit is contained in:
parent
25bc810306
commit
bcc6ba26ac
2 changed files with 31 additions and 3 deletions
31
src/hooks/modal/useModalRouting.ts
Normal file
31
src/hooks/modal/useModalRouting.ts
Normal file
|
@ -0,0 +1,31 @@
|
|||
import { useCallback, useMemo } from 'react';
|
||||
|
||||
import { useRouter } from 'next/router';
|
||||
|
||||
/** use this to preserve scrolling and handle back button behaviour on
|
||||
* opening modal
|
||||
*
|
||||
* this will replace url with ?modal=modalName, next you should
|
||||
* show modal for that name and pass params to it
|
||||
*/
|
||||
export const useModalRouting = () => {
|
||||
const router = useRouter();
|
||||
|
||||
const openModal = useCallback(
|
||||
(modalName: string) => {
|
||||
const [path] = router.asPath.split('?');
|
||||
|
||||
void router.push(path + '?modal=' + modalName, path + '?modal=' + modalName, {
|
||||
shallow: true,
|
||||
scroll: false,
|
||||
});
|
||||
},
|
||||
[router]
|
||||
);
|
||||
|
||||
const currentModal = useMemo(() => router.query.modal, [router]);
|
||||
|
||||
console.log(currentModal);
|
||||
|
||||
return { openModal };
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue