Skip to content

Commit

Permalink
Fix image gallery scrolling in editor on Safari
Browse files Browse the repository at this point in the history
Safari (tested with 17.3) also triggers the observer callback for
children whose `intersectionRatio` is below the threshold. This only
happens inside the editor iframe. In the preview or published entries,
the behavior matches Chrome and Firefox.

We need to double check `intersectionRatio` ourselves to prevent
invoking the `onVisibleIndexChange` callback for all of the children,
which leads to a broken image gallery.

REDMINE-20635
  • Loading branch information
tf committed Mar 8, 2024
1 parent 2b49d8a commit 94c8adf
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export function useIntersectionObserver({threshold, onVisibleIndexChange}) {
(child) => child === entry.target
);

if (entry.isIntersecting) {
if (entry.isIntersecting && entry.intersectionRatio >= threshold) {
onVisibleIndexChange(entryIndex);
}
});
Expand Down

0 comments on commit 94c8adf

Please sign in to comment.