1
0
Fork 0
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:
Fedor Katurov 2022-07-22 17:48:09 +07:00
parent 25bc810306
commit bcc6ba26ac
2 changed files with 31 additions and 3 deletions

View 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 };
};