Wikipedia:Reference desk/Archives/Computing/2016 December 9

= December 9 =

Scroll position in JavaScript
I'm writing a script to hide (and restore) stuff on the screen.

I use regex to remove it, and a clone to put it back.

The problem is, when a large amount of text is either removed or restored, it pushes or pulls the user way down or way up the page.

What I'd like the program to do is have the list item that's at the top of the current screen stay there. That way, the user remains looking at the same items.

How can JavaScript track what's on the screen? The Transhumanist 20:31, 9 December 2016 (UTC)
 * Why you just do not use "display" css property to hide/show content? Ruslik_ Zero 20:49, 9 December 2016 (UTC)
 * because the script removes content (temporarily) rather than hides it, and then puts it back via a clone. Can't afford the time to embed new DOMs for this, as there are tens of millions of pages. The problem is, when the content is removed or restored, the remaining content shifts position relative to the screen. I need a way for the user's view to stick with the list item that is displayed at the top of the screen before the hide or show operation. The Transhumanist 11:07, 11 December 2016 (UTC)
 * You can get the position of an element, relative to the viewport, with code from http://stackoverflow.com/questions/442404/retrieve-the-position-x-y-of-an-html-element. You can then keep that element on the screen with code from http://kirbysayshi.com/2013/08/19/maintaining-scroll-position-knockoutjs-list.html. The two websearches I used to find these were https://duckduckgo.com/?q=js+get+top-left+object and https://duckduckgo.com/?q=js+scroll+element+to+viewport+position. BTW, stackoverflow is probably a better place to ask this type of question. LongHairedFop (talk) 13:53, 11 December 2016 (UTC)

Finding source code for learning Scheme
Where could I find source code of programs written in Scheme? I want code that's commonly used in a productive environment, and accessible to a beginner, (i.e. with educational value, but not textbook examples). --Hofhof (talk) 21:06, 9 December 2016 (UTC)