admin管理员组

文章数量:1346657

I made a couple of vertical scroll IntersectionObserver modules, but I'm interested in horizontal scroll (root will be a div and observation target will be an img). I want to observe the changes when the img bees enlarged but the div remains the width of the viewport. I'm not even sure that mobile Safari will report a zoomed img as having a changed width, this is an experiment. Back to the question though, I haven't found any info. re: observing horizontal intersection so I'm not sure if that's supported?

I made a couple of vertical scroll IntersectionObserver modules, but I'm interested in horizontal scroll (root will be a div and observation target will be an img). I want to observe the changes when the img bees enlarged but the div remains the width of the viewport. I'm not even sure that mobile Safari will report a zoomed img as having a changed width, this is an experiment. Back to the question though, I haven't found any info. re: observing horizontal intersection so I'm not sure if that's supported?

Share Improve this question asked Oct 9, 2019 at 18:19 Ted FitzpatrickTed Fitzpatrick 9441 gold badge9 silver badges20 bronze badges 2
  • 2 Intersection observers aren't inherently related to scrolling at all. They just observe how much of the element is inside the view port; whether that changed because of a horizontal or vertical scroll, a CSS change, or something else doesn't matter. – IceMetalPunk Commented Oct 9, 2019 at 18:32
  • @IceMetalPunk ok so in your experience horizontal scroll is supported? – Ted Fitzpatrick Commented Oct 9, 2019 at 18:35
Add a ment  | 

1 Answer 1

Reset to default 9

To get an IntersectionObserver only in the x axis you can add to the options: rootMargin: "4000px 0px 4000px 0px".

本文标签: javascriptDoes IntersectionObserver support horizontal scrolling observationStack Overflow