@antv/l7-component 2.9.32-alpha.4 → 2.9.32-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/control/baseControl/buttonControl.d.ts +1 -1
- package/es/control/baseControl/control.d.ts +4 -5
- package/es/control/baseControl/control.js +18 -5
- package/es/control/baseControl/popperControl.d.ts +1 -1
- package/es/control/baseControl/selectControl.d.ts +2 -2
- package/es/control/baseControl/selectControl.js +5 -0
- package/es/control/zoom.d.ts +3 -2
- package/lib/assets/iconfont/iconfont.js +46 -30
- package/lib/constants/index.js +34 -56
- package/lib/control/baseControl/buttonControl.js +194 -105
- package/lib/control/baseControl/control.js +317 -156
- package/lib/control/baseControl/index.js +57 -22
- package/lib/control/baseControl/popperControl.js +136 -102
- package/lib/control/baseControl/selectControl.js +230 -130
- package/lib/control/exportImage.js +175 -81
- package/lib/control/fullscreen.js +157 -102
- package/lib/control/geoLocate.js +143 -67
- package/lib/control/layerControl.js +162 -116
- package/lib/control/logo.js +101 -70
- package/lib/control/mapTheme.js +144 -85
- package/lib/control/mouseLocation.js +112 -71
- package/lib/control/scale.js +180 -127
- package/lib/control/zoom.js +154 -111
- package/lib/index.js +251 -48
- package/lib/interface.js +4 -16
- package/lib/marker-layer.js +367 -249
- package/lib/marker.js +419 -277
- package/lib/popup/layerPopup.js +305 -188
- package/lib/popup/popup.js +602 -339
- package/lib/utils/anchor.js +37 -55
- package/lib/utils/icon.js +13 -32
- package/lib/utils/popper.js +268 -180
- package/lib/utils/screenfull.js +110 -103
- package/package.json +5 -5
package/lib/utils/anchor.js
CHANGED
|
@@ -1,63 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
"use strict";
|
|
18
2
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
__export(anchor_exports, {
|
|
22
|
-
anchorTranslate: () => anchorTranslate,
|
|
23
|
-
anchorType: () => anchorType,
|
|
24
|
-
applyAnchorClass: () => applyAnchorClass
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
25
5
|
});
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
6
|
+
exports.anchorType = exports.anchorTranslate = void 0;
|
|
7
|
+
exports.applyAnchorClass = applyAnchorClass;
|
|
8
|
+
var anchorType;
|
|
9
|
+
exports.anchorType = anchorType;
|
|
10
|
+
|
|
11
|
+
(function (anchorType) {
|
|
12
|
+
anchorType["CENTER"] = "center";
|
|
13
|
+
anchorType["TOP"] = "top";
|
|
14
|
+
anchorType["TOP-LEFT"] = "top-left";
|
|
15
|
+
anchorType["TOP-RIGHT"] = "top-right";
|
|
16
|
+
anchorType["BOTTOM"] = "bottom";
|
|
17
|
+
anchorType["BOTTOM-LEFT"] = "bottom-left";
|
|
18
|
+
anchorType["LEFT"] = "left";
|
|
19
|
+
anchorType["RIGHT"] = "right";
|
|
20
|
+
})(anchorType || (exports.anchorType = anchorType = {}));
|
|
21
|
+
|
|
38
22
|
var anchorTranslate = {
|
|
39
|
-
center:
|
|
40
|
-
top:
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
bottom:
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
left:
|
|
47
|
-
right:
|
|
23
|
+
center: 'translate(-50%,-50%)',
|
|
24
|
+
top: 'translate(-50%,0)',
|
|
25
|
+
'top-left': 'translate(0,0)',
|
|
26
|
+
'top-right': 'translate(-100%,0)',
|
|
27
|
+
bottom: 'translate(-50%,-100%)',
|
|
28
|
+
'bottom-left': 'translate(0,-100%)',
|
|
29
|
+
'bottom-right': 'translate(-100%,-100%)',
|
|
30
|
+
left: 'translate(0,-50%)',
|
|
31
|
+
right: 'translate(-100%,-50%)'
|
|
48
32
|
};
|
|
33
|
+
exports.anchorTranslate = anchorTranslate;
|
|
34
|
+
|
|
49
35
|
function applyAnchorClass(element, anchor, prefix) {
|
|
50
|
-
|
|
51
|
-
|
|
36
|
+
var classList = element.classList;
|
|
37
|
+
|
|
38
|
+
for (var key in anchorTranslate) {
|
|
52
39
|
if (anchorTranslate.hasOwnProperty(key)) {
|
|
53
|
-
classList.remove(
|
|
40
|
+
classList.remove("l7-".concat(prefix, "-anchor-").concat(key));
|
|
54
41
|
}
|
|
55
42
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
0 && (module.exports = {
|
|
60
|
-
anchorTranslate,
|
|
61
|
-
anchorType,
|
|
62
|
-
applyAnchorClass
|
|
63
|
-
});
|
|
43
|
+
|
|
44
|
+
classList.add("l7-".concat(prefix, "-anchor-").concat(anchor));
|
|
45
|
+
}
|
package/lib/utils/icon.js
CHANGED
|
@@ -1,37 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
"use strict";
|
|
18
2
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
__export(icon_exports, {
|
|
22
|
-
createL7Icon: () => createL7Icon
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
23
5
|
});
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
svg.
|
|
28
|
-
svg.
|
|
29
|
-
|
|
30
|
-
use.
|
|
6
|
+
exports.createL7Icon = void 0;
|
|
7
|
+
|
|
8
|
+
var createL7Icon = function createL7Icon(className) {
|
|
9
|
+
var svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
10
|
+
svg.classList.add('l7-iconfont');
|
|
11
|
+
svg.setAttribute('aria-hidden', 'true');
|
|
12
|
+
var use = document.createElementNS('http://www.w3.org/2000/svg', 'use');
|
|
13
|
+
use.setAttributeNS('http://www.w3.org/1999/xlink', 'href', "#".concat(className));
|
|
31
14
|
svg.appendChild(use);
|
|
32
15
|
return svg;
|
|
33
16
|
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
createL7Icon
|
|
37
|
-
});
|
|
17
|
+
|
|
18
|
+
exports.createL7Icon = createL7Icon;
|
package/lib/utils/popper.js
CHANGED
|
@@ -1,209 +1,297 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
|
|
19
|
-
// src/utils/popper.ts
|
|
20
|
-
var popper_exports = {};
|
|
21
|
-
__export(popper_exports, {
|
|
22
|
-
Popper: () => Popper
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
23
7
|
});
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
var
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
8
|
+
exports.Popper = void 0;
|
|
9
|
+
|
|
10
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
|
+
|
|
12
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
|
+
|
|
14
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
|
+
|
|
16
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
17
|
+
|
|
18
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
19
|
+
|
|
20
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
21
|
+
|
|
22
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
23
|
+
|
|
24
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
25
|
+
|
|
26
|
+
var _l7Utils = require("@antv/l7-utils");
|
|
27
|
+
|
|
28
|
+
var _eventemitter = require("eventemitter3");
|
|
29
|
+
|
|
30
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
31
|
+
|
|
32
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
33
|
+
|
|
34
|
+
var Popper = /*#__PURE__*/function (_EventEmitter) {
|
|
35
|
+
(0, _inherits2.default)(Popper, _EventEmitter);
|
|
36
|
+
|
|
37
|
+
var _super = _createSuper(Popper);
|
|
38
|
+
|
|
39
|
+
function Popper(button, option) {
|
|
40
|
+
var _this;
|
|
41
|
+
|
|
42
|
+
(0, _classCallCheck2.default)(this, Popper);
|
|
43
|
+
_this = _super.call(this);
|
|
44
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "isShow", false);
|
|
45
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "timeout", null);
|
|
46
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "show", function () {
|
|
47
|
+
if (_this.isShow || !_this.contentDOM.innerHTML) {
|
|
48
|
+
return (0, _assertThisInitialized2.default)(_this);
|
|
35
49
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
50
|
+
|
|
51
|
+
_this.resetPopperPosition();
|
|
52
|
+
|
|
53
|
+
_l7Utils.DOM.removeClass(_this.popperDOM, 'l7-popper-hide');
|
|
54
|
+
|
|
55
|
+
_this.isShow = true;
|
|
56
|
+
|
|
57
|
+
if (_this.option.unique) {
|
|
58
|
+
// console.log(Popper.conflictPopperList.length);
|
|
59
|
+
Popper.conflictPopperList.forEach(function (popper) {
|
|
60
|
+
if (popper !== (0, _assertThisInitialized2.default)(_this) && popper.isShow) {
|
|
42
61
|
popper.hide();
|
|
43
62
|
}
|
|
44
63
|
});
|
|
45
64
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
65
|
+
|
|
66
|
+
_this.emit('show');
|
|
67
|
+
|
|
68
|
+
return (0, _assertThisInitialized2.default)(_this);
|
|
69
|
+
});
|
|
70
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "hide", function () {
|
|
71
|
+
if (!_this.isShow) {
|
|
72
|
+
return (0, _assertThisInitialized2.default)(_this);
|
|
52
73
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
74
|
+
|
|
75
|
+
_l7Utils.DOM.addClass(_this.popperDOM, 'l7-popper-hide');
|
|
76
|
+
|
|
77
|
+
_this.isShow = false;
|
|
78
|
+
|
|
79
|
+
_this.emit('hide');
|
|
80
|
+
|
|
81
|
+
return (0, _assertThisInitialized2.default)(_this);
|
|
82
|
+
});
|
|
83
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "setHideTimeout", function () {
|
|
84
|
+
if (_this.timeout) {
|
|
60
85
|
return;
|
|
61
86
|
}
|
|
62
|
-
|
|
63
|
-
|
|
87
|
+
|
|
88
|
+
_this.timeout = window.setTimeout(function () {
|
|
89
|
+
if (!_this.isShow) {
|
|
64
90
|
return;
|
|
65
91
|
}
|
|
66
|
-
|
|
67
|
-
|
|
92
|
+
|
|
93
|
+
_this.hide();
|
|
94
|
+
|
|
95
|
+
_this.timeout = null;
|
|
68
96
|
}, 300);
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
if (
|
|
72
|
-
window.clearTimeout(
|
|
73
|
-
|
|
97
|
+
});
|
|
98
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "clearHideTimeout", function () {
|
|
99
|
+
if (_this.timeout) {
|
|
100
|
+
window.clearTimeout(_this.timeout);
|
|
101
|
+
_this.timeout = null;
|
|
74
102
|
}
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
if (
|
|
78
|
-
|
|
103
|
+
});
|
|
104
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onBtnClick", function () {
|
|
105
|
+
if (_this.isShow) {
|
|
106
|
+
_this.hide();
|
|
79
107
|
} else {
|
|
80
|
-
|
|
108
|
+
_this.show();
|
|
81
109
|
}
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
110
|
+
});
|
|
111
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onBtnMouseLeave", function () {
|
|
112
|
+
_this.setHideTimeout();
|
|
113
|
+
});
|
|
114
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onBtnMouseMove", function () {
|
|
115
|
+
_this.clearHideTimeout();
|
|
116
|
+
|
|
117
|
+
if (_this.isShow) {
|
|
89
118
|
return;
|
|
90
119
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
120
|
+
|
|
121
|
+
_this.show();
|
|
122
|
+
});
|
|
123
|
+
_this.button = button;
|
|
124
|
+
_this.option = option;
|
|
125
|
+
|
|
126
|
+
_this.init();
|
|
127
|
+
|
|
96
128
|
if (option.unique) {
|
|
97
|
-
|
|
129
|
+
Popper.conflictPopperList.push((0, _assertThisInitialized2.default)(_this));
|
|
98
130
|
}
|
|
131
|
+
|
|
132
|
+
return _this;
|
|
99
133
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
getIsShow() {
|
|
107
|
-
return this.isShow;
|
|
108
|
-
}
|
|
109
|
-
getContent() {
|
|
110
|
-
return this.content;
|
|
111
|
-
}
|
|
112
|
-
setContent(content) {
|
|
113
|
-
if (typeof content === "string") {
|
|
114
|
-
this.contentDOM.innerHTML = content;
|
|
115
|
-
} else if (content instanceof HTMLElement) {
|
|
116
|
-
import_l7_utils.DOM.clearChildren(this.contentDOM);
|
|
117
|
-
this.contentDOM.appendChild(content);
|
|
134
|
+
|
|
135
|
+
(0, _createClass2.default)(Popper, [{
|
|
136
|
+
key: "buttonRect",
|
|
137
|
+
get: function get() {
|
|
138
|
+
return this.button.getBoundingClientRect();
|
|
118
139
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
this.popperDOM = this.createPopper();
|
|
124
|
-
if (trigger === "click") {
|
|
125
|
-
this.button.addEventListener("click", this.onBtnClick);
|
|
126
|
-
} else {
|
|
127
|
-
this.button.addEventListener("mousemove", this.onBtnMouseMove);
|
|
128
|
-
this.button.addEventListener("mouseleave", this.onBtnMouseLeave);
|
|
129
|
-
this.popperDOM.addEventListener("mousemove", this.onBtnMouseMove);
|
|
130
|
-
this.popperDOM.addEventListener("mouseleave", this.onBtnMouseLeave);
|
|
140
|
+
}, {
|
|
141
|
+
key: "getPopperDOM",
|
|
142
|
+
value: function getPopperDOM() {
|
|
143
|
+
return this.popperDOM;
|
|
131
144
|
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
if (placement.includes("left")) {
|
|
152
|
-
popperStyleObj.right = `${buttonRect.width + right}px`;
|
|
153
|
-
} else if (placement.includes("right")) {
|
|
154
|
-
popperStyleObj.left = `${buttonRect.width + left}px`;
|
|
145
|
+
}, {
|
|
146
|
+
key: "getIsShow",
|
|
147
|
+
value: function getIsShow() {
|
|
148
|
+
return this.isShow;
|
|
149
|
+
}
|
|
150
|
+
}, {
|
|
151
|
+
key: "getContent",
|
|
152
|
+
value: function getContent() {
|
|
153
|
+
return this.content;
|
|
154
|
+
}
|
|
155
|
+
}, {
|
|
156
|
+
key: "setContent",
|
|
157
|
+
value: function setContent(content) {
|
|
158
|
+
if (typeof content === 'string') {
|
|
159
|
+
this.contentDOM.innerHTML = content;
|
|
160
|
+
} else if (content instanceof HTMLElement) {
|
|
161
|
+
_l7Utils.DOM.clearChildren(this.contentDOM);
|
|
162
|
+
|
|
163
|
+
this.contentDOM.appendChild(content);
|
|
155
164
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
165
|
+
|
|
166
|
+
this.content = content;
|
|
167
|
+
}
|
|
168
|
+
}, {
|
|
169
|
+
key: "init",
|
|
170
|
+
value: function init() {
|
|
171
|
+
var trigger = this.option.trigger;
|
|
172
|
+
this.popperDOM = this.createPopper();
|
|
173
|
+
|
|
174
|
+
if (trigger === 'click') {
|
|
175
|
+
this.button.addEventListener('click', this.onBtnClick);
|
|
160
176
|
} else {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
177
|
+
this.button.addEventListener('mousemove', this.onBtnMouseMove);
|
|
178
|
+
this.button.addEventListener('mouseleave', this.onBtnMouseLeave);
|
|
179
|
+
this.popperDOM.addEventListener('mousemove', this.onBtnMouseMove);
|
|
180
|
+
this.popperDOM.addEventListener('mouseleave', this.onBtnMouseLeave);
|
|
164
181
|
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
182
|
+
}
|
|
183
|
+
}, {
|
|
184
|
+
key: "destroy",
|
|
185
|
+
value: function destroy() {
|
|
186
|
+
this.button.removeEventListener('click', this.onBtnClick);
|
|
187
|
+
this.button.removeEventListener('mousemove', this.onBtnMouseMove);
|
|
188
|
+
this.button.removeEventListener('mousemove', this.onBtnMouseLeave);
|
|
189
|
+
this.popperDOM.removeEventListener('mousemove', this.onBtnMouseMove);
|
|
190
|
+
this.popperDOM.removeEventListener('mouseleave', this.onBtnMouseLeave);
|
|
191
|
+
|
|
192
|
+
_l7Utils.DOM.remove(this.popperDOM);
|
|
193
|
+
}
|
|
194
|
+
}, {
|
|
195
|
+
key: "resetPopperPosition",
|
|
196
|
+
value: function resetPopperPosition() {
|
|
197
|
+
var popperStyleObj = {};
|
|
198
|
+
var _this$option = this.option,
|
|
199
|
+
container = _this$option.container,
|
|
200
|
+
_this$option$offset = _this$option.offset,
|
|
201
|
+
offset = _this$option$offset === void 0 ? [0, 0] : _this$option$offset,
|
|
202
|
+
placement = _this$option.placement;
|
|
203
|
+
|
|
204
|
+
var _offset = (0, _slicedToArray2.default)(offset, 2),
|
|
205
|
+
offsetX = _offset[0],
|
|
206
|
+
offsetY = _offset[1];
|
|
207
|
+
|
|
208
|
+
var buttonRect = this.button.getBoundingClientRect();
|
|
209
|
+
var containerRect = container.getBoundingClientRect();
|
|
210
|
+
|
|
211
|
+
var _DOM$getDiffRect = _l7Utils.DOM.getDiffRect(buttonRect, containerRect),
|
|
212
|
+
left = _DOM$getDiffRect.left,
|
|
213
|
+
right = _DOM$getDiffRect.right,
|
|
214
|
+
top = _DOM$getDiffRect.top,
|
|
215
|
+
bottom = _DOM$getDiffRect.bottom;
|
|
216
|
+
|
|
217
|
+
var isTransformX = false;
|
|
218
|
+
var isTransformY = false;
|
|
219
|
+
|
|
220
|
+
if (/^(left|right)/.test(placement)) {
|
|
221
|
+
if (placement.includes('left')) {
|
|
222
|
+
popperStyleObj.right = "".concat(buttonRect.width + right, "px");
|
|
223
|
+
} else if (placement.includes('right')) {
|
|
224
|
+
popperStyleObj.left = "".concat(buttonRect.width + left, "px");
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
if (placement.includes('start')) {
|
|
228
|
+
popperStyleObj.top = "".concat(top, "px");
|
|
229
|
+
} else if (placement.includes('end')) {
|
|
230
|
+
popperStyleObj.bottom = "".concat(bottom, "px");
|
|
231
|
+
} else {
|
|
232
|
+
popperStyleObj.top = "".concat(top + buttonRect.height / 2, "px");
|
|
233
|
+
isTransformY = true;
|
|
234
|
+
popperStyleObj.transform = "translate(".concat(offsetX, "px, calc(").concat(offsetY, "px - 50%))");
|
|
235
|
+
}
|
|
236
|
+
} else if (/^(top|bottom)/.test(placement)) {
|
|
237
|
+
if (placement.includes('top')) {
|
|
238
|
+
popperStyleObj.bottom = "".concat(buttonRect.height + bottom, "px");
|
|
239
|
+
} else if (placement.includes('bottom')) {
|
|
240
|
+
popperStyleObj.top = "".concat(buttonRect.height + top, "px");
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
if (placement.includes('start')) {
|
|
244
|
+
popperStyleObj.left = "".concat(left, "px");
|
|
245
|
+
} else if (placement.includes('end')) {
|
|
246
|
+
popperStyleObj.right = "".concat(right, "px");
|
|
247
|
+
} else {
|
|
248
|
+
popperStyleObj.left = "".concat(left + buttonRect.width / 2, "px");
|
|
249
|
+
isTransformX = true;
|
|
250
|
+
popperStyleObj.transform = "translate(calc(".concat(offsetX, "px - 50%), ").concat(offsetY, "px)");
|
|
251
|
+
}
|
|
170
252
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
253
|
+
|
|
254
|
+
popperStyleObj.transform = "translate(calc(".concat(offsetX, "px - ").concat(isTransformX ? '50%' : '0%', "), calc(").concat(offsetY, "px - ").concat(isTransformY ? '50%' : '0%', ")");
|
|
255
|
+
var posList = placement.split('-');
|
|
256
|
+
|
|
257
|
+
if (posList.length) {
|
|
258
|
+
_l7Utils.DOM.addClass(this.popperDOM, posList.map(function (pos) {
|
|
259
|
+
return "l7-popper-".concat(pos);
|
|
260
|
+
}).join(' '));
|
|
179
261
|
}
|
|
262
|
+
|
|
263
|
+
_l7Utils.DOM.addStyle(this.popperDOM, _l7Utils.DOM.css2Style(popperStyleObj));
|
|
180
264
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
this.
|
|
265
|
+
}, {
|
|
266
|
+
key: "createPopper",
|
|
267
|
+
value: function createPopper() {
|
|
268
|
+
var _this$option2 = this.option,
|
|
269
|
+
container = _this$option2.container,
|
|
270
|
+
_this$option2$classNa = _this$option2.className,
|
|
271
|
+
className = _this$option2$classNa === void 0 ? '' : _this$option2$classNa,
|
|
272
|
+
content = _this$option2.content;
|
|
273
|
+
|
|
274
|
+
var popper = _l7Utils.DOM.create('div', "l7-popper l7-popper-hide ".concat(className));
|
|
275
|
+
|
|
276
|
+
var popperContent = _l7Utils.DOM.create('div', 'l7-popper-content');
|
|
277
|
+
|
|
278
|
+
var popperArrow = _l7Utils.DOM.create('div', 'l7-popper-arrow');
|
|
279
|
+
|
|
280
|
+
popper.appendChild(popperContent);
|
|
281
|
+
popper.appendChild(popperArrow);
|
|
282
|
+
container.appendChild(popper);
|
|
283
|
+
this.popperDOM = popper;
|
|
284
|
+
this.contentDOM = popperContent;
|
|
285
|
+
|
|
286
|
+
if (content) {
|
|
287
|
+
this.setContent(content);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
return popper;
|
|
200
291
|
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
};
|
|
204
|
-
|
|
205
|
-
Popper
|
|
206
|
-
|
|
207
|
-
0 && (module.exports = {
|
|
208
|
-
Popper
|
|
209
|
-
});
|
|
292
|
+
}]);
|
|
293
|
+
return Popper;
|
|
294
|
+
}(_eventemitter.EventEmitter);
|
|
295
|
+
|
|
296
|
+
exports.Popper = Popper;
|
|
297
|
+
(0, _defineProperty2.default)(Popper, "conflictPopperList", []);
|