mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 12:56:41 +07:00
arrows markup
This commit is contained in:
parent
25a59bf944
commit
ada2e59676
2 changed files with 114 additions and 43 deletions
|
@ -10,6 +10,7 @@ import { PRESETS } from '~/constants/urls';
|
||||||
import { LoaderCircle } from '~/components/input/LoaderCircle';
|
import { LoaderCircle } from '~/components/input/LoaderCircle';
|
||||||
import { throttle } from 'throttle-debounce';
|
import { throttle } from 'throttle-debounce';
|
||||||
import * as MODAL_ACTIONS from '~/redux/modal/actions';
|
import * as MODAL_ACTIONS from '~/redux/modal/actions';
|
||||||
|
import { Icon } from '~/components/input/Icon';
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
is_loading: boolean;
|
is_loading: boolean;
|
||||||
|
@ -183,7 +184,7 @@ const NodeImageSlideBlock: FC<IProps> = ({
|
||||||
setIsDragging(false);
|
setIsDragging(false);
|
||||||
normalizeOffset();
|
normalizeOffset();
|
||||||
|
|
||||||
if (Math.abs(new Date().getTime() - drag_start) < 200 && initial_x - getX(event) < 50) {
|
if (Math.abs(new Date().getTime() - drag_start) < 200 && initial_x - getX(event) < 20) {
|
||||||
onOpenPhotoSwipe();
|
onOpenPhotoSwipe();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -233,57 +234,77 @@ const NodeImageSlideBlock: FC<IProps> = ({
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classNames(styles.wrap, { [styles.is_loading]: is_loading })} ref={wrap}>
|
<div className={styles.wrap}>
|
||||||
<div
|
<div className={classNames(styles.cutter, { [styles.is_loading]: is_loading })} ref={wrap}>
|
||||||
className={classNames(styles.placeholder, {
|
<div
|
||||||
[styles.is_loading]: is_loading || !loaded[current],
|
className={classNames(styles.placeholder, {
|
||||||
})}
|
[styles.is_loading]: is_loading || !loaded[current],
|
||||||
>
|
})}
|
||||||
<div>
|
>
|
||||||
<LoaderCircle size={96} />
|
<div>
|
||||||
|
<LoaderCircle size={96} />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div
|
<div
|
||||||
className={classNames(styles.image_container, { [styles.is_dragging]: is_dragging })}
|
className={classNames(styles.image_container, { [styles.is_dragging]: is_dragging })}
|
||||||
style={{
|
style={{
|
||||||
height,
|
height,
|
||||||
transform: `translate(${offset}px, 0)`,
|
transform: `translate(${offset}px, 0)`,
|
||||||
width: `${images.length * 100}%`,
|
width: `${images.length * 100}%`,
|
||||||
}}
|
}}
|
||||||
onMouseDown={startDragging}
|
onMouseDown={startDragging}
|
||||||
onTouchStart={startDragging}
|
onTouchStart={startDragging}
|
||||||
ref={slide}
|
ref={slide}
|
||||||
>
|
>
|
||||||
{!is_loading &&
|
{!is_loading &&
|
||||||
images.map((file, index) => (
|
images.map((file, index) => (
|
||||||
<div
|
<div
|
||||||
className={classNames(styles.image_wrap, {
|
className={classNames(styles.image_wrap, {
|
||||||
is_active: index === current && loaded[index],
|
is_active: index === current && loaded[index],
|
||||||
})}
|
})}
|
||||||
ref={setRef(index)}
|
ref={setRef(index)}
|
||||||
key={node.updated_at + file.id}
|
key={node.updated_at + file.id}
|
||||||
>
|
>
|
||||||
<img
|
<img
|
||||||
className={styles.image}
|
className={styles.image}
|
||||||
src={getURL(file, PRESETS['1600'])}
|
src={getURL(file, PRESETS['1600'])}
|
||||||
alt=""
|
alt=""
|
||||||
key={file.id}
|
key={file.id}
|
||||||
onLoad={onImageLoad(index)}
|
onLoad={onImageLoad(index)}
|
||||||
style={{ maxHeight: max_height }}
|
style={{ maxHeight: max_height }}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{!is_loading && (
|
{images.length > 1 && (
|
||||||
|
<div className={styles.image_count}>
|
||||||
|
{current + 1}
|
||||||
|
<small> / </small>
|
||||||
|
{images.length}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/*
|
||||||
|
!is_loading && (
|
||||||
<ImageSwitcher
|
<ImageSwitcher
|
||||||
total={images.length}
|
total={images.length}
|
||||||
current={current}
|
current={current}
|
||||||
onChange={changeCurrent}
|
onChange={changeCurrent}
|
||||||
loaded={loaded}
|
loaded={loaded}
|
||||||
/>
|
/>
|
||||||
)}
|
)
|
||||||
|
*/}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className={classNames(styles.image_arrow)}>
|
||||||
|
<Icon icon="left" size={40} />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className={classNames(styles.image_arrow, styles.image_arrow_right)}>
|
||||||
|
<Icon icon="right" size={40} />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
.wrap {
|
.wrap {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cutter {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
position: relative;
|
position: relative;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
|
@ -52,12 +56,58 @@
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
padding: 0 $gap / 2;
|
padding: 0 $gap / 2;
|
||||||
|
position: relative;
|
||||||
|
|
||||||
&:global(.is_active) {
|
&:global(.is_active) {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.image_count {
|
||||||
|
position: absolute;
|
||||||
|
color: transparentize(white, 0.5);
|
||||||
|
bottom: $gap * 3;
|
||||||
|
right: 50%;
|
||||||
|
padding: $gap / 2 $gap * 1.2;
|
||||||
|
border-radius: 20px;
|
||||||
|
background: $content_bg;
|
||||||
|
font: $font_14_semibold;
|
||||||
|
transform: translate(50%, 0);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
user-select: none;
|
||||||
|
|
||||||
|
small {
|
||||||
|
font-size: 0.8em;
|
||||||
|
padding: 0 5px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.image_arrow {
|
||||||
|
position: absolute;
|
||||||
|
left: -$gap;
|
||||||
|
top: 50%;
|
||||||
|
width: 40px;
|
||||||
|
height: 64px;
|
||||||
|
border-radius: $radius;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
transform: translate(-100%, -50%);
|
||||||
|
|
||||||
|
&_right {
|
||||||
|
right: -$gap;
|
||||||
|
left: auto;
|
||||||
|
transform: translate(100%, -50%);
|
||||||
|
}
|
||||||
|
|
||||||
|
svg {
|
||||||
|
position: relative;
|
||||||
|
left: -2px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.placeholder {
|
.placeholder {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue