react-aim
Advanced tools
Comparing version 0.1.9 to 0.1.10
# CHANGELOG | ||
## 0.1.10 (September 22th, 2016) | ||
- Initial release | ||
## 0.1.0 (May 31st, 2016) | ||
- Initial release |
@@ -25,2 +25,18 @@ 'use strict'; | ||
function scrollPosition() { | ||
var scrollTop = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop; | ||
var scrollLeft = document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft; | ||
return { scrollTop: scrollTop, scrollLeft: scrollLeft }; | ||
} | ||
function mousePosition(event) { | ||
var sPos = scrollPosition(); | ||
var x = document.all ? event.clientX + sPos.scrollLeft : event.pageX; | ||
var y = document.all ? event.clientY + sPos.scrollTop : event.pageY; | ||
return { x: x, y: y }; | ||
} | ||
var Monitor = function () { | ||
@@ -35,3 +51,3 @@ function Monitor() { | ||
this.handleMouseMove = function (e) { | ||
_this.mousePosition = { x: e.pageX, y: e.pageY }; | ||
_this.mousePosition = mousePosition(e); | ||
_this.checkAim(e); | ||
@@ -135,6 +151,10 @@ _this.prevMousePosition = _this.mousePosition; | ||
if (component._isMounted) { | ||
var mPos = mousePosition(event); | ||
var sPos = scrollPosition(); | ||
var rect = _reactDom2.default.findDOMNode(component).getBoundingClientRect(); | ||
var left = rect.left >= 0 ? rect.left : 0; | ||
var top = rect.top >= 0 ? rect.top : 0; | ||
return event.pageX >= left && event.pageX <= left + rect.width && event.pageY >= top && event.pageY <= top + rect.height; | ||
var left = rect.left + sPos.scrollLeft; | ||
var top = rect.top + sPos.scrollTop; | ||
return mPos.x >= left && mPos.x <= left + rect.width && mPos.y >= top && mPos.y <= top + rect.height; | ||
} | ||
@@ -141,0 +161,0 @@ return false; |
@@ -39,3 +39,3 @@ 'use strict'; | ||
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(_class).call(this)); | ||
var _this = _possibleConstructorReturn(this, (_class.__proto__ || Object.getPrototypeOf(_class)).call(this)); | ||
@@ -42,0 +42,0 @@ _this._isOver = false; |
@@ -39,3 +39,3 @@ 'use strict'; | ||
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(_class).call(this)); | ||
var _this = _possibleConstructorReturn(this, (_class.__proto__ || Object.getPrototypeOf(_class)).call(this)); | ||
@@ -42,0 +42,0 @@ _this.aiming = false; |
{ | ||
"name": "react-aim", | ||
"author": "Gabriel Bull", | ||
"version": "0.1.9", | ||
"version": "0.1.10", | ||
"description": "Determine the cursor aim for triggering mouse events.", | ||
@@ -34,3 +34,3 @@ "main": "./lib/index.js", | ||
"build-publish": "npm run build && npm publish", | ||
"playground": "./node_modules/.bin/webpack-dev-server --config ./playground/webpack.config.js --colors --inline --port 3005", | ||
"playground": "./node_modules/.bin/webpack-dev-server --config ./playground/webpack.config.js --colors --inline --port 3000", | ||
"test": "./node_modules/.bin/mocha test" | ||
@@ -43,20 +43,20 @@ }, | ||
"devDependencies": { | ||
"babel-core": "^6.9.1", | ||
"babel-eslint": "^6.0.4", | ||
"babel-loader": "^6.2.4", | ||
"babel-core": "^6.14.0", | ||
"babel-eslint": "^6.1.2", | ||
"babel-loader": "^6.2.5", | ||
"babel-plugin-transform-decorators-legacy": "^1.3.4", | ||
"babel-preset-es2015": "^6.6.0", | ||
"babel-preset-react": "^6.5.0", | ||
"babel-preset-es2015": "^6.14.0", | ||
"babel-preset-react": "^6.11.1", | ||
"babel-preset-stage-0": "^6.5.0", | ||
"chai": "^3.5.0", | ||
"eslint": "^2.12.0", | ||
"eslint-plugin-react": "^5.1.1", | ||
"html-webpack-plugin": "^2.21.0", | ||
"mocha": "^2.5.3", | ||
"react": "^15.1.0", | ||
"react-dom": "^15.1.0", | ||
"react-hot-loader": "^1.3.0", | ||
"webpack": "^1.13.1", | ||
"webpack-dev-server": "^1.14.1" | ||
"eslint": "^3.5.0", | ||
"eslint-plugin-react": "^6.3.0", | ||
"html-webpack-plugin": "^2.22.0", | ||
"mocha": "^3.0.2", | ||
"react": "^15.3.2", | ||
"react-dom": "^15.3.2", | ||
"react-hot-loader": "^3.0.0-beta.5", | ||
"webpack": "^1.13.2", | ||
"webpack-dev-server": "^1.16.1" | ||
} | ||
} |
455422
1267