Description
I'm opening this issue to revamp an issue I already raised in the W3C position mailing list that I feel received very little attention.
The point I'm making is the following:
The specifications of
position: sticky
don't mention any event fired when an element is stuck and when it returns to its original position, for example something likestickystart
andstickyend
. I think this could be very useful and it has different use cases.The first use case is a website that needs to decrease the margin of a navigation bar when it starts sticking. Another use case might be to have an element that takes the full width of the page when it's sticking but a different width when it's in its original position.
A use case I can think of is an element that should have the width of its parent when is not sticking and the width of the window when sticking. An example is shown in this demo I've created:
https://jsfiddle.net/638rjsty/
And this is the result I'd like to achieve:
https://jsfiddle.net/4otjrrpf/
The second demo uses a library to simulate the support for position: sticky
, so it can be seen in any modern browser.