Fix error "Uncaught TypeError: Cannot read property 'pageX' of undefined"