Ted Fitzpatrick
Ted Fitzpatrick

Reputation: 944

Does IntersectionObserver support horizontal scrolling observation?

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 becomes 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?

Upvotes: 6

Views: 8235

Answers (1)

Felipe Hernandez
Felipe Hernandez

Reputation: 106

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

Upvotes: 9

Related Questions