-
Notifications
You must be signed in to change notification settings - Fork 161
Add PointerEvent and related event handlers. #317
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
It seems like everything is now correctly formatted. Unfortunately I am unable to check this since the sbt task does not fail on my own system. |
Can't you run |
Sorry, I did not know scalafmt was a thing. |
* in addition to new properties for other forms of input: pressure, contact geometry, tilt, etc. | ||
* In fact, the PointerEvent interface inherits all of the MouseEvent's properties thus facilitating | ||
* migrating content from mouse events to pointer events. | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you confirm that you are the original author of this documentation text?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is the documentation found on MDN. I added credit below (that must have slipped through).
MDN documents are licensed under the Creative Commons license found here: https://github.com/mdn/mdn/blob/master/LICENSE
*/ | ||
@js.native | ||
@JSGlobal | ||
class PointerEvent extends MouseEvent { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The constructor should take a type: String
, and optionally a init: PointerEventInit
, according to https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/PointerEvent.
PointerEventInit
should be modeled as a non-native JS trait, with = js.undefined
for all members.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the necessary Init trait and constructor parameters.
Please note that this also applies to MouseEvent, which is currently not implemented.
* | ||
* MDN | ||
*/ | ||
def pointerId: Int = js.native |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://www.w3.org/TR/pointerevents/#pointerevent-interface says that pointerId
is a long
in the IDL, so it should be a Double
in Scala.js, not an Int
(and not a Long
either).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed it accordingly.
> https://www.w3.org/TR/pointerevents/#pointerevent-interface says that pointerId is a long in the IDL, so it should be a Double in Scala.js, not an Int (and not a Long either).
In the last 2 commits I also added the additional |
/** | ||
* Sets value of MouseEvent.pointerId. Defaults to 0. | ||
*/ | ||
var pointerId: js.undefOr[Double] = js.undefined |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
undefOr
-> UndefOr
to fix the compile error.
Otherwise good to go.
Pointer events are now available across all major browsers, since they provide several advantages over traditional mouse and touch events, it would be handy to be able to use them in scalajs.