@@ -551,7 +551,7 @@ export class SpineWebComponentWidget extends HTMLElement implements Disposable,
551
551
* By default, the function does nothing.
552
552
* This is an experimental property and might be removed in the future.
553
553
*/
554
- public cursorBoundsEventCallback = ( event : CursorEventTypes ) => { }
554
+ public cursorBoundsEventCallback = ( event : CursorEventTypes , originalEvent ?: UIEvent ) => { }
555
555
556
556
/**
557
557
* This methods allows to associate to a Slot a callback. For these slots, if the widget is interactive,
@@ -1105,39 +1105,39 @@ export class SpineWebComponentWidget extends HTMLElement implements Disposable,
1105
1105
* @internal
1106
1106
*/
1107
1107
public cursorSlotEventCallbacks : Map < Slot , {
1108
- slotFunction : ( slot : Slot , event : CursorEventTypes ) => void ,
1108
+ slotFunction : ( slot : Slot , event : CursorEventTypes , originalEvent ?: UIEvent ) => void ,
1109
1109
inside : boolean ,
1110
1110
} > = new Map ( ) ;
1111
1111
1112
1112
/**
1113
1113
* @internal
1114
1114
*/
1115
- public cursorEventUpdate ( type : CursorEventTypesInput ) {
1115
+ public cursorEventUpdate ( type : CursorEventTypesInput , originalEvent ?: UIEvent ) {
1116
1116
if ( ! this . isInteractive ) return ;
1117
1117
1118
- this . checkBoundsInteraction ( type ) ;
1119
- this . checkSlotInteraction ( type ) ;
1118
+ this . checkBoundsInteraction ( type , originalEvent ) ;
1119
+ this . checkSlotInteraction ( type , originalEvent ) ;
1120
1120
}
1121
1121
1122
- private checkBoundsInteraction ( type : CursorEventTypesInput ) {
1122
+ private checkBoundsInteraction ( type : CursorEventTypesInput , originalEvent ?: UIEvent ) {
1123
1123
if ( ( type === "down" || type === "up" ) && this . cursorInsideBounds ) {
1124
- this . cursorBoundsEventCallback ( type ) ;
1124
+ this . cursorBoundsEventCallback ( type , originalEvent ) ;
1125
1125
return ;
1126
1126
}
1127
1127
1128
1128
if ( this . checkCursorInsideBounds ( ) ) {
1129
1129
1130
1130
if ( ! this . cursorInsideBounds ) {
1131
- this . cursorBoundsEventCallback ( "enter" ) ;
1131
+ this . cursorBoundsEventCallback ( "enter" , originalEvent ) ;
1132
1132
}
1133
1133
this . cursorInsideBounds = true ;
1134
1134
1135
- this . cursorBoundsEventCallback ( type ) ;
1135
+ this . cursorBoundsEventCallback ( type , originalEvent ) ;
1136
1136
1137
1137
} else {
1138
1138
1139
1139
if ( this . cursorInsideBounds ) {
1140
- this . cursorBoundsEventCallback ( "leave" ) ;
1140
+ this . cursorBoundsEventCallback ( "leave" , originalEvent ) ;
1141
1141
}
1142
1142
this . cursorInsideBounds = false ;
1143
1143
@@ -1158,7 +1158,7 @@ export class SpineWebComponentWidget extends HTMLElement implements Disposable,
1158
1158
return inside ( this . pointTemp , this . bounds ) ;
1159
1159
}
1160
1160
1161
- private checkSlotInteraction ( type : CursorEventTypesInput ) {
1161
+ private checkSlotInteraction ( type : CursorEventTypesInput , originalEvent ?: UIEvent ) {
1162
1162
for ( let [ slot , interactionState ] of this . cursorSlotEventCallbacks ) {
1163
1163
if ( ! slot . bone . active ) continue ;
1164
1164
let attachment = slot . getAttachment ( ) ;
@@ -1169,7 +1169,7 @@ export class SpineWebComponentWidget extends HTMLElement implements Disposable,
1169
1169
1170
1170
if ( type === "down" || type === "up" ) {
1171
1171
if ( inside ) {
1172
- slotFunction ( slot , type ) ;
1172
+ slotFunction ( slot , type , originalEvent ) ;
1173
1173
}
1174
1174
return ;
1175
1175
}
@@ -1192,7 +1192,7 @@ export class SpineWebComponentWidget extends HTMLElement implements Disposable,
1192
1192
1193
1193
if ( ! inside ) {
1194
1194
interactionState . inside = true ;
1195
- slotFunction ( slot , "enter" ) ;
1195
+ slotFunction ( slot , "enter" , originalEvent ) ;
1196
1196
}
1197
1197
1198
1198
slotFunction ( slot , type ) ;
@@ -1201,7 +1201,7 @@ export class SpineWebComponentWidget extends HTMLElement implements Disposable,
1201
1201
1202
1202
if ( inside ) {
1203
1203
interactionState . inside = false ;
1204
- slotFunction ( slot , "leave" ) ;
1204
+ slotFunction ( slot , "leave" , originalEvent ) ;
1205
1205
}
1206
1206
1207
1207
}
@@ -1982,18 +1982,17 @@ class SpineWebComponentOverlay extends HTMLElement implements OverlayAttributes,
1982
1982
this . skeletonList . forEach ( widget => {
1983
1983
if ( ! this . cursorWidgetUpdate ( widget ) || ! widget . onScreen ) return ;
1984
1984
1985
- widget . cursorEventUpdate ( "move" ) ;
1985
+ widget . cursorEventUpdate ( "move" , ev ) ;
1986
1986
} ) ;
1987
1987
} ,
1988
1988
down : ( x , y , ev ) => {
1989
1989
const input = getInput ( ev ) ;
1990
1990
this . skeletonList . forEach ( widget => {
1991
1991
if ( ! widget . onScreen && widget . dragX === 0 && widget . dragY === 0 ) return ;
1992
1992
1993
- widget . cursorEventUpdate ( "down" ) ;
1993
+ widget . cursorEventUpdate ( "down" , ev ) ;
1994
1994
1995
1995
if ( ( widget . isInteractive && widget . cursorInsideBounds ) || ( ! widget . isInteractive && widget . checkCursorInsideBounds ( ) ) ) {
1996
-
1997
1996
if ( ! widget . isDraggable ) return ;
1998
1997
1999
1998
widget . dragging = true ;
@@ -2016,7 +2015,7 @@ class SpineWebComponentOverlay extends HTMLElement implements OverlayAttributes,
2016
2015
this . skeletonList . forEach ( widget => {
2017
2016
if ( ! this . cursorWidgetUpdate ( widget ) || ! widget . onScreen && widget . dragX === 0 && widget . dragY === 0 ) return ;
2018
2017
2019
- widget . cursorEventUpdate ( "drag" ) ;
2018
+ widget . cursorEventUpdate ( "drag" , ev ) ;
2020
2019
2021
2020
if ( ! widget . dragging ) return ;
2022
2021
@@ -2030,12 +2029,12 @@ class SpineWebComponentOverlay extends HTMLElement implements OverlayAttributes,
2030
2029
prevX = input . x ;
2031
2030
prevY = input . y ;
2032
2031
} ,
2033
- up : ( ) => {
2032
+ up : ( x , y , ev ) => {
2034
2033
this . skeletonList . forEach ( widget => {
2035
2034
widget . dragging = false ;
2036
2035
2037
2036
if ( widget . cursorInsideBounds ) {
2038
- widget . cursorEventUpdate ( "up" ) ;
2037
+ widget . cursorEventUpdate ( "up" , ev ) ;
2039
2038
}
2040
2039
} ) ;
2041
2040
}
0 commit comments