Skip to content

Commit

Permalink
adjust imports and the log message
Browse files Browse the repository at this point in the history
  • Loading branch information
wordpressfan committed Sep 4, 2024
1 parent 9635089 commit ecdac7a
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/BeaconLrc.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
'use strict';

import BeaconUtils from "./Utils.js";
import BeaconManager from "./BeaconManager.js";
import Utils from "./Utils.js";

class BeaconLrc {
constructor(config, logger) {
Expand Down Expand Up @@ -53,7 +51,7 @@ class BeaconLrc {
_getElementDistance(element) {
const rect = element.getBoundingClientRect();
const scrollTop = window.pageYOffset || document.documentElement.scrollTop;
return Math.max(0, rect.top + scrollTop - Utils.getScreenHeight());
return Math.max(0, rect.top + scrollTop - BeaconUtils.getScreenHeight());
}

_skipElement(element) {
Expand Down Expand Up @@ -84,10 +82,10 @@ class BeaconLrc {
return;
}

const can_push_hash = element.parentElement && this._getElementDistance(element.parentElement) < this.config.lrc_threshold && distance > this.config.lrc_threshold;
const can_push_hash = element.parentElement && this._getElementDistance(element.parentElement) < this.config.lrc_threshold && distance >= this.config.lrc_threshold;

const color = can_push_hash ? "green" : distance === 0 ? "red" : "";
this.logger.logColoredMessage( `${'\t'.repeat(depth)}${element.tagName} (Depth: ${depth}, Distance from viewport top: ${distance}px)`, color );
this.logger.logColoredMessage( `${'\t'.repeat(depth)}${element.tagName} (Depth: ${depth}, Distance from viewport bottom: ${distance}px)`, color );

//const xpath = this._getXPath(element);
//console.log(`%c${'\t'.repeat(depth)}Xpath: ${xpath}`, style);
Expand Down

0 comments on commit ecdac7a

Please sign in to comment.