bramkragten / swipe-card

Card that allows you to swipe throught multiple cards for Home Assistant Lovelace
234 stars 32 forks source link

Adding the ability to define hash values for each card within swipe-card #68

Open TinyShark opened 1 year ago

TinyShark commented 1 year ago

The Swiper API has hash navigation built in and it can be enabled with the following config parameters on swipe-card:

type: custom:swipe-card
parameters:
  slidesPerView: auto
  hashNavigation:
    watchState: true

This works as it should if I manually add data-hash="[my-hash-value]" to the class of the desired slide through chrome dev tools:

Screenshot 2023-01-24 at 10 45 36

and then use javascript to set the hash: window.location.hash = 'testhash'; Swipe card transitions to that specific slide.

Would it be possible to add an option/field to define a hash value per card?

for eg:

type: custom:swipe-card
parameters:
  slidesPerView: auto
  hashNavigation:
    watchState: true
cards:
  - type: vertical-stack
    hash: my-hash-value

thanks!