mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-24 20:36: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 };
|
||||
};
|
|
@ -8,7 +8,6 @@ import { apiGetNode, apiGetNodeComments, getNodeDiff } from '~/api/node';
|
|||
import { NodeHeadMetadata } from '~/components/node/NodeHeadMetadata';
|
||||
import { COMMENTS_DISPLAY } from '~/constants/node';
|
||||
import { useNodeComments } from '~/hooks/comments/useNodeComments';
|
||||
import { useScrollToTop } from '~/hooks/dom/useScrollToTop';
|
||||
import { useImageModal } from '~/hooks/navigation/useImageModal';
|
||||
import { useLoadNode } from '~/hooks/node/useLoadNode';
|
||||
import { useNodePageParams } from '~/hooks/node/useNodePageParams';
|
||||
|
@ -107,8 +106,6 @@ const NodePage: FC<Props> = observer(props => {
|
|||
);
|
||||
const [canEdit] = useNodePermissions(node);
|
||||
|
||||
useScrollToTop([id, isLoadingComments]);
|
||||
|
||||
if (!node) {
|
||||
// TODO: do something here
|
||||
return null;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue