@antv/l7-component 2.21.0 → 2.21.2

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.
Files changed (83) hide show
  1. package/es/assets/iconfont/iconfont.js +6 -6
  2. package/es/constants/index.js +2 -2
  3. package/es/control/baseControl/buttonControl.js +109 -144
  4. package/es/control/baseControl/control.js +212 -258
  5. package/es/control/baseControl/popperControl.js +67 -95
  6. package/es/control/baseControl/selectControl.js +132 -178
  7. package/es/control/exportImage.js +59 -142
  8. package/es/control/fullscreen.js +69 -100
  9. package/es/control/geoLocate.js +37 -84
  10. package/es/control/layerSwitch.js +111 -154
  11. package/es/control/logo.js +43 -69
  12. package/es/control/mapTheme.js +57 -98
  13. package/es/control/mouseLocation.js +37 -69
  14. package/es/control/scale.js +107 -135
  15. package/es/control/swipe.js +297 -393
  16. package/es/control/zoom.js +80 -112
  17. package/es/css/index.css +10 -7
  18. package/es/index.js +667 -1
  19. package/es/marker-layer.js +274 -326
  20. package/es/marker.d.ts +0 -2
  21. package/es/marker.js +394 -453
  22. package/es/popup/layerPopup.js +277 -321
  23. package/es/popup/popup.js +422 -482
  24. package/es/utils/anchor.js +6 -6
  25. package/es/utils/icon.js +4 -4
  26. package/es/utils/popper.js +180 -196
  27. package/es/utils/screenfull.js +29 -51
  28. package/lib/assets/iconfont/iconfont.js +6 -6
  29. package/lib/constants/index.d.ts +60 -0
  30. package/lib/constants/index.js +2 -2
  31. package/lib/control/baseControl/buttonControl.d.ts +60 -0
  32. package/lib/control/baseControl/buttonControl.js +110 -143
  33. package/lib/control/baseControl/control.d.ts +112 -0
  34. package/lib/control/baseControl/control.js +213 -257
  35. package/lib/control/baseControl/index.d.ts +4 -0
  36. package/lib/control/baseControl/index.js +5 -5
  37. package/lib/control/baseControl/popperControl.d.ts +28 -0
  38. package/lib/control/baseControl/popperControl.js +68 -94
  39. package/lib/control/baseControl/selectControl.d.ts +53 -0
  40. package/lib/control/baseControl/selectControl.js +133 -177
  41. package/lib/control/exportImage.d.ts +19 -0
  42. package/lib/control/exportImage.js +60 -141
  43. package/lib/control/fullscreen.d.ts +20 -0
  44. package/lib/control/fullscreen.js +70 -99
  45. package/lib/control/geoLocate.d.ts +17 -0
  46. package/lib/control/geoLocate.js +38 -83
  47. package/lib/control/layerSwitch.d.ts +27 -0
  48. package/lib/control/layerSwitch.js +112 -153
  49. package/lib/control/logo.d.ts +14 -0
  50. package/lib/control/logo.js +44 -69
  51. package/lib/control/mapTheme.d.ts +11 -0
  52. package/lib/control/mapTheme.js +58 -97
  53. package/lib/control/mouseLocation.d.ts +16 -0
  54. package/lib/control/mouseLocation.js +38 -68
  55. package/lib/control/scale.d.ts +35 -0
  56. package/lib/control/scale.js +108 -134
  57. package/lib/control/swipe.d.ts +66 -0
  58. package/lib/control/swipe.js +298 -392
  59. package/lib/control/zoom.d.ts +39 -0
  60. package/lib/control/zoom.js +81 -111
  61. package/lib/css/index.css +10 -7
  62. package/lib/index.d.ts +19 -0
  63. package/lib/index.js +683 -17
  64. package/lib/interface.d.ts +18 -0
  65. package/lib/marker-layer.d.ts +55 -0
  66. package/lib/marker-layer.js +276 -324
  67. package/lib/marker.d.ts +58 -0
  68. package/lib/marker.js +395 -452
  69. package/lib/popup/layerPopup.d.ts +99 -0
  70. package/lib/popup/layerPopup.js +278 -320
  71. package/lib/popup/popup.d.ts +142 -0
  72. package/lib/popup/popup.js +423 -481
  73. package/lib/utils/anchor.d.ts +22 -0
  74. package/lib/utils/anchor.js +6 -6
  75. package/lib/utils/icon.d.ts +1 -0
  76. package/lib/utils/icon.js +6 -5
  77. package/lib/utils/popper.d.ts +76 -0
  78. package/lib/utils/popper.js +184 -196
  79. package/lib/utils/screenfull.d.ts +2 -0
  80. package/lib/utils/screenfull.js +29 -52
  81. package/package.json +16 -20
  82. package/CHANGELOG.md +0 -325
  83. package/LICENSE.md +0 -21
@@ -0,0 +1,22 @@
1
+ export declare enum anchorType {
2
+ 'CENTER' = "center",
3
+ 'TOP' = "top",
4
+ 'TOP-LEFT' = "top-left",
5
+ 'TOP-RIGHT' = "top-right",
6
+ 'BOTTOM' = "bottom",
7
+ 'BOTTOM-LEFT' = "bottom-left",
8
+ 'LEFT' = "left",
9
+ 'RIGHT' = "right"
10
+ }
11
+ export declare const anchorTranslate: {
12
+ center: string;
13
+ top: string;
14
+ 'top-left': string;
15
+ 'top-right': string;
16
+ bottom: string;
17
+ 'bottom-left': string;
18
+ 'bottom-right': string;
19
+ left: string;
20
+ right: string;
21
+ };
22
+ export declare function applyAnchorClass(element: HTMLElement, anchor: string, prefix: string): void;
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.anchorType = exports.anchorTranslate = void 0;
7
7
  exports.applyAnchorClass = applyAnchorClass;
8
- var anchorType = exports.anchorType = /*#__PURE__*/function (anchorType) {
8
+ let anchorType = exports.anchorType = /*#__PURE__*/function (anchorType) {
9
9
  anchorType["CENTER"] = "center";
10
10
  anchorType["TOP"] = "top";
11
11
  anchorType["TOP-LEFT"] = "top-left";
@@ -16,7 +16,7 @@ var anchorType = exports.anchorType = /*#__PURE__*/function (anchorType) {
16
16
  anchorType["RIGHT"] = "right";
17
17
  return anchorType;
18
18
  }({});
19
- var anchorTranslate = exports.anchorTranslate = {
19
+ const anchorTranslate = exports.anchorTranslate = {
20
20
  center: 'translate(-50%,-50%)',
21
21
  top: 'translate(-50%,0)',
22
22
  'top-left': 'translate(0,0)',
@@ -28,11 +28,11 @@ var anchorTranslate = exports.anchorTranslate = {
28
28
  right: 'translate(-100%,-50%)'
29
29
  };
30
30
  function applyAnchorClass(element, anchor, prefix) {
31
- var classList = element.classList;
32
- for (var key in anchorTranslate) {
31
+ const classList = element.classList;
32
+ for (const key in anchorTranslate) {
33
33
  if (anchorTranslate.hasOwnProperty(key)) {
34
- classList.remove("l7-".concat(prefix, "-anchor-").concat(key));
34
+ classList.remove(`l7-${prefix}-anchor-${key}`);
35
35
  }
36
36
  }
37
- classList.add("l7-".concat(prefix, "-anchor-").concat(anchor));
37
+ classList.add(`l7-${prefix}-anchor-${anchor}`);
38
38
  }
@@ -0,0 +1 @@
1
+ export declare const createL7Icon: (className: string) => SVGSVGElement;
package/lib/utils/icon.js CHANGED
@@ -4,12 +4,13 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.createL7Icon = void 0;
7
- var createL7Icon = exports.createL7Icon = function createL7Icon(className) {
8
- var svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
7
+ const createL7Icon = className => {
8
+ const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
9
9
  svg.classList.add('l7-iconfont');
10
10
  svg.setAttribute('aria-hidden', 'true');
11
- var use = document.createElementNS('http://www.w3.org/2000/svg', 'use');
12
- use.setAttributeNS('http://www.w3.org/1999/xlink', 'href', "#".concat(className));
11
+ const use = document.createElementNS('http://www.w3.org/2000/svg', 'use');
12
+ use.setAttributeNS('http://www.w3.org/1999/xlink', 'href', `#${className}`);
13
13
  svg.appendChild(use);
14
14
  return svg;
15
- };
15
+ };
16
+ exports.createL7Icon = createL7Icon;
@@ -0,0 +1,76 @@
1
+ import { EventEmitter } from 'eventemitter3';
2
+ /**
3
+ * 气泡位置枚举
4
+ */
5
+ export type PopperPlacement = 'top-start' | 'top' | 'top-end' | 'left-start' | 'left' | 'left-end' | 'bottom-start' | 'bottom' | 'bottom-end' | 'right-start' | 'right' | 'right-end';
6
+ /**
7
+ * 气泡触发类型,当前支持 click 和 hover 两种类型
8
+ */
9
+ export type PopperTrigger = 'click' | 'hover';
10
+ /**
11
+ * 气泡内容类型
12
+ */
13
+ export type PopperContent = string | HTMLElement | null;
14
+ export interface IPopperOption {
15
+ placement: PopperPlacement;
16
+ trigger: PopperTrigger;
17
+ content?: PopperContent;
18
+ offset?: [number, number];
19
+ className?: string;
20
+ container: HTMLElement;
21
+ unique?: boolean;
22
+ }
23
+ export declare class Popper extends EventEmitter<'show' | 'hide'> {
24
+ protected get buttonRect(): DOMRect;
25
+ protected static conflictPopperList: Popper[];
26
+ popperDOM: HTMLElement;
27
+ contentDOM: HTMLElement;
28
+ /**
29
+ * 按钮实体
30
+ * @protected
31
+ */
32
+ protected button: HTMLElement;
33
+ /**
34
+ * Popper 配置
35
+ * @protected
36
+ */
37
+ protected option: IPopperOption;
38
+ /**
39
+ * 当前是否展示
40
+ * @protected
41
+ */
42
+ protected isShow: boolean;
43
+ /**
44
+ * 当前气泡展示的内容
45
+ * @protected
46
+ */
47
+ protected content: PopperContent;
48
+ /**
49
+ * 关闭气泡的定时器
50
+ * @protected
51
+ */
52
+ protected timeout: number | null;
53
+ constructor(button: HTMLElement, option: IPopperOption);
54
+ getPopperDOM(): HTMLElement;
55
+ getIsShow(): boolean;
56
+ getContent(): PopperContent;
57
+ setContent(content: PopperContent): void;
58
+ show: () => this;
59
+ hide: () => this;
60
+ /**
61
+ * 设置隐藏气泡的定时器
62
+ */
63
+ setHideTimeout: () => void;
64
+ /**
65
+ * 销毁隐藏气泡的定时器
66
+ */
67
+ clearHideTimeout: () => void;
68
+ init(): void;
69
+ destroy(): void;
70
+ resetPopperPosition(): void;
71
+ protected createPopper(): HTMLElement;
72
+ protected onBtnClick: () => void;
73
+ protected onPopperUnClick: (e: MouseEvent) => void;
74
+ protected onBtnMouseLeave: () => void;
75
+ protected onBtnMouseMove: () => void;
76
+ }
@@ -5,264 +5,252 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.Popper = void 0;
8
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
10
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
11
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
12
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
13
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
14
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
15
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
16
9
  var _l7Utils = require("@antv/l7-utils");
17
10
  var _eventemitter = require("eventemitter3");
18
- 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); }; }
19
- 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; } }
20
11
  /**
21
12
  * 气泡位置枚举
22
13
  */
14
+
23
15
  /**
24
16
  * 气泡触发类型,当前支持 click 和 hover 两种类型
25
17
  */
18
+
26
19
  /**
27
20
  * 气泡内容类型
28
21
  */
29
- var Popper = exports.Popper = /*#__PURE__*/function (_EventEmitter) {
30
- (0, _inherits2.default)(Popper, _EventEmitter);
31
- var _super = _createSuper(Popper);
32
- function Popper(button, option) {
33
- var _this;
34
- (0, _classCallCheck2.default)(this, Popper);
35
- _this = _super.call(this);
22
+
23
+ class Popper extends _eventemitter.EventEmitter {
24
+ get buttonRect() {
25
+ return this.button.getBoundingClientRect();
26
+ }
27
+ constructor(button, option) {
28
+ super();
29
+ // 气泡容器 DOM
30
+ (0, _defineProperty2.default)(this, "popperDOM", void 0);
31
+ // 气泡中展示的内容容器 DOM
32
+ (0, _defineProperty2.default)(this, "contentDOM", void 0);
33
+ /**
34
+ * 按钮实体
35
+ * @protected
36
+ */
37
+ (0, _defineProperty2.default)(this, "button", void 0);
38
+ /**
39
+ * Popper 配置
40
+ * @protected
41
+ */
42
+ (0, _defineProperty2.default)(this, "option", void 0);
36
43
  /**
37
44
  * 当前是否展示
38
45
  * @protected
39
46
  */
40
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "isShow", false);
47
+ (0, _defineProperty2.default)(this, "isShow", false);
48
+ /**
49
+ * 当前气泡展示的内容
50
+ * @protected
51
+ */
52
+ (0, _defineProperty2.default)(this, "content", void 0);
41
53
  /**
42
54
  * 关闭气泡的定时器
43
55
  * @protected
44
56
  */
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);
57
+ (0, _defineProperty2.default)(this, "timeout", null);
58
+ (0, _defineProperty2.default)(this, "show", () => {
59
+ if (this.isShow || !this.contentDOM.innerHTML) {
60
+ return this;
49
61
  }
50
- _this.resetPopperPosition();
51
- _l7Utils.DOM.removeClass(_this.popperDOM, 'l7-popper-hide');
52
- _this.isShow = true;
53
- if (_this.option.unique) {
54
- Popper.conflictPopperList.forEach(function (popper) {
55
- if (popper !== (0, _assertThisInitialized2.default)(_this) && popper.isShow) {
62
+ this.resetPopperPosition();
63
+ _l7Utils.DOM.removeClass(this.popperDOM, 'l7-popper-hide');
64
+ this.isShow = true;
65
+ if (this.option.unique) {
66
+ Popper.conflictPopperList.forEach(popper => {
67
+ if (popper !== this && popper.isShow) {
56
68
  popper.hide();
57
69
  }
58
70
  });
59
71
  }
60
- _this.emit('show');
61
- window.addEventListener('pointerdown', _this.onPopperUnClick);
62
- return (0, _assertThisInitialized2.default)(_this);
72
+ this.emit('show');
73
+ window.addEventListener('pointerdown', this.onPopperUnClick);
74
+ return this;
63
75
  });
64
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "hide", function () {
65
- if (!_this.isShow) {
66
- return (0, _assertThisInitialized2.default)(_this);
76
+ (0, _defineProperty2.default)(this, "hide", () => {
77
+ if (!this.isShow) {
78
+ return this;
67
79
  }
68
- _l7Utils.DOM.addClass(_this.popperDOM, 'l7-popper-hide');
69
- _this.isShow = false;
70
- _this.emit('hide');
71
- window.removeEventListener('pointerdown', _this.onPopperUnClick);
72
- return (0, _assertThisInitialized2.default)(_this);
80
+ _l7Utils.DOM.addClass(this.popperDOM, 'l7-popper-hide');
81
+ this.isShow = false;
82
+ this.emit('hide');
83
+ window.removeEventListener('pointerdown', this.onPopperUnClick);
84
+ return this;
73
85
  });
74
86
  /**
75
87
  * 设置隐藏气泡的定时器
76
88
  */
77
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "setHideTimeout", function () {
78
- if (_this.timeout) {
89
+ (0, _defineProperty2.default)(this, "setHideTimeout", () => {
90
+ if (this.timeout) {
79
91
  return;
80
92
  }
81
- _this.timeout = window.setTimeout(function () {
82
- if (!_this.isShow) {
93
+ this.timeout = window.setTimeout(() => {
94
+ if (!this.isShow) {
83
95
  return;
84
96
  }
85
- _this.hide();
86
- _this.timeout = null;
97
+ this.hide();
98
+ this.timeout = null;
87
99
  }, 300);
88
100
  });
89
101
  /**
90
102
  * 销毁隐藏气泡的定时器
91
103
  */
92
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "clearHideTimeout", function () {
93
- if (_this.timeout) {
94
- window.clearTimeout(_this.timeout);
95
- _this.timeout = null;
104
+ (0, _defineProperty2.default)(this, "clearHideTimeout", () => {
105
+ if (this.timeout) {
106
+ window.clearTimeout(this.timeout);
107
+ this.timeout = null;
96
108
  }
97
109
  });
98
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onBtnClick", function () {
99
- if (_this.isShow) {
100
- _this.hide();
110
+ (0, _defineProperty2.default)(this, "onBtnClick", () => {
111
+ if (this.isShow) {
112
+ this.hide();
101
113
  } else {
102
- _this.show();
114
+ this.show();
103
115
  }
104
116
  });
105
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onPopperUnClick", function (e) {
117
+ (0, _defineProperty2.default)(this, "onPopperUnClick", e => {
106
118
  if (!_l7Utils.DOM.findParentElement(e.target, ['.l7-button-control', '.l7-popper-content'])) {
107
- _this.hide();
119
+ this.hide();
108
120
  }
109
121
  });
110
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onBtnMouseLeave", function () {
111
- _this.setHideTimeout();
122
+ (0, _defineProperty2.default)(this, "onBtnMouseLeave", () => {
123
+ this.setHideTimeout();
112
124
  });
113
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onBtnMouseMove", function () {
114
- _this.clearHideTimeout();
115
- if (_this.isShow) {
125
+ (0, _defineProperty2.default)(this, "onBtnMouseMove", () => {
126
+ this.clearHideTimeout();
127
+ if (this.isShow) {
116
128
  return;
117
129
  }
118
- _this.show();
130
+ this.show();
119
131
  });
120
- _this.button = button;
121
- _this.option = option;
122
- _this.init();
132
+ this.button = button;
133
+ this.option = option;
134
+ this.init();
123
135
  if (option.unique) {
124
- Popper.conflictPopperList.push((0, _assertThisInitialized2.default)(_this));
136
+ Popper.conflictPopperList.push(this);
125
137
  }
126
- return _this;
127
138
  }
128
- (0, _createClass2.default)(Popper, [{
129
- key: "buttonRect",
130
- get: function get() {
131
- return this.button.getBoundingClientRect();
132
- }
133
- }, {
134
- key: "getPopperDOM",
135
- value: function getPopperDOM() {
136
- return this.popperDOM;
137
- }
138
- }, {
139
- key: "getIsShow",
140
- value: function getIsShow() {
141
- return this.isShow;
139
+ getPopperDOM() {
140
+ return this.popperDOM;
141
+ }
142
+ getIsShow() {
143
+ return this.isShow;
144
+ }
145
+ getContent() {
146
+ return this.content;
147
+ }
148
+ setContent(content) {
149
+ if (typeof content === 'string') {
150
+ this.contentDOM.innerHTML = content;
151
+ } else if (content instanceof HTMLElement) {
152
+ _l7Utils.DOM.clearChildren(this.contentDOM);
153
+ this.contentDOM.appendChild(content);
142
154
  }
143
- }, {
144
- key: "getContent",
145
- value: function getContent() {
146
- return this.content;
155
+ this.content = content;
156
+ }
157
+ init() {
158
+ const {
159
+ trigger
160
+ } = this.option;
161
+ this.popperDOM = this.createPopper();
162
+ if (trigger === 'click') {
163
+ this.button.addEventListener('click', this.onBtnClick);
164
+ } else {
165
+ this.button.addEventListener('mousemove', this.onBtnMouseMove);
166
+ this.button.addEventListener('mouseleave', this.onBtnMouseLeave);
167
+ this.popperDOM.addEventListener('mousemove', this.onBtnMouseMove);
168
+ this.popperDOM.addEventListener('mouseleave', this.onBtnMouseLeave);
147
169
  }
148
- }, {
149
- key: "setContent",
150
- value: function setContent(content) {
151
- if (typeof content === 'string') {
152
- this.contentDOM.innerHTML = content;
153
- } else if (content instanceof HTMLElement) {
154
- _l7Utils.DOM.clearChildren(this.contentDOM);
155
- this.contentDOM.appendChild(content);
170
+ }
171
+ destroy() {
172
+ this.button.removeEventListener('click', this.onBtnClick);
173
+ this.button.removeEventListener('mousemove', this.onBtnMouseMove);
174
+ this.button.removeEventListener('mousemove', this.onBtnMouseLeave);
175
+ this.popperDOM.removeEventListener('mousemove', this.onBtnMouseMove);
176
+ this.popperDOM.removeEventListener('mouseleave', this.onBtnMouseLeave);
177
+ _l7Utils.DOM.remove(this.popperDOM);
178
+ }
179
+ resetPopperPosition() {
180
+ const popperStyleObj = {};
181
+ const {
182
+ container,
183
+ offset = [0, 0],
184
+ placement
185
+ } = this.option;
186
+ const [offsetX, offsetY] = offset;
187
+ const buttonRect = this.button.getBoundingClientRect();
188
+ const containerRect = container.getBoundingClientRect();
189
+ const {
190
+ left,
191
+ right,
192
+ top,
193
+ bottom
194
+ } = _l7Utils.DOM.getDiffRect(buttonRect, containerRect);
195
+ let isTransformX = false;
196
+ let isTransformY = false;
197
+ if (/^(left|right)/.test(placement)) {
198
+ if (placement.includes('left')) {
199
+ popperStyleObj.right = `${buttonRect.width + right}px`;
200
+ } else if (placement.includes('right')) {
201
+ popperStyleObj.left = `${buttonRect.width + left}px`;
156
202
  }
157
- this.content = content;
158
- }
159
- }, {
160
- key: "init",
161
- value: function init() {
162
- var trigger = this.option.trigger;
163
- this.popperDOM = this.createPopper();
164
- if (trigger === 'click') {
165
- this.button.addEventListener('click', this.onBtnClick);
203
+ if (placement.includes('start')) {
204
+ popperStyleObj.top = `${top}px`;
205
+ } else if (placement.includes('end')) {
206
+ popperStyleObj.bottom = `${bottom}px`;
166
207
  } else {
167
- this.button.addEventListener('mousemove', this.onBtnMouseMove);
168
- this.button.addEventListener('mouseleave', this.onBtnMouseLeave);
169
- this.popperDOM.addEventListener('mousemove', this.onBtnMouseMove);
170
- this.popperDOM.addEventListener('mouseleave', this.onBtnMouseLeave);
208
+ popperStyleObj.top = `${top + buttonRect.height / 2}px`;
209
+ isTransformY = true;
210
+ popperStyleObj.transform = `translate(${offsetX}px, calc(${offsetY}px - 50%))`;
171
211
  }
172
- }
173
- }, {
174
- key: "destroy",
175
- value: function destroy() {
176
- this.button.removeEventListener('click', this.onBtnClick);
177
- this.button.removeEventListener('mousemove', this.onBtnMouseMove);
178
- this.button.removeEventListener('mousemove', this.onBtnMouseLeave);
179
- this.popperDOM.removeEventListener('mousemove', this.onBtnMouseMove);
180
- this.popperDOM.removeEventListener('mouseleave', this.onBtnMouseLeave);
181
- _l7Utils.DOM.remove(this.popperDOM);
182
- }
183
- }, {
184
- key: "resetPopperPosition",
185
- value: function resetPopperPosition() {
186
- var popperStyleObj = {};
187
- var _this$option = this.option,
188
- container = _this$option.container,
189
- _this$option$offset = _this$option.offset,
190
- offset = _this$option$offset === void 0 ? [0, 0] : _this$option$offset,
191
- placement = _this$option.placement;
192
- var _offset = (0, _slicedToArray2.default)(offset, 2),
193
- offsetX = _offset[0],
194
- offsetY = _offset[1];
195
- var buttonRect = this.button.getBoundingClientRect();
196
- var containerRect = container.getBoundingClientRect();
197
- var _DOM$getDiffRect = _l7Utils.DOM.getDiffRect(buttonRect, containerRect),
198
- left = _DOM$getDiffRect.left,
199
- right = _DOM$getDiffRect.right,
200
- top = _DOM$getDiffRect.top,
201
- bottom = _DOM$getDiffRect.bottom;
202
- var isTransformX = false;
203
- var isTransformY = false;
204
- if (/^(left|right)/.test(placement)) {
205
- if (placement.includes('left')) {
206
- popperStyleObj.right = "".concat(buttonRect.width + right, "px");
207
- } else if (placement.includes('right')) {
208
- popperStyleObj.left = "".concat(buttonRect.width + left, "px");
209
- }
210
- if (placement.includes('start')) {
211
- popperStyleObj.top = "".concat(top, "px");
212
- } else if (placement.includes('end')) {
213
- popperStyleObj.bottom = "".concat(bottom, "px");
214
- } else {
215
- popperStyleObj.top = "".concat(top + buttonRect.height / 2, "px");
216
- isTransformY = true;
217
- popperStyleObj.transform = "translate(".concat(offsetX, "px, calc(").concat(offsetY, "px - 50%))");
218
- }
219
- } else if (/^(top|bottom)/.test(placement)) {
220
- if (placement.includes('top')) {
221
- popperStyleObj.bottom = "".concat(buttonRect.height + bottom, "px");
222
- } else if (placement.includes('bottom')) {
223
- popperStyleObj.top = "".concat(buttonRect.height + top, "px");
224
- }
225
- if (placement.includes('start')) {
226
- popperStyleObj.left = "".concat(left, "px");
227
- } else if (placement.includes('end')) {
228
- popperStyleObj.right = "".concat(right, "px");
229
- } else {
230
- popperStyleObj.left = "".concat(left + buttonRect.width / 2, "px");
231
- isTransformX = true;
232
- popperStyleObj.transform = "translate(calc(".concat(offsetX, "px - 50%), ").concat(offsetY, "px)");
233
- }
212
+ } else if (/^(top|bottom)/.test(placement)) {
213
+ if (placement.includes('top')) {
214
+ popperStyleObj.bottom = `${buttonRect.height + bottom}px`;
215
+ } else if (placement.includes('bottom')) {
216
+ popperStyleObj.top = `${buttonRect.height + top}px`;
234
217
  }
235
- popperStyleObj.transform = "translate(calc(".concat(offsetX, "px - ").concat(isTransformX ? '50%' : '0%', "), calc(").concat(offsetY, "px - ").concat(isTransformY ? '50%' : '0%', ")");
236
- var posList = placement.split('-');
237
- if (posList.length) {
238
- _l7Utils.DOM.addClass(this.popperDOM, posList.map(function (pos) {
239
- return "l7-popper-".concat(pos);
240
- }).join(' '));
218
+ if (placement.includes('start')) {
219
+ popperStyleObj.left = `${left}px`;
220
+ } else if (placement.includes('end')) {
221
+ popperStyleObj.right = `${right}px`;
222
+ } else {
223
+ popperStyleObj.left = `${left + buttonRect.width / 2}px`;
224
+ isTransformX = true;
225
+ popperStyleObj.transform = `translate(calc(${offsetX}px - 50%), ${offsetY}px)`;
241
226
  }
242
- _l7Utils.DOM.addStyle(this.popperDOM, _l7Utils.DOM.css2Style(popperStyleObj));
243
227
  }
244
- }, {
245
- key: "createPopper",
246
- value: function createPopper() {
247
- var _this$option2 = this.option,
248
- container = _this$option2.container,
249
- _this$option2$classNa = _this$option2.className,
250
- className = _this$option2$classNa === void 0 ? '' : _this$option2$classNa,
251
- content = _this$option2.content;
252
- var popper = _l7Utils.DOM.create('div', "l7-popper l7-popper-hide ".concat(className));
253
- var popperContent = _l7Utils.DOM.create('div', 'l7-popper-content');
254
- var popperArrow = _l7Utils.DOM.create('div', 'l7-popper-arrow');
255
- popper.appendChild(popperContent);
256
- popper.appendChild(popperArrow);
257
- container.appendChild(popper);
258
- this.popperDOM = popper;
259
- this.contentDOM = popperContent;
260
- if (content) {
261
- this.setContent(content);
262
- }
263
- return popper;
228
+ popperStyleObj.transform = `translate(calc(${offsetX}px - ${isTransformX ? '50%' : '0%'}), calc(${offsetY}px - ${isTransformY ? '50%' : '0%'})`;
229
+ const posList = placement.split('-');
230
+ if (posList.length) {
231
+ _l7Utils.DOM.addClass(this.popperDOM, posList.map(pos => `l7-popper-${pos}`).join(' '));
232
+ }
233
+ _l7Utils.DOM.addStyle(this.popperDOM, _l7Utils.DOM.css2Style(popperStyleObj));
234
+ }
235
+ createPopper() {
236
+ const {
237
+ container,
238
+ className = '',
239
+ content
240
+ } = this.option;
241
+ const popper = _l7Utils.DOM.create('div', `l7-popper l7-popper-hide ${className}`);
242
+ const popperContent = _l7Utils.DOM.create('div', 'l7-popper-content');
243
+ const popperArrow = _l7Utils.DOM.create('div', 'l7-popper-arrow');
244
+ popper.appendChild(popperContent);
245
+ popper.appendChild(popperArrow);
246
+ container.appendChild(popper);
247
+ this.popperDOM = popper;
248
+ this.contentDOM = popperContent;
249
+ if (content) {
250
+ this.setContent(content);
264
251
  }
265
- }]);
266
- return Popper;
267
- }(_eventemitter.EventEmitter);
252
+ return popper;
253
+ }
254
+ }
255
+ exports.Popper = Popper;
268
256
  (0, _defineProperty2.default)(Popper, "conflictPopperList", []);
@@ -0,0 +1,2 @@
1
+ declare let screenfull: any;
2
+ export default screenfull;