@antv/l7-component 2.25.5 → 2.25.7
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/package.json +5 -5
- package/es/assets/iconfont/iconfont.d.ts +0 -21
- package/es/assets/iconfont/iconfont.js +0 -61
- package/es/constants/index.d.ts +0 -60
- package/es/constants/index.js +0 -60
- package/es/control/baseControl/buttonControl.d.ts +0 -60
- package/es/control/baseControl/buttonControl.js +0 -142
- package/es/control/baseControl/control.d.ts +0 -112
- package/es/control/baseControl/control.js +0 -256
- package/es/control/baseControl/index.d.ts +0 -4
- package/es/control/baseControl/index.js +0 -4
- package/es/control/baseControl/popperControl.d.ts +0 -28
- package/es/control/baseControl/popperControl.js +0 -92
- package/es/control/baseControl/selectControl.d.ts +0 -53
- package/es/control/baseControl/selectControl.js +0 -173
- package/es/control/exportImage.d.ts +0 -19
- package/es/control/exportImage.js +0 -73
- package/es/control/fullscreen.d.ts +0 -20
- package/es/control/fullscreen.js +0 -88
- package/es/control/geoLocate.d.ts +0 -17
- package/es/control/geoLocate.js +0 -60
- package/es/control/layerSwitch.d.ts +0 -27
- package/es/control/layerSwitch.js +0 -155
- package/es/control/logo.d.ts +0 -14
- package/es/control/logo.js +0 -49
- package/es/control/mapTheme.d.ts +0 -11
- package/es/control/mapTheme.js +0 -69
- package/es/control/mouseLocation.d.ts +0 -16
- package/es/control/mouseLocation.js +0 -52
- package/es/control/scale.d.ts +0 -35
- package/es/control/scale.js +0 -121
- package/es/control/swipe.d.ts +0 -66
- package/es/control/swipe.js +0 -392
- package/es/control/zoom.d.ts +0 -39
- package/es/control/zoom.js +0 -100
- package/es/css/button.less +0 -77
- package/es/css/control.less +0 -82
- package/es/css/index.css +0 -653
- package/es/css/index.less +0 -13
- package/es/css/l7.less +0 -69
- package/es/css/layerPopup.less +0 -9
- package/es/css/logo.less +0 -21
- package/es/css/mouseLocation.less +0 -9
- package/es/css/popper.less +0 -74
- package/es/css/popup.less +0 -176
- package/es/css/scale.less +0 -37
- package/es/css/select.less +0 -96
- package/es/css/swipe.less +0 -80
- package/es/css/variables.less +0 -29
- package/es/css/zoom.less +0 -34
- package/es/images/layers.png +0 -0
- package/es/images/layers.svg +0 -1
- package/es/images/logo.png +0 -0
- package/es/images/quanping.svg +0 -12
- package/es/index.d.ts +0 -19
- package/es/index.js +0 -708
- package/es/interface.d.ts +0 -29
- package/es/interface.js +0 -1
- package/es/marker-layer.d.ts +0 -46
- package/es/marker-layer.js +0 -509
- package/es/marker.d.ts +0 -66
- package/es/marker.js +0 -495
- package/es/popup/layerPopup.d.ts +0 -105
- package/es/popup/layerPopup.js +0 -341
- package/es/popup/popup.d.ts +0 -147
- package/es/popup/popup.js +0 -587
- package/es/utils/anchor.d.ts +0 -22
- package/es/utils/anchor.js +0 -31
- package/es/utils/eventManager.d.ts +0 -42
- package/es/utils/eventManager.js +0 -84
- package/es/utils/icon.d.ts +0 -1
- package/es/utils/icon.js +0 -12
- package/es/utils/popper.d.ts +0 -76
- package/es/utils/popper.js +0 -257
- package/es/utils/screenfull.d.ts +0 -2
- package/es/utils/screenfull.js +0 -106
- package/lib/assets/iconfont/iconfont.d.ts +0 -21
- package/lib/assets/iconfont/iconfont.js +0 -68
- package/lib/constants/index.d.ts +0 -60
- package/lib/constants/index.js +0 -66
- package/lib/control/baseControl/buttonControl.d.ts +0 -60
- package/lib/control/baseControl/buttonControl.js +0 -149
- package/lib/control/baseControl/control.d.ts +0 -112
- package/lib/control/baseControl/control.js +0 -269
- package/lib/control/baseControl/index.d.ts +0 -4
- package/lib/control/baseControl/index.js +0 -39
- package/lib/control/baseControl/popperControl.d.ts +0 -28
- package/lib/control/baseControl/popperControl.js +0 -99
- package/lib/control/baseControl/selectControl.d.ts +0 -53
- package/lib/control/baseControl/selectControl.js +0 -180
- package/lib/control/exportImage.d.ts +0 -19
- package/lib/control/exportImage.js +0 -80
- package/lib/control/fullscreen.d.ts +0 -20
- package/lib/control/fullscreen.js +0 -95
- package/lib/control/geoLocate.d.ts +0 -17
- package/lib/control/geoLocate.js +0 -67
- package/lib/control/layerSwitch.d.ts +0 -27
- package/lib/control/layerSwitch.js +0 -162
- package/lib/control/logo.d.ts +0 -14
- package/lib/control/logo.js +0 -55
- package/lib/control/mapTheme.d.ts +0 -11
- package/lib/control/mapTheme.js +0 -76
- package/lib/control/mouseLocation.d.ts +0 -16
- package/lib/control/mouseLocation.js +0 -59
- package/lib/control/scale.d.ts +0 -35
- package/lib/control/scale.js +0 -128
- package/lib/control/swipe.d.ts +0 -66
- package/lib/control/swipe.js +0 -399
- package/lib/control/zoom.d.ts +0 -39
- package/lib/control/zoom.js +0 -107
- package/lib/css/button.less +0 -77
- package/lib/css/control.less +0 -82
- package/lib/css/index.css +0 -653
- package/lib/css/index.less +0 -13
- package/lib/css/l7.less +0 -69
- package/lib/css/layerPopup.less +0 -9
- package/lib/css/logo.less +0 -21
- package/lib/css/mouseLocation.less +0 -9
- package/lib/css/popper.less +0 -74
- package/lib/css/popup.less +0 -176
- package/lib/css/scale.less +0 -37
- package/lib/css/select.less +0 -96
- package/lib/css/swipe.less +0 -80
- package/lib/css/variables.less +0 -29
- package/lib/css/zoom.less +0 -34
- package/lib/images/layers.png +0 -0
- package/lib/images/layers.svg +0 -1
- package/lib/images/logo.png +0 -0
- package/lib/images/quanping.svg +0 -12
- package/lib/index.d.ts +0 -19
- package/lib/index.js +0 -835
- package/lib/interface.d.ts +0 -29
- package/lib/interface.js +0 -5
- package/lib/marker-layer.d.ts +0 -46
- package/lib/marker-layer.js +0 -518
- package/lib/marker.d.ts +0 -66
- package/lib/marker.js +0 -502
- package/lib/popup/layerPopup.d.ts +0 -105
- package/lib/popup/layerPopup.js +0 -348
- package/lib/popup/popup.d.ts +0 -147
- package/lib/popup/popup.js +0 -594
- package/lib/utils/anchor.d.ts +0 -22
- package/lib/utils/anchor.js +0 -38
- package/lib/utils/eventManager.d.ts +0 -42
- package/lib/utils/eventManager.js +0 -92
- package/lib/utils/icon.d.ts +0 -1
- package/lib/utils/icon.js +0 -19
- package/lib/utils/popper.d.ts +0 -76
- package/lib/utils/popper.js +0 -264
- package/lib/utils/screenfull.d.ts +0 -2
- package/lib/utils/screenfull.js +0 -112
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = exports.EventManager = void 0;
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
/**
|
|
10
|
-
* 事件管理器,用于统一管理事件绑定和解绑
|
|
11
|
-
* 解决组件销毁时事件未正确清理导致的内存泄漏问题
|
|
12
|
-
*/
|
|
13
|
-
class EventManager {
|
|
14
|
-
constructor() {
|
|
15
|
-
(0, _defineProperty2.default)(this, "bindings", []);
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* 绑定事件
|
|
19
|
-
* @param target 事件目标对象
|
|
20
|
-
* @param event 事件名称
|
|
21
|
-
* @param handler 事件处理函数
|
|
22
|
-
*/
|
|
23
|
-
on(target, event, handler) {
|
|
24
|
-
this.bindings.push({
|
|
25
|
-
target,
|
|
26
|
-
event,
|
|
27
|
-
handler
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
// 根据目标类型选择绑定方式
|
|
31
|
-
if (this.isMapService(target)) {
|
|
32
|
-
target.on(event, handler);
|
|
33
|
-
} else {
|
|
34
|
-
target.addEventListener(event, handler);
|
|
35
|
-
}
|
|
36
|
-
return this;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* 解绑指定事件
|
|
41
|
-
* @param target 事件目标对象
|
|
42
|
-
* @param event 事件名称
|
|
43
|
-
* @param handler 事件处理函数
|
|
44
|
-
*/
|
|
45
|
-
|
|
46
|
-
off(target, event, handler) {
|
|
47
|
-
const index = this.bindings.findIndex(b => b.target === target && b.event === event && b.handler === handler);
|
|
48
|
-
if (index > -1) {
|
|
49
|
-
this.bindings.splice(index, 1);
|
|
50
|
-
if (this.isMapService(target)) {
|
|
51
|
-
target.off(event, handler);
|
|
52
|
-
} else {
|
|
53
|
-
target.removeEventListener(event, handler);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return this;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* 清除所有绑定的事件
|
|
61
|
-
*/
|
|
62
|
-
clear() {
|
|
63
|
-
this.bindings.forEach(({
|
|
64
|
-
target,
|
|
65
|
-
event,
|
|
66
|
-
handler
|
|
67
|
-
}) => {
|
|
68
|
-
if (this.isMapService(target)) {
|
|
69
|
-
target.off(event, handler);
|
|
70
|
-
} else {
|
|
71
|
-
target.removeEventListener(event, handler);
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
this.bindings = [];
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* 获取当前绑定的事件数量
|
|
79
|
-
*/
|
|
80
|
-
size() {
|
|
81
|
-
return this.bindings.length;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* 判断目标是否为 MapService
|
|
86
|
-
*/
|
|
87
|
-
isMapService(target) {
|
|
88
|
-
return target && typeof target.on === 'function' && typeof target.off === 'function';
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
exports.EventManager = EventManager;
|
|
92
|
-
var _default = exports.default = EventManager;
|
package/lib/utils/icon.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const createL7Icon: (className: string) => SVGSVGElement;
|
package/lib/utils/icon.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createL7Icon = void 0;
|
|
7
|
-
var _iconfont = require("../assets/iconfont/iconfont");
|
|
8
|
-
const createL7Icon = className => {
|
|
9
|
-
// Ensure SVG sprite is loaded before creating the icon reference
|
|
10
|
-
(0, _iconfont.ensureSvgSprite)();
|
|
11
|
-
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
12
|
-
svg.classList.add('l7-iconfont');
|
|
13
|
-
svg.setAttribute('aria-hidden', 'true');
|
|
14
|
-
const use = document.createElementNS('http://www.w3.org/2000/svg', 'use');
|
|
15
|
-
use.setAttributeNS('http://www.w3.org/1999/xlink', 'href', `#${className}`);
|
|
16
|
-
svg.appendChild(use);
|
|
17
|
-
return svg;
|
|
18
|
-
};
|
|
19
|
-
exports.createL7Icon = createL7Icon;
|
package/lib/utils/popper.d.ts
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
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
|
-
}
|
package/lib/utils/popper.js
DELETED
|
@@ -1,264 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.Popper = void 0;
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
var _l7Utils = require("@antv/l7-utils");
|
|
10
|
-
var _eventemitter = require("eventemitter3");
|
|
11
|
-
/**
|
|
12
|
-
* 气泡位置枚举
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* 气泡触发类型,当前支持 click 和 hover 两种类型
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* 气泡内容类型
|
|
21
|
-
*/
|
|
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);
|
|
43
|
-
/**
|
|
44
|
-
* 当前是否展示
|
|
45
|
-
* @protected
|
|
46
|
-
*/
|
|
47
|
-
(0, _defineProperty2.default)(this, "isShow", false);
|
|
48
|
-
/**
|
|
49
|
-
* 当前气泡展示的内容
|
|
50
|
-
* @protected
|
|
51
|
-
*/
|
|
52
|
-
(0, _defineProperty2.default)(this, "content", void 0);
|
|
53
|
-
/**
|
|
54
|
-
* 关闭气泡的定时器
|
|
55
|
-
* @protected
|
|
56
|
-
*/
|
|
57
|
-
(0, _defineProperty2.default)(this, "timeout", null);
|
|
58
|
-
(0, _defineProperty2.default)(this, "show", () => {
|
|
59
|
-
if (this.isShow || !this.contentDOM.innerHTML) {
|
|
60
|
-
return this;
|
|
61
|
-
}
|
|
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) {
|
|
68
|
-
popper.hide();
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
this.emit('show');
|
|
73
|
-
window.addEventListener('pointerdown', this.onPopperUnClick);
|
|
74
|
-
return this;
|
|
75
|
-
});
|
|
76
|
-
(0, _defineProperty2.default)(this, "hide", () => {
|
|
77
|
-
if (!this.isShow) {
|
|
78
|
-
return this;
|
|
79
|
-
}
|
|
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;
|
|
85
|
-
});
|
|
86
|
-
/**
|
|
87
|
-
* 设置隐藏气泡的定时器
|
|
88
|
-
*/
|
|
89
|
-
(0, _defineProperty2.default)(this, "setHideTimeout", () => {
|
|
90
|
-
if (this.timeout) {
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
this.timeout = window.setTimeout(() => {
|
|
94
|
-
if (!this.isShow) {
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
this.hide();
|
|
98
|
-
this.timeout = null;
|
|
99
|
-
}, 300);
|
|
100
|
-
});
|
|
101
|
-
/**
|
|
102
|
-
* 销毁隐藏气泡的定时器
|
|
103
|
-
*/
|
|
104
|
-
(0, _defineProperty2.default)(this, "clearHideTimeout", () => {
|
|
105
|
-
if (this.timeout) {
|
|
106
|
-
window.clearTimeout(this.timeout);
|
|
107
|
-
this.timeout = null;
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
(0, _defineProperty2.default)(this, "onBtnClick", () => {
|
|
111
|
-
if (this.isShow) {
|
|
112
|
-
this.hide();
|
|
113
|
-
} else {
|
|
114
|
-
this.show();
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
(0, _defineProperty2.default)(this, "onPopperUnClick", e => {
|
|
118
|
-
if (!_l7Utils.DOM.findParentElement(e.target, ['.l7-button-control', '.l7-popper-content'])) {
|
|
119
|
-
this.hide();
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
(0, _defineProperty2.default)(this, "onBtnMouseLeave", () => {
|
|
123
|
-
this.setHideTimeout();
|
|
124
|
-
});
|
|
125
|
-
(0, _defineProperty2.default)(this, "onBtnMouseMove", () => {
|
|
126
|
-
this.clearHideTimeout();
|
|
127
|
-
if (this.isShow) {
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
this.show();
|
|
131
|
-
});
|
|
132
|
-
this.button = button;
|
|
133
|
-
this.option = option;
|
|
134
|
-
this.init();
|
|
135
|
-
if (option.unique) {
|
|
136
|
-
Popper.conflictPopperList.push(this);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
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);
|
|
154
|
-
}
|
|
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);
|
|
169
|
-
}
|
|
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
|
-
// 从 conflictPopperList 中移除当前实例,防止内存泄漏
|
|
180
|
-
if (this.option.unique) {
|
|
181
|
-
const index = Popper.conflictPopperList.indexOf(this);
|
|
182
|
-
if (index > -1) {
|
|
183
|
-
Popper.conflictPopperList.splice(index, 1);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
resetPopperPosition() {
|
|
188
|
-
const popperStyleObj = {};
|
|
189
|
-
const {
|
|
190
|
-
container,
|
|
191
|
-
offset = [0, 0],
|
|
192
|
-
placement
|
|
193
|
-
} = this.option;
|
|
194
|
-
const [offsetX, offsetY] = offset;
|
|
195
|
-
const buttonRect = this.button.getBoundingClientRect();
|
|
196
|
-
const containerRect = container.getBoundingClientRect();
|
|
197
|
-
const {
|
|
198
|
-
left,
|
|
199
|
-
right,
|
|
200
|
-
top,
|
|
201
|
-
bottom
|
|
202
|
-
} = _l7Utils.DOM.getDiffRect(buttonRect, containerRect);
|
|
203
|
-
let isTransformX = false;
|
|
204
|
-
let isTransformY = false;
|
|
205
|
-
if (/^(left|right)/.test(placement)) {
|
|
206
|
-
if (placement.includes('left')) {
|
|
207
|
-
popperStyleObj.right = `${buttonRect.width + right}px`;
|
|
208
|
-
} else if (placement.includes('right')) {
|
|
209
|
-
popperStyleObj.left = `${buttonRect.width + left}px`;
|
|
210
|
-
}
|
|
211
|
-
if (placement.includes('start')) {
|
|
212
|
-
popperStyleObj.top = `${top}px`;
|
|
213
|
-
} else if (placement.includes('end')) {
|
|
214
|
-
popperStyleObj.bottom = `${bottom}px`;
|
|
215
|
-
} else {
|
|
216
|
-
popperStyleObj.top = `${top + buttonRect.height / 2}px`;
|
|
217
|
-
isTransformY = true;
|
|
218
|
-
popperStyleObj.transform = `translate(${offsetX}px, calc(${offsetY}px - 50%))`;
|
|
219
|
-
}
|
|
220
|
-
} else if (/^(top|bottom)/.test(placement)) {
|
|
221
|
-
if (placement.includes('top')) {
|
|
222
|
-
popperStyleObj.bottom = `${buttonRect.height + bottom}px`;
|
|
223
|
-
} else if (placement.includes('bottom')) {
|
|
224
|
-
popperStyleObj.top = `${buttonRect.height + top}px`;
|
|
225
|
-
}
|
|
226
|
-
if (placement.includes('start')) {
|
|
227
|
-
popperStyleObj.left = `${left}px`;
|
|
228
|
-
} else if (placement.includes('end')) {
|
|
229
|
-
popperStyleObj.right = `${right}px`;
|
|
230
|
-
} else {
|
|
231
|
-
popperStyleObj.left = `${left + buttonRect.width / 2}px`;
|
|
232
|
-
isTransformX = true;
|
|
233
|
-
popperStyleObj.transform = `translate(calc(${offsetX}px - 50%), ${offsetY}px)`;
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
popperStyleObj.transform = `translate(calc(${offsetX}px - ${isTransformX ? '50%' : '0%'}), calc(${offsetY}px - ${isTransformY ? '50%' : '0%'})`;
|
|
237
|
-
const posList = placement.split('-');
|
|
238
|
-
if (posList.length) {
|
|
239
|
-
_l7Utils.DOM.addClass(this.popperDOM, posList.map(pos => `l7-popper-${pos}`).join(' '));
|
|
240
|
-
}
|
|
241
|
-
_l7Utils.DOM.addStyle(this.popperDOM, _l7Utils.DOM.css2Style(popperStyleObj));
|
|
242
|
-
}
|
|
243
|
-
createPopper() {
|
|
244
|
-
const {
|
|
245
|
-
container,
|
|
246
|
-
className = '',
|
|
247
|
-
content
|
|
248
|
-
} = this.option;
|
|
249
|
-
const popper = _l7Utils.DOM.create('div', `l7-popper l7-popper-hide ${className}`);
|
|
250
|
-
const popperContent = _l7Utils.DOM.create('div', 'l7-popper-content');
|
|
251
|
-
const popperArrow = _l7Utils.DOM.create('div', 'l7-popper-arrow');
|
|
252
|
-
popper.appendChild(popperContent);
|
|
253
|
-
popper.appendChild(popperArrow);
|
|
254
|
-
container.appendChild(popper);
|
|
255
|
-
this.popperDOM = popper;
|
|
256
|
-
this.contentDOM = popperContent;
|
|
257
|
-
if (content) {
|
|
258
|
-
this.setContent(content);
|
|
259
|
-
}
|
|
260
|
-
return popper;
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
exports.Popper = Popper;
|
|
264
|
-
(0, _defineProperty2.default)(Popper, "conflictPopperList", []);
|
package/lib/utils/screenfull.js
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
// @ts-nocheck
|
|
8
|
-
|
|
9
|
-
const methodMap = [['requestFullscreen', 'exitFullscreen', 'fullscreenElement', 'fullscreenEnabled', 'fullscreenchange', 'fullscreenerror'],
|
|
10
|
-
// New WebKit
|
|
11
|
-
['webkitRequestFullscreen', 'webkitExitFullscreen', 'webkitFullscreenElement', 'webkitFullscreenEnabled', 'webkitfullscreenchange', 'webkitfullscreenerror'],
|
|
12
|
-
// Old WebKit
|
|
13
|
-
['webkitRequestFullScreen', 'webkitCancelFullScreen', 'webkitCurrentFullScreenElement', 'webkitCancelFullScreen', 'webkitfullscreenchange', 'webkitfullscreenerror'], ['mozRequestFullScreen', 'mozCancelFullScreen', 'mozFullScreenElement', 'mozFullScreenEnabled', 'mozfullscreenchange', 'mozfullscreenerror'], ['msRequestFullscreen', 'msExitFullscreen', 'msFullscreenElement', 'msFullscreenEnabled', 'MSFullscreenChange', 'MSFullscreenError']];
|
|
14
|
-
const nativeAPI = (() => {
|
|
15
|
-
if (typeof document === 'undefined') {
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
const unprefixedMethods = methodMap[0];
|
|
19
|
-
const returnValue = {};
|
|
20
|
-
for (const methodList of methodMap) {
|
|
21
|
-
const exitFullscreenMethod = methodList === null || methodList === void 0 ? void 0 : methodList[1];
|
|
22
|
-
if (exitFullscreenMethod in document) {
|
|
23
|
-
for (const [index, method] of methodList.entries()) {
|
|
24
|
-
returnValue[unprefixedMethods[index]] = method;
|
|
25
|
-
}
|
|
26
|
-
return returnValue;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return false;
|
|
30
|
-
})();
|
|
31
|
-
const eventNameMap = {
|
|
32
|
-
change: nativeAPI.fullscreenchange,
|
|
33
|
-
error: nativeAPI.fullscreenerror
|
|
34
|
-
};
|
|
35
|
-
let screenfull = {
|
|
36
|
-
// eslint-disable-next-line default-param-last
|
|
37
|
-
request(element = document.documentElement, options) {
|
|
38
|
-
return new Promise((resolve, reject) => {
|
|
39
|
-
const onFullScreenEntered = () => {
|
|
40
|
-
screenfull.off('change', onFullScreenEntered);
|
|
41
|
-
resolve();
|
|
42
|
-
};
|
|
43
|
-
screenfull.on('change', onFullScreenEntered);
|
|
44
|
-
const returnPromise = element[nativeAPI.requestFullscreen](options);
|
|
45
|
-
if (returnPromise instanceof Promise) {
|
|
46
|
-
returnPromise.then(onFullScreenEntered).catch(reject);
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
},
|
|
50
|
-
exit() {
|
|
51
|
-
return new Promise((resolve, reject) => {
|
|
52
|
-
if (!screenfull.isFullscreen) {
|
|
53
|
-
resolve();
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
const onFullScreenExit = () => {
|
|
57
|
-
screenfull.off('change', onFullScreenExit);
|
|
58
|
-
resolve();
|
|
59
|
-
};
|
|
60
|
-
screenfull.on('change', onFullScreenExit);
|
|
61
|
-
const returnPromise = document[nativeAPI.exitFullscreen]();
|
|
62
|
-
if (returnPromise instanceof Promise) {
|
|
63
|
-
returnPromise.then(onFullScreenExit).catch(reject);
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
},
|
|
67
|
-
toggle(element, options) {
|
|
68
|
-
return screenfull.isFullscreen ? screenfull.exit() : screenfull.request(element, options);
|
|
69
|
-
},
|
|
70
|
-
onchange(callback) {
|
|
71
|
-
screenfull.on('change', callback);
|
|
72
|
-
},
|
|
73
|
-
onerror(callback) {
|
|
74
|
-
screenfull.on('error', callback);
|
|
75
|
-
},
|
|
76
|
-
on(event, callback) {
|
|
77
|
-
const eventName = eventNameMap[event];
|
|
78
|
-
if (eventName) {
|
|
79
|
-
document.addEventListener(eventName, callback, false);
|
|
80
|
-
}
|
|
81
|
-
},
|
|
82
|
-
off(event, callback) {
|
|
83
|
-
const eventName = eventNameMap[event];
|
|
84
|
-
if (eventName) {
|
|
85
|
-
document.removeEventListener(eventName, callback, false);
|
|
86
|
-
}
|
|
87
|
-
},
|
|
88
|
-
raw: nativeAPI
|
|
89
|
-
};
|
|
90
|
-
Object.defineProperties(screenfull, {
|
|
91
|
-
isFullscreen: {
|
|
92
|
-
get: () => Boolean(document[nativeAPI.fullscreenElement])
|
|
93
|
-
},
|
|
94
|
-
element: {
|
|
95
|
-
enumerable: true,
|
|
96
|
-
get: () => {
|
|
97
|
-
var _document$nativeAPI$f;
|
|
98
|
-
return (_document$nativeAPI$f = document[nativeAPI.fullscreenElement]) !== null && _document$nativeAPI$f !== void 0 ? _document$nativeAPI$f : undefined;
|
|
99
|
-
}
|
|
100
|
-
},
|
|
101
|
-
isEnabled: {
|
|
102
|
-
enumerable: true,
|
|
103
|
-
// Coerce to boolean in case of old WebKit.
|
|
104
|
-
get: () => Boolean(document[nativeAPI.fullscreenEnabled])
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
if (!nativeAPI) {
|
|
108
|
-
screenfull = {
|
|
109
|
-
isEnabled: false
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
var _default = exports.default = screenfull;
|