mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 21:06:42 +07:00
simplier slider for images
This commit is contained in:
parent
f4f808d7e5
commit
b88aa32e07
6 changed files with 143 additions and 122 deletions
|
@ -18,6 +18,7 @@
|
|||
height: 100%;
|
||||
animation: fadeIn 2s;
|
||||
will-change: transform, opacity;
|
||||
filter: blur(10px);
|
||||
|
||||
&::after {
|
||||
content: ' ';
|
||||
|
@ -26,7 +27,7 @@
|
|||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: url(~/sprites/stripes.svg) rgba(0, 0, 0, 0.3);
|
||||
background: url(~/sprites/stripes.svg) transparentize($content_bg, 0.2);
|
||||
}
|
||||
|
||||
@include tablet {
|
||||
|
|
|
@ -30,25 +30,18 @@ const NodeImageBlock: FC<IProps> = ({ node, is_loading, updateLayout, modalShowP
|
|||
);
|
||||
|
||||
const setRef = useCallback(index => el => (refs.current[index] = el), [refs]);
|
||||
|
||||
const onImageLoad = useCallback(index => () => setLoaded({ ...loaded, [index]: true }), [
|
||||
setLoaded,
|
||||
loaded,
|
||||
]);
|
||||
|
||||
const onOpenPhotoSwipe = useCallback(
|
||||
(index: number) => () => modalShowPhotoswipe(images, index),
|
||||
[modalShowPhotoswipe, images]
|
||||
);
|
||||
|
||||
useEffect(() => updateLayout(), [loaded]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!refs || !refs.current[current] || !loaded[current]) return setHeight(320);
|
||||
|
||||
const el = refs.current[current];
|
||||
|
||||
const element_height = el.getBoundingClientRect && el.getBoundingClientRect().height;
|
||||
|
||||
setHeight(element_height);
|
||||
}, [refs, current, loaded]);
|
||||
|
||||
|
@ -59,35 +52,33 @@ const NodeImageBlock: FC<IProps> = ({ node, is_loading, updateLayout, modalShowP
|
|||
|
||||
return (
|
||||
<div className={classNames(styles.wrap, { is_loading, is_animated })}>
|
||||
<div>
|
||||
<ImageSwitcher
|
||||
total={images.length}
|
||||
current={current}
|
||||
onChange={setCurrent}
|
||||
loaded={loaded}
|
||||
/>
|
||||
<ImageSwitcher
|
||||
total={images.length}
|
||||
current={current}
|
||||
onChange={setCurrent}
|
||||
loaded={loaded}
|
||||
/>
|
||||
|
||||
<div className={styles.image_container} style={{ height }}>
|
||||
{(is_loading || !loaded[0] || !images.length) && <div className={styles.placeholder} />}
|
||||
<div className={styles.image_container} style={{ height }}>
|
||||
{(is_loading || !loaded[0] || !images.length) && <div className={styles.placeholder} />}
|
||||
|
||||
{images.map((file, index) => (
|
||||
<div
|
||||
className={classNames(styles.image_wrap, {
|
||||
is_active: index === current && loaded[index],
|
||||
})}
|
||||
ref={setRef(index)}
|
||||
{images.map((file, index) => (
|
||||
<div
|
||||
className={classNames(styles.image_wrap, {
|
||||
is_active: index === current && loaded[index],
|
||||
})}
|
||||
ref={setRef(index)}
|
||||
key={file.id}
|
||||
>
|
||||
<img
|
||||
className={styles.image}
|
||||
src={getURL(file, PRESETS['1600'])}
|
||||
alt=""
|
||||
key={file.id}
|
||||
>
|
||||
<img
|
||||
className={styles.image}
|
||||
src={getURL(file, PRESETS['1600'])}
|
||||
alt=""
|
||||
key={file.id}
|
||||
onLoad={onImageLoad(index)}
|
||||
/>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
onLoad={onImageLoad(index)}
|
||||
/>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
.wrap {
|
||||
padding-bottom: $gap * 2;
|
||||
|
||||
&:global(.is_animated) {
|
||||
.image_container {
|
||||
transition: height 0.5s;
|
||||
|
@ -12,7 +14,6 @@
|
|||
|
||||
.image_container {
|
||||
width: 100%;
|
||||
background: $node_image_bg;
|
||||
border-radius: $panel_radius 0 0 $panel_radius;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
@ -22,10 +23,12 @@
|
|||
user-select: none;
|
||||
|
||||
.image {
|
||||
max-height: 960px;
|
||||
max-height: calc(100vh - 140px);
|
||||
max-width: 100%;
|
||||
opacity: 1;
|
||||
border-radius: $radius $radius 0 0;
|
||||
border-radius: $radius;
|
||||
|
||||
@include outer_shadow();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -36,8 +36,9 @@
|
|||
|
||||
@include tablet {
|
||||
border-radius: 0;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
// flex-direction: column;
|
||||
// align-items: flex-start;
|
||||
height: 128px;
|
||||
}
|
||||
|
||||
@include can_backdrop {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue