mirror of
https://github.com/jupyter/notebook.git
synced 2025-03-13 13:17:50 +08:00
Rate limit scrolling callback
This commit is contained in:
parent
887e0dd154
commit
3bcd3417c2
@ -297,9 +297,9 @@ define(function (require) {
|
||||
expand_time(time);
|
||||
});
|
||||
|
||||
this.scroll_manager.element.scroll(function () {
|
||||
this.scroll_manager.onScroll(function () {
|
||||
that.update_marked_status();
|
||||
});
|
||||
}, 100);
|
||||
|
||||
// Firefox 22 broke $(window).on("beforeunload")
|
||||
// I'm not sure why or how.
|
||||
@ -738,6 +738,7 @@ define(function (require) {
|
||||
};
|
||||
|
||||
Notebook.prototype.update_marked_status = function() {
|
||||
console.log("update marked status");
|
||||
var marked_cells = this.get_marked_cells();
|
||||
var num_offscreen = 0;
|
||||
var i;
|
||||
|
@ -13,6 +13,17 @@ define(['jquery'], function($){
|
||||
this.animation_speed = options.animation_speed || 250; //ms
|
||||
};
|
||||
|
||||
ScrollManager.prototype.onScroll = function (func, rate) {
|
||||
/**
|
||||
* Register a function to be called when the page is scrolled, throttled
|
||||
* at a particular rate limit.
|
||||
*/
|
||||
this.element.scroll(function () {
|
||||
clearTimeout(func._timeout);
|
||||
func._timeout = setTimeout(func, rate);
|
||||
});
|
||||
};
|
||||
|
||||
ScrollManager.prototype.scroll = function (delta) {
|
||||
/**
|
||||
* Scroll the document.
|
||||
|
Loading…
x
Reference in New Issue
Block a user