Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed color glitches in FireFox #318

Closed
wants to merge 1 commit into from

Conversation

giwih
Copy link
Contributor

@giwih giwih commented Dec 13, 2024

Description

Related Issues

Checklist

  • I have read and followed the Contributing Guidelines.
  • I have added necessary tests.
  • The project builds and runs without issues.

Copy link
Contributor

@ZiClaud ZiClaud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works, thank you!

Copy link
Collaborator

@itz-rj-here itz-rj-here left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@prem-k-r please review it
I guess it’s ok

@prem-k-r
Copy link
Collaborator

Related Issues

Github trick: You can write as Closes #308 in PR description, it will automatically closes the issue when the PR is merged :)

@XengShi
Copy link
Owner

XengShi commented Dec 16, 2024

This change will disable live changes of colors in Chrome. I think live updates provide a better user experience. Therefore, I am merging this change into the Firefox-specific branch.

Screencast.From.2024-12-16.18-27-12.mp4

@XengShi XengShi closed this Dec 16, 2024
@ZiClaud
Copy link
Contributor

ZiClaud commented Dec 23, 2024

I'd like for this to be reopened and changed the code to:

// Function to detect if the browser is Firefox
function isFirefox() {
    return navigator.userAgent.toLowerCase().includes('firefox');
}

// Apply appropriate listeners based on the browser
if (isFirefox()) {
    // Add listeners for Firefox
    colorPicker.removeEventListener('change', handleColorPickerChange);
    colorPicker.addEventListener('change', handleColorPickerChange);
} else {
    // Add listeners for Chrome and Safari
    colorPicker.removeEventListener('input', handleColorPickerChange);
    colorPicker.addEventListener('input', handleColorPickerChange);
}

And remove the Firefox-specific branch

I've tested it on both Firefox and Chrome, and it works.
Didn't test it on Safari, Brave and others.

Also, to make the code more solid, create a folder: browserUtils.js and put in there

// browserUtils.js

/**
 * Detect if the browser is Firefox.
 * @returns {boolean} True if the browser is Firefox.
 */
export function isFirefox() {
    return navigator.userAgent.toLowerCase().includes('firefox');
}

/**
 * Detect if the browser is Chrome.
 * @returns {boolean} True if the browser is Chrome.
 */
export function isChrome() {
    return navigator.userAgent.toLowerCase().includes('chrome') &&
           !navigator.userAgent.toLowerCase().includes('edge') &&
           !navigator.userAgent.toLowerCase().includes('opera');
}

@XengShi @giwih @prem-k-r

@prem-k-r
Copy link
Collaborator

prem-k-r commented Dec 24, 2024

we can define isfirefox there in a line, maybe no need for browserUtils.js

there has been an extra option added for firefox #323 , so not a good idea to delete the branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] Colour glitches on start since last update
5 participants