Skip to content

Add ability to tap on slider and trigger custom command whether slider is enabled or disabled#10

Open
lizsugar wants to merge 9 commits intocustom-cards:mainfrom
lizsugar:slider_tap_action
Open

Add ability to tap on slider and trigger custom command whether slider is enabled or disabled#10
lizsugar wants to merge 9 commits intocustom-cards:mainfrom
lizsugar:slider_tap_action

Conversation

@lizsugar
Copy link
Copy Markdown
Collaborator

@lizsugar lizsugar commented Jun 2, 2022

This one is a pretty big change and most of my PRs submitted after this one (e.g., scene domain support) work best if this is already merged.

This change is not backwards compatible. The previous slider.has_toggle option is replaced by slider.disable_sliding.

This allows the user to define a tap_action on the slider element independent of action button and icon. The tap_action fires whether slider can move or not and does not fire when the slider has moved.

Examples:

For switches

slider:
  disable_sliding: true
  tap_action: toggle

For lights

slider:
  disable_sliding: false
  tap_action: toggle

For media players

slider:
  disable_sliding: false
  tap_action: more-info

For scenes

slider:
  disable_sliding: true
  tap_action:
    action: call-service
    service: scene.turn_on
    service_data:
      entity_id: scene.dining_room_on

Plus some default settings based on card type
FIX: No longer triggers the tap_action when sliding!
BUG: does not trigger tap_action unless slider is disabled
It is supposed to trigger tap_action at all times.

The goal is that this change will eventually result in "Act as a toggle (disable
sliding)" being removed. A toggle for disabling slider will remain, but
it will no longer add a tap action for toggle when enabled, as that will be attached to the
slider anyway (and can be defined as 'none' action if desired).
Remove all references to hasToggle/has_toggle and replace appropriately with disableSliding/disable_sliding.

Added default configs for the controller types

tap_action works with both mouse and touch when sliding is disabled

current bugs, now better described after further testing:
- tap_action with sliding enabled works with touch but not mouse click
- tap_action with sliding enabled sometimes jumps to the value your finger is at
It's in a good place except still does not work with mouse click while
slider is active.

Probably SQUASH this commit...
A little bit of a dirty fix, but it works
@lizsugar lizsugar mentioned this pull request Jun 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant