diff --git a/bower.json b/bower.json index 51ef04e..c3a8924 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "react-tooltip-component", - "version": "0.2.0", + "version": "0.2.1", "description": "React component.", "main": ["dist/react-tooltip-component.js", "dist/tooltip"], "keywords": [ diff --git a/dist/react-tooltip-component.js b/dist/react-tooltip-component.js index dc8ce08..636c888 100644 --- a/dist/react-tooltip-component.js +++ b/dist/react-tooltip-component.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["react","react-dom"],t):"object"==typeof exports?exports.ReactTooltipComponent=t(require("react"),require("react-dom")):e.ReactTooltipComponent=t(e.React,e.ReactDOM)}(this,function(e,t){return function(e){function t(n){if(o[n])return o[n].exports;var r=o[n]={exports:{},id:n,loaded:!1};return e[n].call(r.exports,r,r.exports,t),r.loaded=!0,r.exports}var o={};return t.m=e,t.c=o,t.p="",t(0)}([function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0});var r=o(1),i=n(r);t["default"]=i["default"],e.exports=t["default"]},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var p=function(){function e(e,t){for(var o=0;o { @@ -47,8 +47,8 @@ class Tooltip extends React.Component { componentWillUnmount = () => { - this.componentEl.removeEventListener('mousemove', this.handleMouseMove); - this.componentEl.removeEventListener('mouseout', this.handleMouseOut); + this.componentEl.removeEventListener(this.props.fixed ? 'mouseenter' : 'mousemove', this.handleMouseMove); + this.componentEl.removeEventListener('mouseleave', this.handleMouseOut); this.container.removeChild(this.tooltipEl); }; @@ -109,13 +109,13 @@ class Tooltip extends React.Component { cOffsetY = componentHeight / 2; break; } - pointX = componentOffsetX + cOffsetX + window.scrollX; - pointY = componentOffsetY + cOffsetY + window.scrollY; + pointX = componentOffsetX + cOffsetX + (window.scrollX || window.pageXOffset); + pointY = componentOffsetY + cOffsetY + (window.scrollY || window.pageYOffset); } else { let clientX = e.clientX; let clientY = e.clientY; - pointX = clientX - containerOffsetX + window.scrollX; - pointY = clientY - containerOffsetY + window.scrollY; + pointX = clientX - containerOffsetX + (window.scrollX || window.pageXOffset); + pointY = clientY - containerOffsetY + (window.scrollY || window.pageYOffset); } return { x: pointX,