Skip to content

Commit

Permalink
move isPageScrolled method to Utils class
Browse files Browse the repository at this point in the history
  • Loading branch information
wordpressfan committed Oct 15, 2024
1 parent 8544b7d commit 4f760de
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 1 addition & 5 deletions src/BeaconManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class BeaconManager {
return;
}

if (this._isPageScrolled()) {
if (BeaconUtils.isPageScrolled()) {
this.logger.logMessage('Bailing out because the page has been scrolled');
this._finalize();
return;
Expand Down Expand Up @@ -149,10 +149,6 @@ class BeaconManager {
this._saveFinalResultIntoDB();
}

_isPageScrolled() {
return window.pageYOffset > 0 || document.documentElement.scrollTop > 0;
}

_finalize() {
const beaconscript = document.querySelector('[data-name="wpr-wpr-beacon"]');
beaconscript.setAttribute('beacon-completed', 'true');
Expand Down
4 changes: 4 additions & 0 deletions src/Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ class BeaconUtils {
);
}

static isPageScrolled() {
return window.pageYOffset > 0 || document.documentElement.scrollTop > 0;
}

}

export default BeaconUtils;

0 comments on commit 4f760de

Please sign in to comment.