JavaScript30 icon indicating copy to clipboard operation
JavaScript30 copied to clipboard

Fix Long Key Press Bug

Open anirbanroy2002 opened this issue 4 years ago • 10 comments

The playing class is not being removed from the keys if they are held down for a long time. This happens because when it's held down for long, there's actually no transformation taking place and thus on line 61, the removeTransition function simply returns the controller without removing the 'playing' class. In this commit, I've updated line 61 such that if the target classList doesn't contain 'playing', the controller will be returned. Else, the 'playing' class will be removed.

anirbanroy2002 avatar Sep 18 '21 10:09 anirbanroy2002

I had issues with this too. I copied and pasted your code, and I'm still having the same issues. Any suggestions?

Nguyen-Ly-1 avatar Oct 04 '21 17:10 Nguyen-Ly-1

This works fine for me: https://github.com/anirbanroy2002/JavaScript30/blob/master/01%20-%20JavaScript%20Drum%20Kit/index-FINISHED.html

anirbanroy2002 avatar Oct 04 '21 17:10 anirbanroy2002

Interesting, I wonder what is going wrong on my end then.

Nguyen-Ly-1 avatar Oct 04 '21 17:10 Nguyen-Ly-1

Try this: https://techrbun.com/temporary/js-drum-kit/index-FINISHED.html

anirbanroy2002 avatar Oct 04 '21 17:10 anirbanroy2002

It's still showing the same issues. I wonder if I'm the only one!

Nguyen-Ly-1 avatar Oct 04 '21 18:10 Nguyen-Ly-1

Could you please elaborate on what issue you're facing?

The bug that this code fixes is:

In the original version, if you keep a key held down for long, the CSS changes on the button doesn't revert back, thus, it makes the button look bigger and golden bordered as if its still playing (but actually isn't), due to the presence of the "playing" class. However this code fixes that issue.

Are you facing some other bug?

Could you please share what OS and browser you're using?

anirbanroy2002 avatar Oct 04 '21 18:10 anirbanroy2002

Some JS Engines might behave differently and not put the "playing" class at index 1 of the classList. In that case, can you please try replacing the line 62:

if (e.target.classList[1] !== 'playing') return;

with this:

if ( ! e.target.classList.contains('playing')) return;

anirbanroy2002 avatar Oct 04 '21 18:10 anirbanroy2002

Hi, Thanks for explaining this to me. The issue is exactly how you described. In addition, the audio isn't playing sound after it plays the audio once. I'm assuming because it isn't ending and returning for either issues for some reason? macOS Catalina version 10.15.7.

Nguyen-Ly-1 avatar Oct 04 '21 18:10 Nguyen-Ly-1

I'm using Safari 15.0

Nguyen-Ly-1 avatar Oct 04 '21 18:10 Nguyen-Ly-1

I do not use SAFARI. Can you test it in Chrome? Might be a browser specific bug. Cuz the sounds keeps playing on chrome as long as you keep it held down.

anirbanroy2002 avatar Oct 04 '21 19:10 anirbanroy2002