Skip to content

Commit

Permalink
Remove workaround for the scroll bug - it's no longer needed #6
Browse files Browse the repository at this point in the history
  • Loading branch information
ainzzorl committed Jun 24, 2021
1 parent 4c830be commit 8f71ed2
Showing 1 changed file with 0 additions and 30 deletions.
30 changes: 0 additions & 30 deletions src/mainDialog/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,3 @@ app.service('dao', function () {
app.run(function ($rootScope: any) {
$rootScope.currentTab = DEFAULT_TAB;
});

// The code below is an ugly workaround for a bug.
// For some reason, when any ng-tracked element is changed,
// the scroll position is automatically reset to the top.
// This happens in Firefox, but works normally in Chrome.
// This is an attempt to detect and block these abnormal scrolls.
// Of course, some "real" scrolls are blocked by it as well.

let currentXOffset = 0;
let currentYOffset = 0;

app.run(function ($window: any) {
if ($window.navigator.userAgent.toLowerCase().indexOf('firefox') < 0) {
return;
}

angular.element($window).bind('scroll', function () {
if (
this.pageYOffset === 0 &&
this.pageYOffset !== currentYOffset &&
currentYOffset > 10
) {
WHLogger.log('Strange scroll has been detected');
$window.scrollTo(currentXOffset, currentYOffset);
WHLogger.log('Reset scroll to ' + currentXOffset + ', ' + currentYOffset);
}
currentXOffset = this.pageXOffset;
currentYOffset = this.pageYOffset;
});
});

0 comments on commit 8f71ed2

Please sign in to comment.