Skip to content

Commit

Permalink
smartphone touch event
Browse files Browse the repository at this point in the history
  • Loading branch information
madmicio committed Oct 6, 2023
1 parent 2c4d43c commit c4b59ce
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions lg-remote-control.js
Original file line number Diff line number Diff line change
Expand Up @@ -560,12 +560,28 @@ class LgRemoteControl extends LitElement {
updateValue("volume_up");
}
});

plusButton.addEventListener("touchstart", (e) => {
e.preventDefault(); // Impedisci il comportamento predefinito del tocco
if (!isNaN(this.volume_value)) {
this._show_vol_text = true;
this.longPressTimer = setTimeout(() => updateValue("volume_up"), 200);
}
});

plusButton.addEventListener("mouseup", () => {
clearTimeout(this.longPressTimer);
this.valueDisplayTimeout = setTimeout(() => {
this._show_vol_text = false;
}, 500);
});

plusButton.addEventListener("touchend", () => {
clearTimeout(this.longPressTimer);
this.valueDisplayTimeout = setTimeout(() => {
this._show_vol_text = false;
}, 500);
});

plusButton.addEventListener("mouseout", () => {
clearTimeout(this.longPressTimer);
Expand All @@ -578,13 +594,28 @@ class LgRemoteControl extends LitElement {
updateValue("volume_down");
}
});

minusButton.addEventListener("touchstart", (e) => {
e.preventDefault(); // Impedisci il comportamento predefinito del tocco
if (!isNaN(this.volume_value)) {
this._show_vol_text = true;
this.longPressTimer = setTimeout(() => updateValue("volume_down"), 200);
}
});

minusButton.addEventListener("mouseup", () => {
clearTimeout(this.longPressTimer);
this.valueDisplayTimeout = setTimeout(() => {
this._show_vol_text = false;
}, 500);
});

minusButton.addEventListener("touchend", () => {
clearTimeout(this.longPressTimer);
this.valueDisplayTimeout = setTimeout(() => {
this._show_vol_text = false;
}, 500);
});

minusButton.addEventListener("mouseout", () => {
clearTimeout(this.longPressTimer);
Expand Down

0 comments on commit c4b59ce

Please sign in to comment.