ryanve / verge

get viewport dimensions...detect elements in the viewport...trust in <!DOCTYPE html>
https://ryanve.dev/verge
MIT License
695 stars 52 forks source link

inViewport, inX, inY expressiveness #28

Open ryanve opened 7 years ago

ryanve commented 7 years ago

In 1.x the signature for these is .inViewport(element, cushion=0) where cushion is an optional +/- cushion around the element. Is this clear enough or should we somehow redesign to be more expressive?

drgullin commented 6 years ago

Right and bottom cushion doesn't work for negative values.

https://github.com/ryanve/verge/blob/master/verge.js#L86-L87 If I set cushion -100, verge won't mark nodes as visible starting from 0 to 100 of the window height, but it also won't mark nodes as visible starting from (window height - 100), because 200 + -100 (200 is an example offset) equals to 100, not 300. - cushion should be replaced with (- Math.abs(cushion).

drgullin commented 6 years ago

Sorry, that solution won't work, this needs some other fix.