Disable that Dang Scrolling when people reply to a comment

We all know that sometimes it can be a pain on livefyre when there are many people replying to your posts. You can be dragged all over the place which is really annoying when you are in the middle of writing a reply to a different post. As a note when that happens just keep typing and livefyre will return you back to where you are typing in the reply.

It is nice to know you received a reply so you can reply to that and tell them why they are stupid. 😃

I wrote code to disable that automatic scrolling on replies. But as I like that feature at times also added the ability to enable and disable it.

This is what you will see at first telling you scrolling is enabled:

And then if you click the button, (Yeah it doesn’t look like a button, would be nicer if it were a checkbox!), then you see this and the browser won’t do any scrolling aside from that done by you as a user:

One thought I’ve had to improve this is to only disable scrolling when you are in the middle of adding a reply. I think it’s easily detectable of the editor is open.

How it works

When code running in the browser like livefyre wants to scroll the browser it calls the javascipt apis scrollTo and scrollBy the browser provides. What this code does is take over those apis and then when scrolling is to be disabled do nothing and when enabled call those original functions.

What do I have to do 

To run it you need to run the javascript code below in your browser. It’s easiest in chrome if you look at how to open the developer tools and go to the snippets tab (under the Sources tab). Then you can save this code as a snippet and it will be stored across sessions. Then you can run the snipet in future sessions.

For Firefox you will want to look into the JavaScript Scratchpad.

For either browser you can also just paste the entire code into the console command line of the browser.

For IE you are on your own as I don’t use it. (It should work for modern versions of IE but you will need to research how to get the code into the browser).

Nothing is persistent outside using the snippets to simply save the code to be run manually later. So worst case if it does not work refresh the page it’s like it never happened.

— Code follows. As a note it’s easiest to copy for pasting if you select the “view raw” link at the bottom. —