Skip to content

Commit 77277dd

Browse files
committed
Fix #16
1 parent 2554bc4 commit 77277dd

1 file changed

Lines changed: 14 additions & 12 deletions

File tree

input-num.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ noAwait = true; // see https://github.com/sidewayss/html-elements/issues/8
7373
// =============================================================================
7474
class InputNum extends BaseElement {
7575
#attrs; #bound; #btns; #confirmIt; #ctrls; #erId; #hoverIn; #hoverOut;
76-
#input; #isBlurring; #isLoading; #isMousing; #locale; #outFocus; #padRight;
77-
#spinId; #states; #svg; #texts; #validate;
76+
#input; #isBlurring; #isLoading; #isMousing; #kbSpin; #locale; #outFocus;
77+
#padRight; #spinId; #states; #svg; #texts; #validate;
7878
#isBlurry; // kludge for this._dom.activeElement === null
7979

8080
static defaults = {
@@ -546,30 +546,32 @@ static observedAttributes = [
546546
case code.down:
547547
case code.up:
548548
// Keyboard repeat rate is an OS setting that has its own delay then
549-
// interval, thus #spin(null), which doesn't set href or #spinId.
549+
// interval. Thus #spin(null), which doesn't set href or #spinId.
550550
// Separate href for delayed image because fast keydown/up sequences
551551
// flicker, and a delay can look just as flickery, depending on the
552552
// timing. It looks better if the initial, pre-delay image is only
553553
// slightly different from #spinner-idle.
554554
const
555555
topBot = key[evt.code],
556-
isSpin = this.#isSpinning, // next line might change it
556+
isSpin = this.#isSpinning, // #spin() can change #isSpinning
557557
inBounds = this.#spin(null, topBot == TOP);
558-
if (isSpin) {
559-
if (inBounds)
560-
this._setHref(`${SPINNER}${SPIN}${topBot}`);
561-
}
562-
else {
558+
if (!isSpin) {
563559
this._setHref(`${SPINNER}key-${topBot}`);
564-
this.#spinId = -1; // so that #isSpinning = true
560+
this.#spinId = -1; // not null so #isSpinning = true
561+
this.#kbSpin = inBounds; // kb for keyboard
562+
}
563+
else if (this.#kbSpin !== undefined) {
564+
if (this.#kbSpin) // set full-speed spin image once
565+
this._setHref(`${SPINNER}${SPIN}${topBot}`);
566+
this.#kbSpin = undefined;
565567
}
566568
default:
567569
}
568570
}
569571
//--------------------------------------------------------------------------
570572
#keyUp(evt) { // Esc key never makes it this far
571-
if (this.#inFocus) { // any character accepted...
572-
if (evt.code == code.enter)
573+
if (this.#inFocus) {
574+
if (evt.code == code.enter) // any character accepted...
573575
this.classList.remove(BEEP);
574576
else { // ...but style erroneous values:
575577
const n = this.#toNumber(this.text);

0 commit comments

Comments
 (0)