Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/action-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export interface ActionHandlerOptions {
hasHold?: boolean;
hasDoubleClick?: boolean;
disabled?: boolean;
stopPropagation?: boolean;
repeat?: number;
repeatLimit?: number;
}
Expand Down Expand Up @@ -138,6 +139,9 @@ class ActionHandler extends HTMLElement implements ActionHandler {
}

element.actionHandler.start = (ev: Event) => {
if (options.stopPropagation) {
ev.stopPropagation();
}
this.cancelled = false;
let x;
let y;
Expand Down Expand Up @@ -171,6 +175,9 @@ class ActionHandler extends HTMLElement implements ActionHandler {
};

element.actionHandler.end = (ev: Event) => {
if (options.stopPropagation) {
ev.stopPropagation();
}
// Don't respond when moved or scrolled while touch
if (['touchend', 'touchcancel'].includes(ev.type) && this.cancelled) {
if (this.isRepeating && this.repeatTimeout) {
Expand Down
1 change: 1 addition & 0 deletions src/button-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -998,6 +998,7 @@ class ButtonCard extends LitElement {
.actionHandler=${actionHandler({
hasDoubleClick: this._config!.double_tap_action!.action !== 'none',
hasHold: this._config!.hold_action!.action !== 'none',
stopPropagation: this._config!.stop_propagation,
repeat: this._config!.hold_action!.repeat,
repeatLimit: this._config!.hold_action!.repeat_limit,
})}
Expand Down
2 changes: 2 additions & 0 deletions src/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface ButtonCardConfig {
tap_action?: ActionConfig;
hold_action?: ActionConfig;
double_tap_action?: ActionConfig;
stop_propagation?: boolean;
show_name?: boolean;
show_state?: boolean;
show_icon?: boolean;
Expand Down Expand Up @@ -58,6 +59,7 @@ export interface ExternalButtonCardConfig {
tap_action?: ActionConfig;
hold_action?: ActionConfig;
double_tap_action?: ActionConfig;
stop_propagation?: boolean;
show_name?: boolean;
show_state?: boolean;
show_icon?: boolean;
Expand Down