Skip to content

Commit fd8f2b0

Browse files
committed
build(Makefile): add deployExample target, add to deploy
Make sure examples are build during deploy, so automatic gh-pages publish can use them. Update standalone.
1 parent 2bb4b38 commit fd8f2b0

File tree

3 files changed

+49
-23
lines changed

3 files changed

+49
-23
lines changed

Makefile

+8-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ devCSS:
2929
@$(NODE_BIN)/node-sass $(SRC)/index.scss $(EXAMPLE_DIST)/style.css
3030
@$(NODE_BIN)/node-sass -w $(EXAMPLE_SRC)/index.scss $(EXAMPLE_DIST)/index.css
3131

32+
deployExample:
33+
@$(NODE_BIN)/browserify -t babelify $(EXAMPLE_SRC)/index.js -o $(EXAMPLE_DIST)/index.js -dv
34+
@$(NODE_BIN)/node-sass $(EXAMPLE_SRC)/index.scss $(EXAMPLE_DIST)/index.css
35+
@$(NODE_BIN)/node-sass $(SRC)/index.scss $(EXAMPLE_DIST)/style.css
36+
3237
devServer:
3338
@echo Listening 8888...
3439
@$(NODE_BIN)/http-server example -p 8888 -s
@@ -47,9 +52,11 @@ deployJS:
4752
deploy: lint
4853
@echo Deploy...
4954
@rm -rf dist && mkdir dist
55+
@rm -rf $(EXAMPLE_DIST) && mkdir -p $(EXAMPLE_DIST)
56+
@make deployExample
5057
@make convertCSS
5158
@make deployJS
5259
@make genStand
5360
@echo success!
5461

55-
.PHONY: lint convertCSS genStand devJS devCSS devServer dev deployJS deployCSS deploy
62+
.PHONY: lint convertCSS genStand devJS devCSS devServer dev deployExample deployJS deployCSS deploy

standalone/react-tooltip.js

+40-21
Original file line numberDiff line numberDiff line change
@@ -1835,7 +1835,7 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
18351835
var isMyElement = targetArray.some(function (ele) {
18361836
return ele === e.currentTarget;
18371837
});
1838-
if (!isMyElement || this.state.show) return;
1838+
if (!isMyElement) return;
18391839
}
18401840
// Get the tooltip content
18411841
// calculate in this phrase so that tip width height can be detected
@@ -1888,6 +1888,7 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
18881888
_this5.setState({
18891889
isEmptyTip: isEmptyTip
18901890
});
1891+
_this5.updatePosition();
18911892
}
18921893
}, getContent[1]);
18931894
}
@@ -2172,14 +2173,19 @@ Object.defineProperty(exports, "__esModule", {
21722173
});
21732174

21742175
exports.default = function (e, target, node, place, desiredPlace, effect, offset) {
2175-
var tipWidth = node.clientWidth;
2176-
var tipHeight = node.clientHeight;
2176+
var _getDimensions = getDimensions(node),
2177+
tipWidth = _getDimensions.width,
2178+
tipHeight = _getDimensions.height;
2179+
2180+
var _getDimensions2 = getDimensions(target),
2181+
targetWidth = _getDimensions2.width,
2182+
targetHeight = _getDimensions2.height;
21772183

21782184
var _getCurrentOffset = getCurrentOffset(e, target, effect),
21792185
mouseX = _getCurrentOffset.mouseX,
21802186
mouseY = _getCurrentOffset.mouseY;
21812187

2182-
var defaultOffset = getDefaultPosition(effect, target.clientWidth, target.clientHeight, tipWidth, tipHeight);
2188+
var defaultOffset = getDefaultPosition(effect, targetWidth, targetHeight, tipWidth, tipHeight);
21832189

21842190
var _calculateOffset = calculateOffset(offset),
21852191
extraOffset_X = _calculateOffset.extraOffset_X,
@@ -2361,28 +2367,18 @@ exports.default = function (e, target, node, place, desiredPlace, effect, offset
23612367
};
23622368
};
23632369

2364-
// Get current mouse offset
2365-
var getCurrentOffset = function getCurrentOffset(e, currentTarget, effect) {
2366-
var boundingClientRect = currentTarget.getBoundingClientRect();
2367-
var targetTop = boundingClientRect.top;
2368-
var targetLeft = boundingClientRect.left;
2369-
var targetWidth = currentTarget.clientWidth;
2370-
var targetHeight = currentTarget.clientHeight;
2370+
var getDimensions = function getDimensions(node) {
2371+
var _node$getBoundingClie = node.getBoundingClientRect(),
2372+
height = _node$getBoundingClie.height,
2373+
width = _node$getBoundingClie.width;
23712374

2372-
if (effect === 'float') {
2373-
return {
2374-
mouseX: e.clientX,
2375-
mouseY: e.clientY
2376-
};
2377-
}
23782375
return {
2379-
mouseX: targetLeft + targetWidth / 2,
2380-
mouseY: targetTop + targetHeight / 2
2376+
height: parseInt(height, 10),
2377+
width: parseInt(width, 10)
23812378
};
23822379
};
23832380

2384-
// List all possibility of tooltip final offset
2385-
// This is useful in judging if it is necessary for tooltip to switch position when out of window
2381+
// Get current mouse offset
23862382
/**
23872383
* Calculate the position of tooltip
23882384
*
@@ -2399,6 +2395,29 @@ var getCurrentOffset = function getCurrentOffset(e, currentTarget, effect) {
23992395
* - `newState` {Object}
24002396
* - `position` {OBject} {left: {Number}, top: {Number}}
24012397
*/
2398+
var getCurrentOffset = function getCurrentOffset(e, currentTarget, effect) {
2399+
var boundingClientRect = currentTarget.getBoundingClientRect();
2400+
var targetTop = boundingClientRect.top;
2401+
var targetLeft = boundingClientRect.left;
2402+
2403+
var _getDimensions3 = getDimensions(currentTarget),
2404+
targetWidth = _getDimensions3.width,
2405+
targetHeight = _getDimensions3.height;
2406+
2407+
if (effect === 'float') {
2408+
return {
2409+
mouseX: e.clientX,
2410+
mouseY: e.clientY
2411+
};
2412+
}
2413+
return {
2414+
mouseX: targetLeft + targetWidth / 2,
2415+
mouseY: targetTop + targetHeight / 2
2416+
};
2417+
};
2418+
2419+
// List all possibility of tooltip final offset
2420+
// This is useful in judging if it is necessary for tooltip to switch position when out of window
24022421
var getDefaultPosition = function getDefaultPosition(effect, targetWidth, targetHeight, tipWidth, tipHeight) {
24032422
var top = void 0;
24042423
var right = void 0;

0 commit comments

Comments
 (0)