This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ezio.melotti
Recipients ezio.melotti, georg.brandl, ned.deily, orsenthil, python-dev, serhiy.storchaka, terry.reedy
Date 2013-10-15.01:18:35
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1381799917.24.0.685176663037.issue4965@psf.upfronthosting.co.za>
In-reply-to
Content
I've looked into it, and I found that:
1) the scroll event can be triggered dozens of times per second;
2) sidebarwrapper.css(...) causes a browser repaint/reflow, which is slow;

Optimizing the function doesn't seem like a good solution, so I tried to throttle it so that the position is updated at most once every 100ms (i.e. at 10fps max).  On Firefox this shows that about 2-6 redraws are skipped but, as a side-effect, the sidebar might result a few pixels off due to the skipped redraws at the end (this doesn't seem noticeable though).
If the value is increased over 100ms these problems start being noticeable.

FTR there are more complex solutions but for now I preferred to keep it simple.  These links contain other techniques (involving timers/timeouts):
* https://github.com/shichuan/javascript-patterns/blob/master/jquery-patterns/window-scroll-event.html
* http://underscorejs.org/docs/underscore.html#section-66 and http://underscorejs.org/#throttle

Serhiy, can you try to apply the patch and fiddle a bit with it to see if you notice any improvement?  You can try to change 100 with a lower or higher value, or do last_call = new Date() at the end of scroll_sidebar().  You might also have to remove the calls to console.log() if they create problems on your browser.
Remember that after each change you have to do:
  cp Doc/tools/sphinxext/static/sidebar.js Doc/build/html/_static/sidebar.js
and refresh the page to see the results.
History
Date User Action Args
2013-10-15 01:18:37ezio.melottisetrecipients: + ezio.melotti, georg.brandl, terry.reedy, orsenthil, ned.deily, python-dev, serhiy.storchaka
2013-10-15 01:18:37ezio.melottisetmessageid: <1381799917.24.0.685176663037.issue4965@psf.upfronthosting.co.za>
2013-10-15 01:18:37ezio.melottilinkissue4965 messages
2013-10-15 01:18:35ezio.melotticreate