Debounce Unread.update.

This will allow use to queue up the scroll events better
and prevent lockup.
This commit is contained in:
Zixaphir 2013-04-21 01:39:58 -07:00
parent c820ed44bc
commit 4c63dd478b
4 changed files with 20 additions and 20 deletions

View File

@ -20,7 +20,7 @@
// @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAgMAAAAqbBEUAAAACVBMVEUAAGcAAABmzDNZt9VtAAAAAXRSTlMAQObYZgAAAHFJREFUKFOt0LENACEIBdBv4Qju4wgWanEj3D6OcIVMKaitYHEU/jwTCQj8W75kiVCSBvdQ5/AvfVHBin11BgdRq3ysBgfwBDRrj3MCIA+oAQaku/Q1cNctrAmyDl577tOThYt/Y1RBM4DgOHzM0HFTAyLukH/cmRnqAAAAAElFTkSuQmCC
// ==/UserScript==
/* 4chan X - Version 3.1.4 - 2013-04-19
/* 4chan X - Version 3.1.4 - 2013-04-21
* https://4chan-x.just-believe.in/
*
* Copyright (c) 2009-2011 James Campos <james.r.campos@gmail.com>
@ -6449,8 +6449,8 @@
}
return arr.splice(0, i);
},
read: function(e) {
var ID, bottom, height, i, post, posts, read, top, _ref;
read: $.debounce(50, function(e) {
var ID, bottom, height, i, post, posts, read;
if (d.hidden || !Unread.posts.length) {
return;
@ -6460,8 +6460,8 @@
read = [];
i = posts.length;
while (post = posts[--i]) {
_ref = post.nodes.root.getBoundingClientRect(), bottom = _ref.bottom, top = _ref.top;
if ((bottom < height) && (top > 0)) {
bottom = post.nodes.root.getBoundingClientRect().bottom;
if (bottom < height) {
ID = post.ID;
posts.remove(post);
}
@ -6475,7 +6475,7 @@
if (e) {
return Unread.update();
}
},
}),
saveLastReadPost: $.debounce(2 * $.SECOND, function() {
return Unread.db.set({
boardID: Unread.thread.board.ID,

View File

@ -20,7 +20,7 @@
// @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAgMAAAAqbBEUAAAACVBMVEUAAGcAAABmzDNZt9VtAAAAAXRSTlMAQObYZgAAAHFJREFUKFOt0LENACEIBdBv4Qju4wgWanEj3D6OcIVMKaitYHEU/jwTCQj8W75kiVCSBvdQ5/AvfVHBin11BgdRq3ysBgfwBDRrj3MCIA+oAQaku/Q1cNctrAmyDl577tOThYt/Y1RBM4DgOHzM0HFTAyLukH/cmRnqAAAAAElFTkSuQmCC
// ==/UserScript==
/* 4chan X - Version 3.1.4 - 2013-04-19
/* 4chan X - Version 3.1.4 - 2013-04-21
* https://4chan-x.just-believe.in/
*
* Copyright (c) 2009-2011 James Campos <james.r.campos@gmail.com>
@ -6441,8 +6441,8 @@
}
return arr.splice(0, i);
},
read: function(e) {
var ID, bottom, height, i, post, posts, read, top, _ref;
read: $.debounce(50, function(e) {
var ID, bottom, height, i, post, posts, read;
if (d.hidden || !Unread.posts.length) {
return;
@ -6452,8 +6452,8 @@
read = [];
i = posts.length;
while (post = posts[--i]) {
_ref = post.nodes.root.getBoundingClientRect(), bottom = _ref.bottom, top = _ref.top;
if ((bottom < height) && (top > 0)) {
bottom = post.nodes.root.getBoundingClientRect().bottom;
if (bottom < height) {
ID = post.ID;
posts.remove(post);
}
@ -6467,7 +6467,7 @@
if (e) {
return Unread.update();
}
},
}),
saveLastReadPost: $.debounce(2 * $.SECOND, function() {
return Unread.db.set({
boardID: Unread.thread.board.ID,

View File

@ -6362,8 +6362,8 @@
}
return arr.splice(0, i);
},
read: function(e) {
var ID, bottom, height, i, post, posts, read, top, _ref;
read: $.debounce(50, function(e) {
var ID, bottom, height, i, post, posts, read;
if (d.hidden || !Unread.posts.length) {
return;
@ -6373,8 +6373,8 @@
read = [];
i = posts.length;
while (post = posts[--i]) {
_ref = post.nodes.root.getBoundingClientRect(), bottom = _ref.bottom, top = _ref.top;
if ((bottom < height) && (top > 0)) {
bottom = post.nodes.root.getBoundingClientRect().bottom;
if (bottom < height) {
ID = post.ID;
posts.remove(post);
}
@ -6388,7 +6388,7 @@
if (e) {
return Unread.update();
}
},
}),
saveLastReadPost: $.debounce(2 * $.SECOND, function() {
return Unread.db.set({
boardID: Unread.thread.board.ID,

View File

@ -98,7 +98,7 @@ Unread =
break if post.ID > Unread.lastReadPost
arr.splice 0, i
read: (e) ->
read: $.debounce 50, (e) ->
return if d.hidden or !Unread.posts.length
height = doc.clientHeight
{posts} = Unread
@ -106,8 +106,8 @@ Unread =
i = posts.length
while post = posts[--i]
{bottom, top} = post.nodes.root.getBoundingClientRect()
if (bottom < height) and (top > 0) # post is completely read
{bottom} = post.nodes.root.getBoundingClientRect()
if (bottom < height) # post is completely read
ID = post.ID
posts.remove post
return unless ID