@@ -13,10 +13,17 @@ export class HomeButton extends LitElement {
1313 static override styles = css `
1414 :host {
1515 display: contents;
16+ touch-action: pan-x;
17+ -webkit-touch-callout: none;
18+ -webkit-user-select: none;
19+ user-select: none;
1620 }
1721
18- .home-button-wrapper {
22+ slot {
1923 display: contents;
24+ }
25+
26+ ::slotted(*) {
2027 touch-action: pan-x;
2128 -webkit-touch-callout: none;
2229 -webkit-user-select: none;
@@ -49,11 +56,30 @@ export class HomeButton extends LitElement {
4956
5057 override connectedCallback ( ) : void {
5158 super . connectedCallback ( ) ;
59+
5260 // Update detector with current thresholds
5361 this . swipeDetector = createUpSwipeDetector ( {
5462 threshold : this . swipeThreshold ,
5563 velocityThreshold : this . velocityThreshold ,
5664 } ) ;
65+
66+ // NOTE: Listen on host element instead of shadow DOM.
67+ // Touch events are not reliably delivered through shadow boundaries in Safari,
68+ // which may cause swipe-up to silently fail.
69+ // Capture phase: avoid child components (e.g. Swiper) stopping propagation.
70+ this . addEventListener ( 'touchstart' , this . handleTouchStart , { capture : true } ) ;
71+ this . addEventListener ( 'touchend' , this . handleTouchEnd , { capture : true } ) ;
72+ this . addEventListener ( 'touchcancel' , this . handleTouchCancel , { capture : true } ) ;
73+ this . addEventListener ( 'click' , this . handleClick ) ;
74+ }
75+
76+ override disconnectedCallback ( ) : void {
77+ this . removeEventListener ( 'touchstart' , this . handleTouchStart , { capture : true } ) ;
78+ this . removeEventListener ( 'touchend' , this . handleTouchEnd , { capture : true } ) ;
79+ this . removeEventListener ( 'touchcancel' , this . handleTouchCancel , { capture : true } ) ;
80+ this . removeEventListener ( 'click' , this . handleClick ) ;
81+
82+ super . disconnectedCallback ( ) ;
5783 }
5884
5985 override updated ( changedProperties : Map < string , unknown > ) : void {
@@ -66,11 +92,23 @@ export class HomeButton extends LitElement {
6692 }
6793
6894 private handleTouchStart = ( e : TouchEvent ) : void => {
95+ if ( ! this . hasRunningApps ) {
96+ this . swipeDetector . reset ( ) ;
97+ return ;
98+ }
99+
69100 this . swipeDetector . handleTouchStart ( e ) ;
70101 } ;
71102
103+ private handleTouchCancel = ( ) : void => {
104+ this . swipeDetector . reset ( ) ;
105+ } ;
106+
72107 private handleTouchEnd = ( e : TouchEvent ) : void => {
73- if ( ! this . hasRunningApps ) return ;
108+ if ( ! this . hasRunningApps ) {
109+ this . swipeDetector . reset ( ) ;
110+ return ;
111+ }
74112
75113 const result = this . swipeDetector . handleTouchEnd ( e ) ;
76114
@@ -101,16 +139,7 @@ export class HomeButton extends LitElement {
101139 } ;
102140
103141 override render ( ) {
104- return html `
105- < div
106- class ="home-button-wrapper "
107- @touchstart =${ this . handleTouchStart }
108- @touchend =${ this . handleTouchEnd }
109- @click=${ this . handleClick }
110- >
111- < slot > </ slot >
112- </ div >
113- ` ;
142+ return html `< slot > </ slot > ` ;
114143 }
115144}
116145
0 commit comments