Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
orientation: undefined,
};

const threshold = 170;
// Increased threshold to reduce false positives on high-resolution and vertical monitors
// Previous value of 170 caused false positives on 1920x1980 and similar resolutions
const threshold = 200;

const emitEvent = (isOpen, orientation) => {
globalThis.dispatchEvent(new globalThis.CustomEvent('devtoolschange', {
Expand All @@ -22,8 +24,15 @@
};

const main = ({emitEvents = true} = {}) => {
const widthThreshold = globalThis.outerWidth - globalThis.innerWidth > threshold;
const heightThreshold = globalThis.outerHeight - globalThis.innerHeight > threshold;
// Calculate the difference between outer and inner window dimensions
const widthDifference = globalThis.outerWidth - globalThis.innerWidth;
const heightDifference = globalThis.outerHeight - globalThis.innerHeight;

Check failure on line 30 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 16

Trailing spaces not allowed.
// Check if the differences exceed the threshold
// Added additional check: differences should be reasonable (< 600) to avoid false positives
// on unusual monitor configurations like 1920x1980 vertical displays
const widthThreshold = widthDifference > threshold && widthDifference < 600;
const heightThreshold = heightDifference > threshold && heightDifference < 600;
const orientation = widthThreshold ? 'vertical' : 'horizontal';

if (
Expand Down
Loading