Closed derick-montague closed 10 years ago
I like this idea, with one modification. I believe I will make the "updateHash" option something which is only supported in browsers which support the history object. I would prefer not to still show the broken behavior in non-modern browsers.
I tried several approaches to updating the hash without breaking offset. The best I was able to achieve was by setting the hash BEFORE the scroll. I stored the current scrollTop value in a variable, updated the hash, and then immediately set the scrollTop value back to its previous value and then animated the scroll. This seemed to work well in Firefox. But in IE, while offset was respected, the "jump" that occurred when the hash value was rapidly updated was visible.
Making updateHash a "progressive" feature just seems like the cleanest to me.
I will pull in the changes with modification as soon as I test. Thanks for looking into this!
I definitely agree with the progressive enhancement approach especially since IE 8 will be around for a while since Windows 7 still ships with it. Glad to help, I appreciate being able to use your script.
Using the history object to update the hash if it's supported by the browser. Otherwise using the location object (for older browsers). Non-supportive browsers will still work as they do now, but modern browsers(non-webkit) will scroll to the correct position.