Skip to content

Commit

Permalink
rebase WheelEvent on top of MouseEvent
Browse files Browse the repository at this point in the history
According to documentation on MDN¹, the WheelEvent interface
inherits properties from MouseEvent, which in turn inherits from
UIEvent, and that inherits from Event.

Embed MouseEvent in WheelEvent type in order to gain access to
additional properties in WheelEvent.

¹ https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent

Fixes #68.

GitHub-Pull-Request: #77
  • Loading branch information
dmitshur authored May 9, 2020
1 parent c2cbf93 commit d4405f7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions events.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func wrapEvent(o *js.Object) Event {
case js.Global.Get("UserProximityEvent"):
return &UserProximityEvent{ev}
case js.Global.Get("WheelEvent"):
return &WheelEvent{BasicEvent: ev}
return &WheelEvent{MouseEvent: &MouseEvent{UIEvent: &UIEvent{ev}}}
default:
return ev
}
Expand Down Expand Up @@ -395,7 +395,7 @@ const (
)

type WheelEvent struct {
*BasicEvent
*MouseEvent
DeltaX float64 `js:"deltaX"`
DeltaY float64 `js:"deltaY"`
DeltaZ float64 `js:"deltaZ"`
Expand Down
4 changes: 2 additions & 2 deletions v2/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func wrapEvent(o js.Value) Event {
case c.Equal(js.Global().Get("UserProximityEvent")):
return &UserProximityEvent{ev}
case c.Equal(js.Global().Get("WheelEvent")):
return &WheelEvent{BasicEvent: ev}
return &WheelEvent{MouseEvent: &MouseEvent{UIEvent: &UIEvent{ev}}}
default:
return ev
}
Expand Down Expand Up @@ -400,7 +400,7 @@ const (
)

type WheelEvent struct {
*BasicEvent
*MouseEvent
}

func (ev *WheelEvent) DeltaX() float64 { return ev.Get("deltaX").Float() }
Expand Down
4 changes: 2 additions & 2 deletions v2/events_go113.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func wrapEvent(o js.Value) Event {
case js.Global().Get("UserProximityEvent"):
return &UserProximityEvent{ev}
case js.Global().Get("WheelEvent"):
return &WheelEvent{BasicEvent: ev}
return &WheelEvent{MouseEvent: &MouseEvent{UIEvent: &UIEvent{ev}}}
default:
return ev
}
Expand Down Expand Up @@ -400,7 +400,7 @@ const (
)

type WheelEvent struct {
*BasicEvent
*MouseEvent
}

func (ev *WheelEvent) DeltaX() float64 { return ev.Get("deltaX").Float() }
Expand Down

0 comments on commit d4405f7

Please sign in to comment.