mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-02-02 06:06:41 +01:00
Sometimes, have to think out of the box
Focus first, then scroll
This commit is contained in:
parent
e3c77cb516
commit
c1f947a9c3
1 changed files with 2 additions and 10 deletions
|
@ -241,15 +241,11 @@ function MediaModal({
|
|||
onClick={(e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
carouselRef.current.focus();
|
||||
carouselRef.current.scrollTo({
|
||||
left: carouselRef.current.clientWidth * (currentIndex - 1),
|
||||
behavior: 'smooth',
|
||||
});
|
||||
setTimeout(() => {
|
||||
// Delay is needed for Safari, the focus stops it from scrolling
|
||||
// 1000 is hypothetical
|
||||
carouselRef.current?.focus();
|
||||
}, 1000);
|
||||
}}
|
||||
>
|
||||
<Icon icon="arrow-left" />
|
||||
|
@ -261,15 +257,11 @@ function MediaModal({
|
|||
onClick={(e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
carouselRef.current.focus();
|
||||
carouselRef.current.scrollTo({
|
||||
left: carouselRef.current.clientWidth * (currentIndex + 1),
|
||||
behavior: 'smooth',
|
||||
});
|
||||
setTimeout(() => {
|
||||
// Delay is needed for Safari, the focus stops it from scrolling
|
||||
// 1000 is hypothetical
|
||||
carouselRef.current?.focus();
|
||||
}, 1000);
|
||||
}}
|
||||
>
|
||||
<Icon icon="arrow-right" />
|
||||
|
|
Loading…
Reference in a new issue