1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-25 04:46:40 +07:00

fixed window callers

This commit is contained in:
Fedor Katurov 2022-01-07 19:16:42 +07:00
parent ba2e610e01
commit 224c27b6f4
6 changed files with 55 additions and 26 deletions

View file

@ -1,11 +1,12 @@
import React, { FC, useCallback } from "react";
import { SortEnd } from "react-sortable-hoc";
import { IFile } from "~/redux/types";
import { moveArrItem } from "~/utils/fn";
import { SortableAudioGrid } from "~/components/editors/SortableAudioGrid";
import React, { FC, useCallback } from 'react';
import { SortEnd } from 'react-sortable-hoc';
import { IFile } from '~/redux/types';
import { moveArrItem } from '~/utils/fn';
import { SortableAudioGrid } from '~/components/editors/SortableAudioGrid';
import styles from "./styles.module.scss";
import { UploadStatus } from "~/store/uploader/UploaderStore";
import styles from './styles.module.scss';
import { UploadStatus } from '~/store/uploader/UploaderStore';
import { useWindowSize } from '~/hooks/dom/useWindowSize';
interface IProps {
files: IFile[];
@ -14,6 +15,8 @@ interface IProps {
}
const AudioGrid: FC<IProps> = ({ files, setFiles, locked }) => {
const { innerWidth } = useWindowSize();
const onMove = useCallback(
({ oldIndex, newIndex }: SortEnd) => {
setFiles(
@ -53,7 +56,7 @@ const AudioGrid: FC<IProps> = ({ files, setFiles, locked }) => {
axis="xy"
items={files}
locked={locked}
pressDelay={window.innerWidth < 768 ? 200 : 0}
pressDelay={innerWidth < 768 ? 200 : 0}
helperClass={styles.helper}
/>
);

View file

@ -1,10 +1,11 @@
import React, { FC, useCallback } from "react";
import { SortEnd } from "react-sortable-hoc";
import styles from "./styles.module.scss";
import { IFile } from "~/redux/types";
import { moveArrItem } from "~/utils/fn";
import { SortableImageGrid } from "~/components/editors/SortableImageGrid";
import { UploadStatus } from "~/store/uploader/UploaderStore";
import React, { FC, useCallback } from 'react';
import { SortEnd } from 'react-sortable-hoc';
import styles from './styles.module.scss';
import { IFile } from '~/redux/types';
import { moveArrItem } from '~/utils/fn';
import { SortableImageGrid } from '~/components/editors/SortableImageGrid';
import { UploadStatus } from '~/store/uploader/UploaderStore';
import { useWindowSize } from '~/hooks/dom/useWindowSize';
interface IProps {
files: IFile[];
@ -13,6 +14,8 @@ interface IProps {
}
const ImageGrid: FC<IProps> = ({ files, setFiles, locked }) => {
const { innerWidth } = useWindowSize();
const onMove = useCallback(
({ oldIndex, newIndex }: SortEnd) => {
setFiles(
@ -40,7 +43,7 @@ const ImageGrid: FC<IProps> = ({ files, setFiles, locked }) => {
axis="xy"
items={files}
locked={locked}
pressDelay={window.innerWidth < 768 ? 200 : 0}
pressDelay={innerWidth < 768 ? 200 : 0}
helperClass={styles.helper}
/>
);

View file

@ -11,6 +11,7 @@ import { LoaderCircle } from '~/components/input/LoaderCircle';
import { useHistory } from 'react-router';
import classNames from 'classnames';
import { IFlowNode } from '~/redux/types';
import { useWindowSize } from '~/hooks/dom/useWindowSize';
SwiperCore.use([EffectFade, Lazy, Autoplay, Navigation]);
@ -19,9 +20,13 @@ interface Props {
}
export const FlowSwiperHero: FC<Props> = ({ heroes }) => {
const { innerWidth } = useWindowSize();
const [controlledSwiper, setControlledSwiper] = useState<SwiperClass | undefined>(undefined);
const [currentIndex, setCurrentIndex] = useState(heroes.length);
const preset = useMemo(() => (window.innerWidth <= 768 ? PRESETS.cover : PRESETS.small_hero), []);
const preset = useMemo(() => (innerWidth <= 768 ? PRESETS.cover : PRESETS.small_hero), [
innerWidth,
]);
const history = useHistory();
const onNext = useCallback(() => {