Skip to content

Commit

Permalink
Remove performance fix that hardly provides any performance gain yet …
Browse files Browse the repository at this point in the history
…breaks things when scrolling

Attempt to disable the autoscrolling done by Twitch to gain some performance
  • Loading branch information
Glodenox committed Dec 8, 2018
1 parent f104182 commit 4d7aaac
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions chat-monitor.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ function actionFunction() {
// Continually scroll up, in a way to make the comments readable
var lastFrame = +new Date();
function scrollUp(now) {
if (chatContentDiv.scrollTop > 0 && GM_config.get("ReverseDirection")) {
if (GM_config.get("ReverseDirection")) {
if (scrollDistance > 0 && GM_config.get("SmoothScroll")) {
// estimate how far along we are in scrolling in the current scroll reference
var currentStep = parseFloat(GM_config.get("SmoothScrollSpeed")) * 1000 / (now - lastFrame);
Expand All @@ -358,7 +358,16 @@ function actionFunction() {
window.requestAnimationFrame(scrollUp);
}
window.requestAnimationFrame(scrollUp);
chatContentDiv.scrollTop = 0;
chatContentDiv.scrollTop = 0;

// Disable Twitch autoscroll with a little trick for performance reasons
if (GM_config.get("ReverseDirection")) {
setTimeout(function() {
chatContentDiv.scrollBy(0, -200);
chatContentDiv.dispatchEvent(new WheelEvent('wheel', {deltaY: -200}));
chatContentDiv.scrollBy(0, 200);
}, 5000);
}
}

//inject custom stylessheet
Expand Down

0 comments on commit 4d7aaac

Please sign in to comment.