mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 04:46:40 +07:00
fixed appearance for new image slider
This commit is contained in:
parent
1aa59eb52c
commit
79c5c3be8d
3 changed files with 28 additions and 8 deletions
|
@ -7,6 +7,7 @@ import { getURL } from '~/utils/dom';
|
||||||
import { UPLOAD_TYPES } from '~/redux/uploads/constants';
|
import { UPLOAD_TYPES } from '~/redux/uploads/constants';
|
||||||
import { PRESETS } from '~/constants/urls';
|
import { PRESETS } from '~/constants/urls';
|
||||||
import * as MODAL_ACTIONS from '~/redux/modal/actions';
|
import * as MODAL_ACTIONS from '~/redux/modal/actions';
|
||||||
|
import { LoaderCircle } from '~/components/input/LoaderCircle';
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
is_loading: boolean;
|
is_loading: boolean;
|
||||||
|
@ -19,7 +20,7 @@ interface IProps {
|
||||||
const NodeImageBlock: FC<IProps> = ({ node, is_loading, updateLayout, modalShowPhotoswipe }) => {
|
const NodeImageBlock: FC<IProps> = ({ node, is_loading, updateLayout, modalShowPhotoswipe }) => {
|
||||||
const [is_animated, setIsAnimated] = useState(false);
|
const [is_animated, setIsAnimated] = useState(false);
|
||||||
const [current, setCurrent] = useState(0);
|
const [current, setCurrent] = useState(0);
|
||||||
const [height, setHeight] = useState(320);
|
const [height, setHeight] = useState(window.innerHeight - 140);
|
||||||
const [loaded, setLoaded] = useState<Record<number, boolean>>({});
|
const [loaded, setLoaded] = useState<Record<number, boolean>>({});
|
||||||
const refs = useRef<Record<number, HTMLDivElement>>({});
|
const refs = useRef<Record<number, HTMLDivElement>>({});
|
||||||
|
|
||||||
|
@ -39,9 +40,12 @@ const NodeImageBlock: FC<IProps> = ({ node, is_loading, updateLayout, modalShowP
|
||||||
useEffect(() => updateLayout(), [loaded]);
|
useEffect(() => updateLayout(), [loaded]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!refs || !refs.current[current] || !loaded[current]) return setHeight(320);
|
if (!refs || !refs.current[current] || !loaded[current])
|
||||||
|
return setHeight(window.innerHeight - 140);
|
||||||
|
|
||||||
const el = refs.current[current];
|
const el = refs.current[current];
|
||||||
const element_height = el.getBoundingClientRect && el.getBoundingClientRect().height;
|
const element_height = el.getBoundingClientRect && el.getBoundingClientRect().height;
|
||||||
|
|
||||||
setHeight(element_height);
|
setHeight(element_height);
|
||||||
}, [refs, current, loaded]);
|
}, [refs, current, loaded]);
|
||||||
|
|
||||||
|
@ -50,6 +54,12 @@ const NodeImageBlock: FC<IProps> = ({ node, is_loading, updateLayout, modalShowP
|
||||||
return () => clearTimeout(timer);
|
return () => clearTimeout(timer);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const onOpenPhotoSwipe = useCallback(() => modalShowPhotoswipe(images, current), [
|
||||||
|
modalShowPhotoswipe,
|
||||||
|
images,
|
||||||
|
current,
|
||||||
|
]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classNames(styles.wrap, { is_loading, is_animated })}>
|
<div className={classNames(styles.wrap, { is_loading, is_animated })}>
|
||||||
<ImageSwitcher
|
<ImageSwitcher
|
||||||
|
@ -59,8 +69,12 @@ const NodeImageBlock: FC<IProps> = ({ node, is_loading, updateLayout, modalShowP
|
||||||
loaded={loaded}
|
loaded={loaded}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div className={styles.image_container} style={{ height }}>
|
<div className={styles.image_container} style={{ height }} onClick={onOpenPhotoSwipe}>
|
||||||
{(is_loading || !loaded[0] || !images.length) && <div className={styles.placeholder} />}
|
{(is_loading || !loaded[0] || !images.length) && (
|
||||||
|
<div className={styles.placeholder}>
|
||||||
|
<LoaderCircle size={72} />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
{images.map((file, index) => (
|
{images.map((file, index) => (
|
||||||
<div
|
<div
|
||||||
|
|
|
@ -51,6 +51,10 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.placeholder {
|
.placeholder {
|
||||||
background: red;
|
width: 100%;
|
||||||
height: 320px;
|
height: calc(100vh - 140px);
|
||||||
|
border-radius: $radius;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,8 @@ const NodePanel: FC<IProps> = memo(
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.place} ref={ref}>
|
<div className={styles.place} ref={ref}>
|
||||||
{stack &&
|
{/*
|
||||||
|
stack &&
|
||||||
createPortal(
|
createPortal(
|
||||||
<NodePanelInner
|
<NodePanelInner
|
||||||
node={node}
|
node={node}
|
||||||
|
@ -62,7 +63,8 @@ const NodePanel: FC<IProps> = memo(
|
||||||
stack
|
stack
|
||||||
/>,
|
/>,
|
||||||
document.body
|
document.body
|
||||||
)}
|
)
|
||||||
|
*/}
|
||||||
|
|
||||||
<NodePanelInner
|
<NodePanelInner
|
||||||
node={node}
|
node={node}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue