harmsk / atom-html-preview

Atom HTML Live Preview Package
MIT License
174 stars 73 forks source link

Scrolling defeats the preview. #103

Open garretwilson opened 8 years ago

garretwilson commented 8 years ago

This is working for me now with XHTML5, and it looks nice. It even updates as I type---very nice.

But it suffers from the same scrolling problems that most HTML previewers suffer from. :frowning: If I have a long document (and all my documents are long documents), once I reach the bottom of the screen and keep typing, the preview does not scroll to my current edit position, so I can't see the information I'm currently typing.

But it gets worse: if I scroll the preview down to show me what I'm typing, the instant I type something else the page reloads---and scrolls back to the top, defeating even my manual scrolling!

So unfortunately this only works with short documents. And I don't have any short documents. :frowning: I can't even find a workaround. Any suggestions?

colelawrence commented 8 years ago

Not that this is not something this package could not handle, but you could write a script tag that could scroll a certain amount down the page when the page loads, I'll look at implementing this though, since it looks like it could be pretty simple script.

colelawrence commented 8 years ago

Taking a quick look at this, I think it should be relatively easy to do if we are able to figure out which part of your html you are editing by inserting something invisible at your cursor or something.

http://codepen.io/ZombieHippie/pen/YqEKJw?editors=1000

Edit there is a native DOMElement::scrollIntoView() function! http://stackoverflow.com/a/3432687/2096729 this looks dope, much less hacky way to go.