-
-
Notifications
You must be signed in to change notification settings - Fork 147
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
Added position related APIs. #705
Conversation
core/source/Dom.mint
Outdated
} | ||
*/ | ||
fun offsetLeft (element : Dom.Element) : Number { | ||
`#{element}.offsetLeft || -1` |
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.
Returning -1
is here is IMO totally unexpected and may lead to hard-to-debug bugs.
Also, AFAIU it's not coherent with this method documentation.
ditto below
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.
We have other functions that return values similarly https://github.com/mint-lang/mint/blob/master/core/source/Dom.mint#L371 https://github.com/mint-lang/mint/blob/dom-position-things/runtime/src/normalize_event.js#L93 We could return Maybe(Number)
(and for all similar functions) but it would greatly increase the friction when using this.
I'll update the documentation comment to reflect this.
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.
If the element is not in the DOM, it returns 0
:
document.createElement("div").offsetLeft
So maybe returning 0
if it's not applicable is better?
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.
0
sounds better to me, although it still seems more like a hack tbh...
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 guess it's good for now, yet it needs to be changed for other props as well.
f413d2f
to
29e0c8d
Compare
- `Dom.offsetLeft`, `Dom.offsetTop` - `Html.Event.layerX`, `Html.Event.layerY` - `Html.Event.offsetX`, `Html.Event.offsetY` Fixes #498
29e0c8d
to
c5bfd40
Compare
case "layerX": | ||
return -1; | ||
case "layerY": | ||
return -1; | ||
case "offsetX": | ||
return -1; | ||
case "offsetY": | ||
return -1; |
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.
Aren't these need to be changed (to 0
) as well?
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.
Added:
Dom.offsetLeft
,Dom.offsetTop
methodsHtml.Event.layerX
,Html.Event.layerY
fieldsHtml.Event.offsetX
,Html.Event.offsetY
fieldsFixes #498