Skip to content

Commit

Permalink
add PointerEvent.PointerID and PointerEvent.PointerType
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitshur committed Dec 15, 2024
1 parent 51f43a2 commit ebaba6f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
10 changes: 8 additions & 2 deletions events.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func wrapEvent(o *js.Object) Event {
case js.Global.Get("PageTransitionEvent"):
return &PageTransitionEvent{ev}
case js.Global.Get("PointerEvent"):
return &PointerEvent{&MouseEvent{UIEvent: &UIEvent{ev}}}
return &PointerEvent{MouseEvent: &MouseEvent{UIEvent: &UIEvent{ev}}}
case js.Global.Get("PopStateEvent"):
return &PopStateEvent{ev}
case js.Global.Get("ProgressEvent"):
Expand Down Expand Up @@ -307,7 +307,13 @@ func (ev *MouseEvent) ModifierState(mod string) bool {
type MutationEvent struct{ *BasicEvent }
type OfflineAudioCompletionEvent struct{ *BasicEvent }
type PageTransitionEvent struct{ *BasicEvent }
type PointerEvent struct{ *MouseEvent }

type PointerEvent struct {
*MouseEvent
PointerID int `js:"pointerId"`
PointerType string `js:"pointerType"`
}

type PopStateEvent struct{ *BasicEvent }
type ProgressEvent struct{ *BasicEvent }
type RelatedEvent struct{ *BasicEvent }
Expand Down
5 changes: 5 additions & 0 deletions v2/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,12 @@ func (ev *MouseEvent) ModifierState(mod string) bool {
type MutationEvent struct{ *BasicEvent }
type OfflineAudioCompletionEvent struct{ *BasicEvent }
type PageTransitionEvent struct{ *BasicEvent }

type PointerEvent struct{ *MouseEvent }

func (ev *PointerEvent) PointerID() int { return ev.Get("pointerId").Int() }
func (ev *PointerEvent) PointerType() string { return ev.Get("pointerType").String() }

type PopStateEvent struct{ *BasicEvent }
type ProgressEvent struct{ *BasicEvent }
type RelatedEvent struct{ *BasicEvent }
Expand Down

0 comments on commit ebaba6f

Please sign in to comment.