Skip to content

Commit e88a10e

Browse files
committed
3.0.8
1 parent f9a03eb commit e88a10e

File tree

4 files changed

+26
-16
lines changed

4 files changed

+26
-16
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
## Change Log
22

3+
### 3.0.8 (2016/07/01 09:29 +00:00)
4+
- [#127](https://github.com/wwayne/react-tooltip/pull/127) Fix stack overflow in some edge case of position calculation (@wwayne)
5+
- [#125](https://github.com/wwayne/react-tooltip/pull/125) Update page <title> for example page (@brandly)
6+
37
### 3.0.7 (2016/06/24 13:58 +00:00)
48
- [#124](https://github.com/wwayne/react-tooltip/pull/124) Consider both vertical and horizontal into place re-calculation (@wwayne)
59

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-tooltip",
3-
"version": "3.0.7",
3+
"version": "3.0.8",
44
"description": "react tooltip component",
55
"main": "dist/index.js",
66
"scripts": {

standalone/react-tooltip.js

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,7 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
604604
var node = _reactDom2.default.findDOMNode(this);
605605

606606
var result = (0, _getPosition2.default)(currentEvent, currentTarget, node, place, effect, offset);
607+
607608
if (result.isNewState) {
608609
// Switch to reverse placement
609610
return this.setState(result.newState, function () {
@@ -737,29 +738,28 @@ exports.default = function (e, target, node, place, effect, offset) {
737738

738739
// Judge if the tooltip has over the window(screen)
739740
var outsideVertical = function outsideVertical() {
740-
// Check for horazontal tooltip, if their vertical out of screen
741741
var result = false;
742742
var newPlace = void 0;
743-
if (getTipOffsetTop('left') < 0 && getTipOffsetBottom('left') <= windowHeight) {
743+
if (getTipOffsetTop('left') < 0 && getTipOffsetBottom('left') <= windowHeight && getTipOffsetBottom('bottom') <= windowHeight) {
744744
result = true;
745745
newPlace = 'bottom';
746-
} else if (getTipOffsetBottom('left') > windowHeight && getTipOffsetTop('left') >= 0) {
746+
} else if (getTipOffsetBottom('left') > windowHeight && getTipOffsetTop('left') >= 0 && getTipOffsetTop('top') >= 0) {
747747
result = true;
748748
newPlace = 'top';
749749
}
750-
if (result && outsideHorizontal().result) result = false;
751750
return { result: result, newPlace: newPlace };
752751
};
753752
var outsideLeft = function outsideLeft() {
754-
// For horizontal tooltip, if vertical out of screen, change the vertical place
755-
756753
var _outsideVertical = outsideVertical();
757754

758755
var result = _outsideVertical.result;
759-
var newPlace = _outsideVertical.newPlace;
756+
var newPlace = _outsideVertical.newPlace; // Deal with vertical as first priority
760757

758+
if (result && outsideHorizontal().result) {
759+
return { result: false }; // No need to change, if change to vertical will out of space
760+
}
761761
if (!result && getTipOffsetLeft('left') < 0 && getTipOffsetRight('right') <= windowWidth) {
762-
result = true;
762+
result = true; // If vertical ok, but let out of side and right won't out of side
763763
newPlace = 'right';
764764
}
765765
return { result: result, newPlace: newPlace };
@@ -770,6 +770,9 @@ exports.default = function (e, target, node, place, effect, offset) {
770770
var result = _outsideVertical2.result;
771771
var newPlace = _outsideVertical2.newPlace;
772772

773+
if (result && outsideHorizontal().result) {
774+
return { result: false }; // No need to change, if change to vertical will out of space
775+
}
773776
if (!result && getTipOffsetRight('right') > windowWidth && getTipOffsetLeft('left') >= 0) {
774777
result = true;
775778
newPlace = 'left';
@@ -780,15 +783,13 @@ exports.default = function (e, target, node, place, effect, offset) {
780783
var outsideHorizontal = function outsideHorizontal() {
781784
var result = false;
782785
var newPlace = void 0;
783-
if (getTipOffsetLeft('top') < 0 && getTipOffsetRight('top') <= windowWidth) {
786+
if (getTipOffsetLeft('top') < 0 && getTipOffsetRight('top') <= windowWidth && getTipOffsetRight('right') <= windowWidth) {
784787
result = true;
785788
newPlace = 'right';
786-
} else if (getTipOffsetRight('top') > windowWidth && getTipOffsetLeft('top') >= 0) {
789+
} else if (getTipOffsetRight('top') > windowWidth && getTipOffsetLeft('top') >= 0 && getTipOffsetLeft('left') >= 0) {
787790
result = true;
788791
newPlace = 'left';
789792
}
790-
791-
if (result && outsideVertical().result) result = false;
792793
return { result: result, newPlace: newPlace };
793794
};
794795
var outsideTop = function outsideTop() {
@@ -797,6 +798,9 @@ exports.default = function (e, target, node, place, effect, offset) {
797798
var result = _outsideHorizontal.result;
798799
var newPlace = _outsideHorizontal.newPlace;
799800

801+
if (result && outsideVertical().result) {
802+
return { result: false };
803+
}
800804
if (!result && getTipOffsetTop('top') < 0 && getTipOffsetBottom('bottom') <= windowHeight) {
801805
result = true;
802806
newPlace = 'bottom';
@@ -809,6 +813,9 @@ exports.default = function (e, target, node, place, effect, offset) {
809813
var result = _outsideHorizontal2.result;
810814
var newPlace = _outsideHorizontal2.newPlace;
811815

816+
if (result && outsideVertical().result) {
817+
return { result: false };
818+
}
812819
if (!result && getTipOffsetBottom('bottom') > windowHeight && getTipOffsetTop('top') >= 0) {
813820
result = true;
814821
newPlace = 'top';

standalone/react-tooltip.min.js

Lines changed: 2 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)