Skip to content

Commit

Permalink
add event detail
Browse files Browse the repository at this point in the history
  • Loading branch information
Nerwyn committed Dec 14, 2023
1 parent b77345a commit 4a77d23
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 14 deletions.
2 changes: 1 addition & 1 deletion dist/android-tv-card.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions src/classes/base-remote-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,13 @@ export class BaseRemoteElement extends LitElement {
} else {
window.history.pushState(null, '', action.navigation_path);
}
window.dispatchEvent(
new Event('location-changed', {
bubbles: false,
cancelable: true,
composed: false,
}),
);
const event = new Event('location-changed', {
bubbles: false,
cancelable: true,
composed: false,
});
event.detail = { replace: action.navigation_replace == true };
window.dispatchEvent(event);
}

toUrl(action: IAction) {
Expand Down
2 changes: 1 addition & 1 deletion src/classes/remote-keyboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { BaseKeyboardElement } from './base-keyboard-element';

@customElement('remote-keyboard')
export class RemoteKeyboard extends BaseKeyboardElement {
onClick(e: Event) {
onClick(e: MouseEvent) {
e.stopImmediatePropagation();
this.fireHapticEvent('light');
for (const element of (e.currentTarget as HTMLElement).children) {
Expand Down
2 changes: 1 addition & 1 deletion src/classes/remote-search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { BaseKeyboardElement } from './base-keyboard-element';

@customElement('remote-search')
export class RemoteSearch extends BaseKeyboardElement {
onClick(e: Event) {
onClick(e: MouseEvent) {
e.stopImmediatePropagation();
this.fireHapticEvent('light');

Expand Down
2 changes: 1 addition & 1 deletion src/classes/remote-textbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { BaseKeyboardElement } from './base-keyboard-element';

@customElement('remote-textbox')
export class RemoteTextbox extends BaseKeyboardElement {
onClick(e: Event) {
onClick(e: MouseEvent) {
e.stopImmediatePropagation();

const text = prompt('Text Input: ');
Expand Down
6 changes: 3 additions & 3 deletions src/classes/remote-touchpad.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ export class RemoteTouchpad extends BaseRemoteElement {

onClick(e: MouseEvent) {
e.stopImmediatePropagation();
console.log(this.actions)
console.log(this.actions);
const clickAction = () => {
clearTimeout(this.clickTimer as ReturnType<typeof setTimeout>);
this.clickTimer = undefined;
this.fireHapticEvent('light');
this.sendAction('tap_action');
console.log('sent tap action')
console.log('sent tap action');
this.clickCount = 0;
};
if (e.detail && e.detail > this.clickCount) {
Expand Down Expand Up @@ -76,7 +76,7 @@ export class RemoteTouchpad extends BaseRemoteElement {

@eventOptions({ passive: true })
onTouchStart(e: TouchEvent) {
this._rippleHandlers.startPress(e);
this._rippleHandlers.startPress(e as unknown as Event);

this.touchTimer = setTimeout(() => {
this.touchHoldClick = true;
Expand Down
4 changes: 4 additions & 0 deletions src/models/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,8 @@ declare global {
interface EventTarget {
action: string;
}

interface Event {
detail?: Record<string, string | number | boolean>;
}
}

0 comments on commit 4a77d23

Please sign in to comment.