File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change 5656 import { onMount } from ' svelte' ;
5757 import type { ExpanderConfig } from ' ./configtype' ;
5858 import type { AnimationState } from ' ./types' ;
59+ import { forwardHaptic } from ' ./helpers/forward-haptic' ;
5960
6061 const {
6162 hass,
219220 }
220221 return false ;
221222 }
223+ forwardHaptic (event .currentTarget as HTMLElement , ' light' );
222224 toggleOpen ();
223225 };
224226
250252
251253 const touchEnd = (event : TouchEvent ) => {
252254 if (! isScrolling && touchElement === event .target && config [' title-card-clickable' ]) {
255+ forwardHaptic (touchElement , ' light' );
253256 toggleOpen ();
254257 touchPreventClick = true ;
255258 // A touch event may not always be followed by a click event so we set a timeout to reset
Original file line number Diff line number Diff line change 1+ // Allowed types are from iOS HIG.
2+ // https://developer.apple.com/design/human-interface-guidelines/ios/user-interaction/feedback/#haptics
3+ // Implementors on platforms other than iOS should attempt to match the patterns (shown in HIG) as closely as possible.
4+ export type HapticType = 'success' | 'warning' | 'failure' | 'light' | 'medium' | 'heavy' | 'selection' | 'none' ;
5+
6+ declare global {
7+ // for fire event
8+ interface HASSDomEvents {
9+ haptic : HapticType ;
10+ }
11+ }
12+
13+ export const forwardHaptic = ( node : HTMLElement , hapticType : HapticType ) => {
14+ node . dispatchEvent ?.(
15+ new CustomEvent ( 'haptic' ,
16+ { detail : hapticType , bubbles : true , composed : true }
17+ )
18+ ) ;
19+ } ;
You can’t perform that action at this time.
0 commit comments