Skip to content
This repository has been archived by the owner on Aug 23, 2018. It is now read-only.

Non-integral pageX and pageY don't work #6

Closed
crazymykl opened this issue Feb 22, 2017 · 3 comments
Closed

Non-integral pageX and pageY don't work #6

crazymykl opened this issue Feb 22, 2017 · 3 comments

Comments

@crazymykl
Copy link

The CSSOM View Module redefines pageX and pageY as double. To make matters worse, IE 11 is prescient, and already treats them as such. IE 10 seems to exhibit the same issue.

(Crummy) SSCCE: on IE 11, go to jquery.com, scroll down the page a bit, run $('body').on('mousemove', function (e) { console.log(e.pageX, e.pageY) }), and waggle the cursor. Non-integral Y positions abound.

It would be nice to (also) get a patch version that decodes them as floats then rounds, just so existing libraries (e. g. https://github.com/zaboco/elm-draggable) work without changes.

@eriklott
Copy link

It would be useful to have these values as floats with the decimals intact. We have a package that relies on detecting the direction of the mouse pointer movement (comparing last position to current position), and without the decimals, the algorithm does a lousy job at slow speeds because all values are rounded to the closest integer - any small movement registers as no movement.

@roine
Copy link

roine commented Sep 7, 2017

I hit this issue today on IE 10, I don't need the position value but the Decoder is failing because pageX and pageY are Float in IE and the Position decoder expects Ints. Hence this line, in the DOM library in DOM.js:22 is never executed

_elm_lang$core$Native_Scheduler.rawSpawn(toTask(result._0));

I imagine the fix would be easy but would require a major bump in the version. Something like

type alias Position =
    { x : Float
    , y : Float
    }

position : Json.Decoder Position
position =
    Json.map2 Position
        (Json.field "pageX" Json.float)
        (Json.field "pageY" Json.float)

All the libraries that use elm-lang/mouse are not behaving as expected in IE.
List of open source projects using elm-lang/mouse:
https://github.com/search?q=elm-lang%2Fmouse&type=Code&utf8=%E2%9C%93

@evancz
Copy link
Contributor

evancz commented Aug 22, 2018

The Browser.Events module in elm/browser allows you to do whatever you want here.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants