Skip to content
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

Uncaught TypeError: Cannot read property 'pageX' of undefined #251

Closed
73rhodes opened this issue Aug 10, 2015 · 55 comments
Closed

Uncaught TypeError: Cannot read property 'pageX' of undefined #251

73rhodes opened this issue Aug 10, 2015 · 55 comments
Milestone

Comments

@73rhodes
Copy link

73rhodes commented Aug 10, 2015

This error originates from the pointerMove event listener, initiating a call chain to setEventXY and getPageXY, where evidently the pointer is has been passed in as undefined.

Seen on Google Chrome and Chrome Mobile, running on WIndows 8.1, Android 4.4, Windows (version undefined) and Linux.

getPageXY should handle null pointer exceptions (no pun intended).

@taye
Copy link
Owner

taye commented Aug 11, 2015

Could you copy the full stack trace and paste it here? Which version of interact.js are you using?

@73rhodes
Copy link
Author

interact.js v1.2.4

The stack trace is from a compressed bundle, so not very readable:

bundle.js:5:22346 f
e.client.vx=e.client.x/a,e.client.vy=e.client.y/a}function f(e,t,n){return n=n||{},e=e||"page",n.x=t[e+"X"],n.y=t[e+"Y"],n}function y(e,t,n){return t=t||{},e instanceof Y?/inertiastart/.test(e.type)?(

bundle.js:5:22628 y
=n.inertiaStatus.sy):(t.x=e.pageX,t.y=e.pageY):Ft?(f("screen",e,t),t.x+=pt.scrollX,t.y+=pt.scrollY):f("page",e,t),t}function g(e,t,n){return t=t||{},e instanceof Y?/inertiastart/.test(e.type)?(d(t,n.i

bundle.js:5:21793 h
,e.timeStamp=t.timeStamp}function h(e,t,n){t||(t=n.pointerIds.length>1?w(n.pointers):n.pointers[0]),y(t,Tt,n),e.page.x=Tt.x,e.page.y=Tt.y,g(t,Tt,n),e.client.x=Tt.x,e.client.y=Tt.y,e.timeStamp=(new Dat

bundle.js:6:11237 Object.U.setEventXY
){return y(e,t,this)},getClientXY:function(e,t){return g(e,t,this)},setEventXY:function(e,t){return h(e,t,this)},pointerOver:function(e,t,n){function a(e,t){e&&O(e,n)&&!B(e,n,n)&&I(e,n,n)&&ut(n,t)&&(o

bundle.js:6:17675Object.U.pointerMove
prepared.name+"Start"](this.downEvent))},pointerMove:function(e,t,a,o,r){this.recordPointer(e),this.setEventXY(this.curCoords,e instanceof Y?this.inertiaStatus.startEvent:void 0);var i,s,l=this.curCoo

bundle.js:5:29662 HTMLDocument.<anonymous>
gedTouches.length;a++){var i=t.changedTouches[a];n=j(i,t.type,o),n&&(n._updateEventTargets(o,r),n[e](i,t,o,r))}else{if(!zt&&/mouse/.test(t.type)){for(a=0;a<wt.length;a++)if(!wt[a].mouse&&wt[a].pointer

But, from a quick review of the code it's clear that there are cases where the setEventXY method will be called with pointer == undefined

@JulienBier
Copy link

Same issue here.

@taye
Copy link
Owner

taye commented Aug 15, 2015

Can you use the master version and generate a sourcemap for the bundle then paste the stacktrace here or make a small demo that demonstrates the bug?

@xlc
Copy link
Contributor

xlc commented Sep 1, 2015

I also have this issue in my app. Here is a plunker to reproduce it: http://embed.plnkr.co/isvvZTN92aTmPUZLDtND/preview

Using Chromebook Version 45.0.2454.15 beta (64-bit)
Steps are:

  1. Drag one of the div using mouse.
  2. Use touch gesture to zoom in.
  3. Use touch gesture to zoom out.
  4. Exception logged in developer console.
Uncaught TypeError: Cannot read property 'pageX' of undefined
getXY @ interact.js:657
getPageXY @ interact.js:688
setEventXY @ interact.js:623
Interaction.setEventXY @ interact.js:1325
Interaction.pointerMove @ interact.js:1761target @ interact.js:3248

I also tried on master and not able to reproduce this issue. Is the master version consider stable enough for production? Is any expect release date for next version?

@taye
Copy link
Owner

taye commented Sep 2, 2015

@xlc Thanks for the info!

There have so far mostly been bug fixes since the previous release. The biggest change is probably

Added event parameters to actionCheckers and dropCheckers

From commits 88dc583 and 16d74d4.

If you don't use an actionChecker or dropChecker at all then everything will probably work fine. I don't have many devices to test on at the moment so if you do, I'd really appreciate it if you can report any problems or just let me know if everything works.

@xlc
Copy link
Contributor

xlc commented Sep 10, 2015

The problem I discovered before did not exist anymore. However there is still a Uncaught TypeError: Cannot read property 'pageX' of null issue keep happening.

I am using 3550e57

I am not yet able to reproduce it.
Here is the stack trace I got from production logs, the code is minified so I only have line numbers:

this.dx = page.x - interaction.prevEvent.pageX;

dragEvent = new InteractEvent(this, event, 'drag', 'move', this.element),

this.prevEvent = this[this.prepared.name + 'Move'](event);

interaction[method](event, event, eventTarget, curEventTarget);

@taye taye closed this as completed in 64882d3 Sep 11, 2015
@taye
Copy link
Owner

taye commented Sep 11, 2015

This should be fixed now. A new release is due tomorrow or the day after. Thanks for all the information!

@marian-r
Copy link
Contributor

I am still experiencing both issues, the original one reported by @73rhodes and the other one reported by @xlc.
Stack trace for the orignal issue:

  • getXY()
  • getPageXY()
  • setEventXY()
  • pointerMove()

Stack trace for the second issue is the same as here #251 (comment).

I am using the b3bfc3e version.

@taye
Copy link
Owner

taye commented Oct 28, 2015

@marian-r Can you try with the very latest commit from master? It's been bundled in the unstable branch so you can download it from https://rawgit.com/taye/interact.js/unstable/dist/interact.js if you don't want to build it yourself.

@marian-r
Copy link
Contributor

I am using it via Bower. Can I get the latest version from master via Bower, but the version which is built already?

@taye
Copy link
Owner

taye commented Oct 29, 2015

According to this, using this in your bower.json file should work:

"interact": "https://github.com/taye/interact.js.git#unstable"

@marian-r
Copy link
Contributor

marian-r commented Nov 1, 2015

Thanks, I didn't realized you include the bundled version in the unstable branch. Can that branch be used in production? Because the name is not promising. Anyway, to test it in production I would need #295 to be fixed as I did in #296, but only for stable branch. Currently, I'm using my forked version with the fix in production. Do you see the fix happening soon?

@taye
Copy link
Owner

taye commented Nov 5, 2015

The next version is planned to be 1.3.0. The minor version is being bumped because of the significant changes of #231. I've decided not to make changes for the 1.2.* code and all improvements since the 1.2.6 release have been for the 1.3.0 target. A few of the bugs that are currently in the stable branch have been fixed in the unstable branch which I find is quite stable, but you might come across a surprise or two. I'll try to fix bugs (or at least provide workarounds) quickly especially if they're in production.

I've implemented a fix for #295 and updated unstable to include it.

@marian-r
Copy link
Contributor

marian-r commented Nov 6, 2015

Oh, thanks a lot for all your work. I would like to try the version 1.3.0, just I don't have enough time at the moment. But I will let you know as soon as I manage to use it.

@nttrung143
Copy link

@taye: sorry for ask, do you have any release plan for 1.3.0
I tried unstable on my app for Windows Surface Pro-3 (use WinJS), it's fixed the problem "Cannot read property 'pageX' of undefined", but it's unstable and cause other bug.
Stable version work fine with only "Cannot read property 'pageX' of undefined" problem.

@taye
Copy link
Owner

taye commented Nov 25, 2015

@nttrung143 Can you describe the new bugs that you're seeing and provide stack traces if exceptions are being raised?

I really don't know when the next version will come. I have a lot of other work to do and can't work on writing tests to find bugs. What would probably make the release happen sooner would be for people to try the latest version and report any bugs that they find. If they don't find any bugs and are using interact.js for fairly complex interactions, it would also be helpful if they mention in the Gitter chatroom that things are working well for them and list which features they're using.

@milkshoes
Copy link

We are also seeing errors with the Interact 1.2.6 via bower.

"Uncaught TypeError: a.getClientRects is not a function" - interact.js:717
"Uncaught TypeError: Cannot read property 'pageX' of null" - interact.js:3472
"Uncaught TypeError: Cannot read property 'timeStamp' of null" - interact.js:3555

Also we tried updating our bower.json file to the following::
"interact": "https://github.com/taye/interact.js.git#unstable"

But we still get these errors. Any suggestions?

Update:

I've noticed that when I do NOT have a dropzone engaged I am able to drag. However, this isn't ideal since we do need a dropzone to actually drop.

Below is my dropzone that seems to cause the errors with the actual dragging:

interact = interact || window.exports.interact;
interact(element).dropzone({
accept: '.js-draggable',
overlap: 0.1,
ondragenter: onDragEnter,
ondragleave: onDragLeave,
ondrop: onDrop
});

Seems like it might have something to do with passing in an (element) into the dropzone?

@taye
Copy link
Owner

taye commented Jan 24, 2016

Can you open a new issue and provide information about the errors you're getting with the unstable version including browser version and stack traces (preferably with line numbers in the source files by using source maps).

@marian-r
Copy link
Contributor

marian-r commented Mar 5, 2016

@taye this issue is still not fixed in the latest version from unstable branch. Any ideas?

@taye
Copy link
Owner

taye commented Apr 8, 2016

@marian-r sorry for the delay. Can you post a stack trace and a brief description of your application?

@taye taye reopened this Apr 8, 2016
@abrbhat
Copy link

abrbhat commented Apr 9, 2016

Here is the stacktrace I am getting for this error:

Uncaught TypeError: Cannot read property 'pageX' of undefined interact.js:649 
getXY @ interact.js:649
getPageXY @ interact.js:666
setEventXY @ interact.js:610
Interaction.setEventXY @ interact.js:1319
Interaction.pointerMove @ interact.js:1782
(anonymous function) @ interact.js:3323

@kairiruutel
Copy link

For me it's the same:

TypeError: Cannot read property 'pageX' of undefined
at type (../libs/interact.js:649:0)
at getXY (../libs/interact.js:666:0)
at getPageXY (../libs/interact.js:610:0)
at setEventXY (../libs/interact.js:1319:0)
at setEventXY (../libs/interact.js:1782:0)
at pointer (../libs/interact.js:3323:0)

@taye
Copy link
Owner

taye commented Apr 14, 2016

@abrbhat @kairiruutel try with the unstable branch.

@stbaer
Copy link
Contributor

stbaer commented Apr 15, 2016

The unstable branch doesn't work for me (using browserify)
Cannot find module './src/utils/window' from 'node_modules/interact.js/dist

@marian-r
Copy link
Contributor

@taye, unfortunately, the error is present in the unstable branch as I mentioned here #251 (comment)

@kairiruutel
Copy link

Are there any updates related to the "TypeError: Cannot read property 'pageX' of undefined"?

@taye
Copy link
Owner

taye commented Aug 10, 2016

I'm sorry for the not sorting this out after so long. I'll begin to investigate this issue again in the coming days.

@taye
Copy link
Owner

taye commented Sep 11, 2016

There's a new unstable build. Please update and and report any issues. A demo to reproduce this bug would be very helpful as I haven't encountered it.

@kelvin4incubit
Copy link

// I am still having the same problem at this line of code, it says getAttribute is not defined

var x = (parseFloat(target.getAttribute('data-x')) || 0);
var y = (parseFloat(target.getAttribute('data-y')) || 0);

@irisjae
Copy link

irisjae commented Oct 8, 2016

It used to be clashing with dragging the handle in noUISlider. However with the unstable build this error is gone! Thanks @taye.

@AlecRust
Copy link

AlecRust commented Nov 2, 2016

Also unable to build this unstable branch with Browserify:

Cannot find module './src/utils/window' from 'node_modules/interact.js/dist

@taye
Copy link
Owner

taye commented Nov 28, 2016

@AlecRust The unstable branch is already built with the bundled files and source maps in the dist/ directory. You can build from the master branch instead which doesn't have a dist/ directory.

@stevelove
Copy link

stevelove commented Dec 9, 2016

@taye I haven't tried the unstable branch, but I can easily reproduce this issue in Chrome 55.0.2883.75 on http://interactjs.io/

Steps to reproduce:

  1. Make sure your browser window is not maximized.
  2. Open the Chrome Developer Tools console.
  3. Visit http://interactjs.io/
  4. Move your mouse off of, then back onto the browser window again.
  5. Observe that each time your mouse moves onto the browser window, Uncaught TypeError: Cannot read property 'pageX' of undefined appears in the console.

Alternative reproduction: The error appears simply by moving your mouse onto the webpage from the browser chrome area (tabs, address bar, bookmarks, etc).

@dingquantracy
Copy link

I just come across the same problem as @stevelove , and I have tried v1.3.0, the error is gone but the interact doesn't work itself , why? Are there any difference of two versions @taye

@danwild
Copy link

danwild commented Dec 15, 2016

I'm seeing the same issue as above (as noted by stevelove), with npm pkg v1.2.6.

Just updated to Chrome 55.0.2883.95 (64-bit, OSX) yesterday, so I guess that's what did it, as I run v1.2.6 in a couple of apps and have never seen this issue before.

@sken
Copy link

sken commented Dec 16, 2016

image

Seeing the same issue in version 1.2.6 since Chrome Update

@arlegotin
Copy link

arlegotin commented Dec 16, 2016

This error fires every few seconds in v1.2.6:

screen shot 2016-12-16 at 17 34 23

OS X, Chrome 55.0.2883.95

@kjar3
Copy link

kjar3 commented Dec 16, 2016

I get (above) error "Cannot read property 'pageX' of undefined" when moving my mouse in and out of the chrome browser window

@naivefun
Copy link

comes again.

screen shot 2016-12-17 at 9 24 06 am

@oliveremi
Copy link

Getting the same error + makes chrome tab crash when using draggablev1.2.6

@animator013
Copy link

animator013 commented Dec 19, 2016

Yup same error when moving mouse out of the webpage content (out of chrome). Also when debug console is open and I move the mouse out of the content to the console, this error comes out. The pointer object is undefined as @naivefun also pointed out.

Is there any fix? It's very annoying.

Safari is working. It's most likely a chrome problem.

This bug is discussed here #457.

@alessandro-bottamedi
Copy link

Same problem here, i think when upgrade chrome to v55

@salzhrani
Copy link

@taye please backport the fix to 1.2.x

@taye
Copy link
Owner

taye commented Dec 19, 2016

I've pushed a thing to the stable branch to avoid PointerEvents in Chrome. If you're using v1.2.*, updating to v1.2.8 should solve this issue when it's related to PointerEvents.

@alessandro-bottamedi
Copy link

v1.2.8 fix the error for me

@danwild
Copy link

danwild commented Dec 19, 2016

Confirmed v1.2.8. fixes the error, thanks @taye!

@EranSch
Copy link

EranSch commented Dec 29, 2016

v1.2.8 has also resolved this issue for us. Thanks @taye!

@derwaldgeist
Copy link

Could you please update the download on interact.io to version 1.2.8? Thanks!

@bebeun
Copy link

bebeun commented Jan 11, 2017

fixe for me also ! thk uuu !

@kcaporaso
Copy link

in the meantime, you can use the 1.2.8 version from a CDN.

https://cdnjs.cloudflare.com/ajax/libs/interact.js/1.2.8/interact.js

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

No branches or pull requests