@ezuikit/player-theme 0.0.1-beta.1 → 1.0.0
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/dist/index.js +181 -1429
- package/dist/index.mjs +181 -1429
- package/dist/index.umd.js +1052 -1297
- package/dist/style.css +1 -1
- package/dist/style.js +2 -2
- package/dist/types/index.d.ts +1 -0
- package/package.json +6 -4
package/dist/index.umd.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* @ezuikit/player-theme
|
|
3
|
-
* Copyright (c) 2025-
|
|
2
|
+
* @ezuikit/player-theme v1.0.0
|
|
3
|
+
* Copyright (c) 2025-11-03 Ezviz-OpenBiz
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
(function (global, factory) {
|
|
@@ -534,6 +534,7 @@
|
|
|
534
534
|
/** 日期改变 */ dateChange: 'Control.dateChange',
|
|
535
535
|
/** 日期销毁 */ dateDestroy: 'Control.datePanelDestroy',
|
|
536
536
|
/** 时间轴拖动结束 */ timeLineChange: 'Control.timeLineChange',
|
|
537
|
+
/** 时间轴图片列表面板 */ timeLinePanelOpenChange: 'Control.timeLinePanelOpenChange',
|
|
537
538
|
/** 时间轴控件销毁 */ timeLineDestroy: 'Control.timeLineDestroy',
|
|
538
539
|
/** 主题控件挂载前 切换新的主题也会触发,如果想首次获取需要在 onInitializing 回调中进行监听 */ beforeMountControls: 'Control.beforeMountControls',
|
|
539
540
|
/** 主题控件挂载完成, 切换新的主题也会触发,如果想首次获取需要在 onInitializing 回调中进行监听 */ mountedControls: 'Control.mountedControls',
|
|
@@ -1463,21 +1464,32 @@
|
|
|
1463
1464
|
}(Control);
|
|
1464
1465
|
|
|
1465
1466
|
/*
|
|
1466
|
-
* @skax/picker
|
|
1467
|
-
* Copyright (c) 2025-
|
|
1467
|
+
* @skax/picker v1.0.3
|
|
1468
|
+
* Copyright (c) 2025-10-28 ShineShao <xiaoshaoqq@gmail.com>
|
|
1468
1469
|
* Released under the MIT License.
|
|
1469
1470
|
*/
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1471
|
+
/**
|
|
1472
|
+
* PickerProvider 单例类
|
|
1473
|
+
*/ class PickerProvider {
|
|
1474
|
+
/**
|
|
1475
|
+
* 获取单例实例
|
|
1476
|
+
* @returns Picker 实例
|
|
1477
|
+
*/ static getInstance() {
|
|
1478
|
+
if (!PickerProvider.instance) {
|
|
1479
|
+
PickerProvider.instance = new PickerProvider();
|
|
1474
1480
|
}
|
|
1475
|
-
return
|
|
1481
|
+
return PickerProvider.instance;
|
|
1476
1482
|
}
|
|
1477
|
-
|
|
1483
|
+
/**
|
|
1484
|
+
* 添加picker
|
|
1485
|
+
* @param picker Picker 实例
|
|
1486
|
+
*/ add(picker) {
|
|
1478
1487
|
this.pickers.push(picker);
|
|
1479
1488
|
}
|
|
1480
|
-
|
|
1489
|
+
/**
|
|
1490
|
+
* 移除picker
|
|
1491
|
+
* @param picker Picker 实例
|
|
1492
|
+
*/ remove(picker) {
|
|
1481
1493
|
const index = this.pickers.indexOf(picker);
|
|
1482
1494
|
if (index > -1) {
|
|
1483
1495
|
this.pickers.splice(index, 1);
|
|
@@ -1485,9 +1497,13 @@
|
|
|
1485
1497
|
console.warn("Picker not found in the provider.");
|
|
1486
1498
|
}
|
|
1487
1499
|
}
|
|
1488
|
-
|
|
1500
|
+
/**
|
|
1501
|
+
* 关闭其他picker
|
|
1502
|
+
* @param e 事件
|
|
1503
|
+
*/ closeOther(e) {
|
|
1489
1504
|
for (const p of this.pickers){
|
|
1490
|
-
|
|
1505
|
+
var _p_$container_contains, _p_$container, _p_$wrapperContent_contains, _p_$wrapperContent;
|
|
1506
|
+
if (p && !(e.target === p.$container || ((_p_$container = p.$container) == null ? void 0 : (_p_$container_contains = _p_$container.contains) == null ? void 0 : _p_$container_contains.call(_p_$container, e.target)) || e.target === p.$wrapperContent || ((_p_$wrapperContent = p.$wrapperContent) == null ? void 0 : (_p_$wrapperContent_contains = _p_$wrapperContent.contains) == null ? void 0 : _p_$wrapperContent_contains.call(_p_$wrapperContent, e.target)))) {
|
|
1491
1507
|
p.open = false;
|
|
1492
1508
|
}
|
|
1493
1509
|
}
|
|
@@ -1496,14 +1512,19 @@
|
|
|
1496
1512
|
this.pickers = [];
|
|
1497
1513
|
// Private constructor to prevent instantiation
|
|
1498
1514
|
}
|
|
1499
|
-
}
|
|
1500
|
-
const
|
|
1515
|
+
}
|
|
1516
|
+
const pickerProvider = PickerProvider.getInstance();
|
|
1501
1517
|
|
|
1502
1518
|
/**
|
|
1503
|
-
* picker
|
|
1519
|
+
* picker 位置
|
|
1520
|
+
*
|
|
1521
|
+
* | top | tl | tr | bottom | bl | br |
|
|
1522
|
+
* |:--------:|:---------:|:---------:|:----------:|:----------:|:----------:|
|
|
1523
|
+
* | 顶部中间 | 顶部左侧 | 顶部右侧 | 底部中间 | 底部左侧 | 底部右侧 |
|
|
1524
|
+
*
|
|
1504
1525
|
* @public
|
|
1505
1526
|
*/ // eslint-disable-next-line @typescript-eslint/naming-convention
|
|
1506
|
-
const
|
|
1527
|
+
const PICKER_PLACEMENT = [
|
|
1507
1528
|
"top",
|
|
1508
1529
|
"tl",
|
|
1509
1530
|
"tr",
|
|
@@ -1514,7 +1535,10 @@
|
|
|
1514
1535
|
/**
|
|
1515
1536
|
* 默认样式前缀
|
|
1516
1537
|
*/ const PICKER_PREFIX_CLS = "epicker";
|
|
1517
|
-
|
|
1538
|
+
/**
|
|
1539
|
+
* Picker 默认值
|
|
1540
|
+
*/ // eslint-disable-next-line @typescript-eslint/naming-convention
|
|
1541
|
+
const __PICKER_DEFAULT_OPTIONS__ = {
|
|
1518
1542
|
getPopupContainer: ()=>document.body,
|
|
1519
1543
|
wrapClassName: "",
|
|
1520
1544
|
open: false,
|
|
@@ -1538,22 +1562,27 @@
|
|
|
1538
1562
|
*
|
|
1539
1563
|
* @example
|
|
1540
1564
|
* ```ts
|
|
1565
|
+
* import "@skax/picker/dist/style/css";
|
|
1541
1566
|
* import Picker from '@skax/picker';
|
|
1542
|
-
* const picker = new Picker(
|
|
1543
|
-
*
|
|
1567
|
+
* const picker = new Picker(document.getElementById('picker-container'),
|
|
1568
|
+
* {
|
|
1544
1569
|
* placement: 'bottom',
|
|
1545
|
-
* content: '<div>选择内容</div>',
|
|
1570
|
+
* content: '<div>选择内容</div>', // or () => '<div>选择内容</div>'
|
|
1546
1571
|
* trigger: 'click',
|
|
1547
1572
|
* isMobile: false,
|
|
1548
1573
|
* });
|
|
1549
1574
|
* picker.open = true; // 打开弹窗
|
|
1550
1575
|
* picker.setPlacement('top'); // 设置弹窗位置
|
|
1551
|
-
* picker.innerHTML('<div>新内容</div>'); //
|
|
1576
|
+
* picker.innerHTML('<div>新内容</div>'); // 设置弹窗内容(会覆盖之前的内容)
|
|
1552
1577
|
* picker.destroy(); // 销毁弹窗
|
|
1553
1578
|
* ```
|
|
1554
1579
|
*/ class Picker {
|
|
1555
1580
|
/**
|
|
1556
1581
|
* picker 内容挂载节点
|
|
1582
|
+
* @example
|
|
1583
|
+
* ```ts
|
|
1584
|
+
* console.log(picker.$popupContainer); // 获取挂载节点
|
|
1585
|
+
* ```
|
|
1557
1586
|
*/ get $popupContainer() {
|
|
1558
1587
|
// prettier-ignore
|
|
1559
1588
|
if (typeof this._options.getPopupContainer === "function") {
|
|
@@ -1652,14 +1681,16 @@
|
|
|
1652
1681
|
}
|
|
1653
1682
|
set disabled(disabled) {
|
|
1654
1683
|
if (disabled) {
|
|
1655
|
-
|
|
1684
|
+
var _this_$container_classList_add, _this_$container_classList, _this_$container;
|
|
1685
|
+
(_this_$container = this.$container) == null ? void 0 : (_this_$container_classList = _this_$container.classList) == null ? void 0 : (_this_$container_classList_add = _this_$container_classList.add) == null ? void 0 : _this_$container_classList_add.call(_this_$container_classList, `${PICKER_PREFIX_CLS}-disabled`);
|
|
1656
1686
|
} else {
|
|
1657
|
-
|
|
1687
|
+
var _this_$container_classList_remove, _this_$container_classList1, _this_$container1;
|
|
1688
|
+
(_this_$container1 = this.$container) == null ? void 0 : (_this_$container_classList1 = _this_$container1.classList) == null ? void 0 : (_this_$container_classList_remove = _this_$container_classList1.remove) == null ? void 0 : _this_$container_classList_remove.call(_this_$container_classList1, `${PICKER_PREFIX_CLS}-disabled`);
|
|
1658
1689
|
}
|
|
1659
1690
|
this._disabled = disabled;
|
|
1660
1691
|
}
|
|
1661
1692
|
/**
|
|
1662
|
-
* 设置弹出位置
|
|
1693
|
+
* 设置弹出位置(移动端不生效)
|
|
1663
1694
|
* @param placement - 弹出位置
|
|
1664
1695
|
* @example
|
|
1665
1696
|
* ```ts
|
|
@@ -1674,7 +1705,7 @@
|
|
|
1674
1705
|
if (this._disabled) {
|
|
1675
1706
|
return;
|
|
1676
1707
|
}
|
|
1677
|
-
if (
|
|
1708
|
+
if (PICKER_PLACEMENT.includes(placement)) {
|
|
1678
1709
|
this._options.placement = placement;
|
|
1679
1710
|
} else {
|
|
1680
1711
|
console.warn(`${placement} is not a valid placement`);
|
|
@@ -1690,10 +1721,10 @@
|
|
|
1690
1721
|
*/ destroy() {
|
|
1691
1722
|
this._animationTimerClear();
|
|
1692
1723
|
this._removeHtml();
|
|
1693
|
-
|
|
1724
|
+
pickerProvider.remove(this);
|
|
1694
1725
|
}
|
|
1695
1726
|
/**
|
|
1696
|
-
*
|
|
1727
|
+
* 设置内容(会覆盖之前内容)
|
|
1697
1728
|
* @param html - html 字符串内容
|
|
1698
1729
|
* @example
|
|
1699
1730
|
* ```ts
|
|
@@ -1725,20 +1756,22 @@
|
|
|
1725
1756
|
/**
|
|
1726
1757
|
* 移除html
|
|
1727
1758
|
*/ _removeHtml() {
|
|
1728
|
-
var
|
|
1729
|
-
|
|
1730
|
-
this.$wrapperContent.removeEventListener("click", this._onContentClick);
|
|
1731
|
-
this.$container.removeEventListener("click", this._onContentClick);
|
|
1759
|
+
var // eslint-disable-next-line @typescript-eslint/unbound-method
|
|
1760
|
+
_this_$wrapperContent, _this_$container_removeEventListener, _this_$container;
|
|
1761
|
+
(_this_$wrapperContent = this.$wrapperContent) == null ? void 0 : _this_$wrapperContent.removeEventListener("click", this._onContentClick);
|
|
1762
|
+
(_this_$container = this.$container) == null ? void 0 : (_this_$container_removeEventListener = _this_$container.removeEventListener) == null ? void 0 : _this_$container_removeEventListener.call(_this_$container, "click", this._onContentClick);
|
|
1732
1763
|
if (this._options.trigger === "click") {
|
|
1733
|
-
|
|
1764
|
+
var _this_$container_removeEventListener1, _this_$container1;
|
|
1765
|
+
(_this_$container1 = this.$container) == null ? void 0 : (_this_$container_removeEventListener1 = _this_$container1.removeEventListener) == null ? void 0 : _this_$container_removeEventListener1.call(_this_$container1, "click", this._onShow);
|
|
1734
1766
|
}
|
|
1735
1767
|
if (this._options.trigger === "hover") {
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
this.$container.removeEventListener("
|
|
1739
|
-
|
|
1740
|
-
this.$
|
|
1741
|
-
this.$wrapperContent.removeEventListener("
|
|
1768
|
+
var _this_$container_removeEventListener2, _this_$container2, _this_$container_removeEventListener3, _this_$container3, _this_$container_removeEventListener4, _this_$container4, // prettier-ignore
|
|
1769
|
+
_this_$wrapperContent1, _this_$wrapperContent2;
|
|
1770
|
+
(_this_$container2 = this.$container) == null ? void 0 : (_this_$container_removeEventListener2 = _this_$container2.removeEventListener) == null ? void 0 : _this_$container_removeEventListener2.call(_this_$container2, "mouseenter", this._onShow);
|
|
1771
|
+
(_this_$container3 = this.$container) == null ? void 0 : (_this_$container_removeEventListener3 = _this_$container3.removeEventListener) == null ? void 0 : _this_$container_removeEventListener3.call(_this_$container3, "mouseover", this._onShow);
|
|
1772
|
+
(_this_$container4 = this.$container) == null ? void 0 : (_this_$container_removeEventListener4 = _this_$container4.removeEventListener) == null ? void 0 : _this_$container_removeEventListener4.call(_this_$container4, "mouseleave", this._onHide);
|
|
1773
|
+
(_this_$wrapperContent1 = this.$wrapperContent) == null ? void 0 : _this_$wrapperContent1.removeEventListener("mouseenter", this._onWrapperShow);
|
|
1774
|
+
(_this_$wrapperContent2 = this.$wrapperContent) == null ? void 0 : _this_$wrapperContent2.removeEventListener("mouseleave", this._onHide);
|
|
1742
1775
|
}
|
|
1743
1776
|
if (!this._options.isMobile) {
|
|
1744
1777
|
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
@@ -1751,20 +1784,31 @@
|
|
|
1751
1784
|
document.removeEventListener("click", this._onDocumentClick);
|
|
1752
1785
|
}
|
|
1753
1786
|
if (this._$mask) {
|
|
1754
|
-
var _this_$wrapperContent;
|
|
1755
1787
|
this._$mask.removeEventListener("click", this._onHide);
|
|
1756
|
-
|
|
1788
|
+
try {
|
|
1789
|
+
var _this_$wrapperContent3;
|
|
1790
|
+
(_this_$wrapperContent3 = this.$wrapperContent) == null ? void 0 : _this_$wrapperContent3.removeChild(this._$mask);
|
|
1791
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
1792
|
+
this._$mask = null;
|
|
1793
|
+
} catch (error) {}
|
|
1757
1794
|
}
|
|
1758
|
-
(
|
|
1759
|
-
|
|
1795
|
+
if (this._options.isMobile) document.body.classList.remove(`${PICKER_PREFIX_CLS}-body-noscroll`);
|
|
1796
|
+
try {
|
|
1797
|
+
var _this_$popupContainer;
|
|
1798
|
+
(_this_$popupContainer = this.$popupContainer) == null ? void 0 : _this_$popupContainer.removeChild(this.$wrapperContent);
|
|
1799
|
+
this.$wrapperContent.innerHTML = "";
|
|
1800
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
1801
|
+
this.$wrapperContent = null;
|
|
1802
|
+
} catch (error) {}
|
|
1760
1803
|
}
|
|
1761
1804
|
/**
|
|
1762
1805
|
* 现实位置
|
|
1763
1806
|
*/ _setPlacement() {
|
|
1764
|
-
|
|
1807
|
+
var _this_$container_getBoundingClientRect, _this_$container;
|
|
1808
|
+
if (!this._open || this._options.isMobile || !this.$container) {
|
|
1765
1809
|
return;
|
|
1766
1810
|
}
|
|
1767
|
-
const $containerRect = this.$container.getBoundingClientRect();
|
|
1811
|
+
const $containerRect = (_this_$container = this.$container) == null ? void 0 : (_this_$container_getBoundingClientRect = _this_$container.getBoundingClientRect) == null ? void 0 : _this_$container_getBoundingClientRect.call(_this_$container);
|
|
1768
1812
|
const $wrapperContentRect = this.$wrapperContent.getBoundingClientRect();
|
|
1769
1813
|
const $popupContainerRect = this.$popupContainer.getBoundingClientRect();
|
|
1770
1814
|
// 容器的坐标 - 挂载的容器的坐标差
|
|
@@ -1813,17 +1857,18 @@
|
|
|
1813
1857
|
right = containerRight;
|
|
1814
1858
|
break;
|
|
1815
1859
|
}
|
|
1816
|
-
this.$wrapperContent.style.cssText += `
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1860
|
+
if (this.$wrapperContent) this.$wrapperContent.style.cssText += `
|
|
1861
|
+
${right !== undefined ? `right: ${right + (((_this__options_offset3 = this._options.offset) == null ? void 0 : _this__options_offset3[0]) || 0)}px;` : ""}
|
|
1862
|
+
${left !== undefined ? `left: ${left + (((_this__options_offset4 = this._options.offset) == null ? void 0 : _this__options_offset4[0]) || 0)}px;` : ""}
|
|
1863
|
+
top: ${bottom + (((_this__options_offset5 = this._options.offset) == null ? void 0 : _this__options_offset5[1]) || 0)}px;
|
|
1864
|
+
z-index:${this._options.zIndex};
|
|
1865
|
+
`;
|
|
1822
1866
|
}
|
|
1823
1867
|
}
|
|
1824
1868
|
/**
|
|
1825
1869
|
* 初始化内容样式
|
|
1826
1870
|
*/ _initContentStyle() {
|
|
1871
|
+
if (!this.$wrapperContent) return;
|
|
1827
1872
|
// prettier-ignore
|
|
1828
1873
|
this.$wrapperContent.classList.add(`${PICKER_PREFIX_CLS}`, `${PICKER_PREFIX_CLS}-wrapper`, `${PICKER_PREFIX_CLS}-${this._options.placement}`);
|
|
1829
1874
|
// 提升优先级
|
|
@@ -1837,8 +1882,10 @@
|
|
|
1837
1882
|
this.$body = document.createElement("div");
|
|
1838
1883
|
this.$body.classList.add(`${PICKER_PREFIX_CLS}-body`);
|
|
1839
1884
|
this.$wrapperContent.appendChild(this.$body);
|
|
1840
|
-
if (this._options.content) {
|
|
1885
|
+
if (typeof this._options.content === "string") {
|
|
1841
1886
|
this.innerHTML(this._options.content);
|
|
1887
|
+
} else if (typeof this._options.content === "function") {
|
|
1888
|
+
this.innerHTML(this._options.content == null ? void 0 : this._options.content.call(this._options));
|
|
1842
1889
|
}
|
|
1843
1890
|
if (typeof this._options.wrapClassName === "string") {
|
|
1844
1891
|
try {
|
|
@@ -1850,17 +1897,20 @@
|
|
|
1850
1897
|
/**
|
|
1851
1898
|
* 绑定事件
|
|
1852
1899
|
*/ _eventListener() {
|
|
1900
|
+
var _this_$container_addEventListener, _this_$container;
|
|
1853
1901
|
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
1854
1902
|
this.$wrapperContent.addEventListener("click", this._onContentClick);
|
|
1855
|
-
this.$container.addEventListener("click", this._onContentClick);
|
|
1903
|
+
(_this_$container = this.$container) == null ? void 0 : (_this_$container_addEventListener = _this_$container.addEventListener) == null ? void 0 : _this_$container_addEventListener.call(_this_$container, "click", this._onContentClick);
|
|
1856
1904
|
//
|
|
1857
1905
|
if (this._options.trigger === "click") {
|
|
1858
|
-
|
|
1906
|
+
var _this_$container_addEventListener1, _this_$container1;
|
|
1907
|
+
(_this_$container1 = this.$container) == null ? void 0 : (_this_$container_addEventListener1 = _this_$container1.addEventListener) == null ? void 0 : _this_$container_addEventListener1.call(_this_$container1, "click", this._onShow);
|
|
1859
1908
|
}
|
|
1860
1909
|
if (this._options.trigger === "hover") {
|
|
1861
|
-
|
|
1862
|
-
this.$container.addEventListener("
|
|
1863
|
-
this.$container.addEventListener("
|
|
1910
|
+
var _this_$container_addEventListener2, _this_$container2, _this_$container_addEventListener3, _this_$container3, _this_$container_addEventListener4, _this_$container4;
|
|
1911
|
+
(_this_$container2 = this.$container) == null ? void 0 : (_this_$container_addEventListener2 = _this_$container2.addEventListener) == null ? void 0 : _this_$container_addEventListener2.call(_this_$container2, "mouseenter", this._onShow);
|
|
1912
|
+
(_this_$container3 = this.$container) == null ? void 0 : (_this_$container_addEventListener3 = _this_$container3.addEventListener) == null ? void 0 : _this_$container_addEventListener3.call(_this_$container3, "mouseover", this._onShow);
|
|
1913
|
+
(_this_$container4 = this.$container) == null ? void 0 : (_this_$container_addEventListener4 = _this_$container4.addEventListener) == null ? void 0 : _this_$container_addEventListener4.call(_this_$container4, "mouseleave", this._onHide);
|
|
1864
1914
|
this.$wrapperContent.addEventListener("mouseenter", this._onWrapperShow);
|
|
1865
1915
|
this.$wrapperContent.addEventListener("mouseleave", this._onHide);
|
|
1866
1916
|
}
|
|
@@ -1883,7 +1933,7 @@
|
|
|
1883
1933
|
* @param e - 内容点击事件
|
|
1884
1934
|
*/ _onContentClick(e) {
|
|
1885
1935
|
e.stopPropagation();
|
|
1886
|
-
|
|
1936
|
+
pickerProvider.closeOther(e);
|
|
1887
1937
|
}
|
|
1888
1938
|
/**
|
|
1889
1939
|
* 显示事件
|
|
@@ -1912,12 +1962,13 @@
|
|
|
1912
1962
|
* document 点击事件
|
|
1913
1963
|
* @param event - 鼠标点击事件
|
|
1914
1964
|
*/ _onDocumentClick(event) {
|
|
1915
|
-
|
|
1965
|
+
var _this_$container;
|
|
1966
|
+
if (!(this.$wrapperContent.contains(event.target) || this.$wrapperContent === event.target || ((_this_$container = this.$container) == null ? void 0 : _this_$container.contains(event.target)) || this.$container === event.target)) {
|
|
1916
1967
|
if (this._disabled) return;
|
|
1917
1968
|
this._onHide();
|
|
1918
1969
|
}
|
|
1919
1970
|
}
|
|
1920
|
-
constructor(options){
|
|
1971
|
+
constructor(container, options){
|
|
1921
1972
|
var _this_$popupContainer;
|
|
1922
1973
|
/** 是否打开 */ this._open = false;
|
|
1923
1974
|
this._OpenChange = false;
|
|
@@ -1925,20 +1976,14 @@
|
|
|
1925
1976
|
this._disabled = false;
|
|
1926
1977
|
this._timer = null;
|
|
1927
1978
|
// prettier-ignore
|
|
1928
|
-
this._options = Object.assign({},
|
|
1979
|
+
this._options = Object.assign({}, __PICKER_DEFAULT_OPTIONS__, options || {});
|
|
1929
1980
|
// 移动端模式强制使用 click 触发
|
|
1930
1981
|
if (this._options.isMobile) {
|
|
1931
1982
|
this._options.trigger = "click";
|
|
1932
1983
|
}
|
|
1933
|
-
|
|
1934
|
-
if (typeof
|
|
1935
|
-
|
|
1936
|
-
} else {
|
|
1937
|
-
this.$container = this._options.container;
|
|
1938
|
-
}
|
|
1939
|
-
if (!this.$container) {
|
|
1940
|
-
throw new Error("container is required!");
|
|
1941
|
-
}
|
|
1984
|
+
pickerProvider.add(this);
|
|
1985
|
+
if (typeof container === "function") this.$container = container();
|
|
1986
|
+
else this.$container = container;
|
|
1942
1987
|
this.$wrapperContent = document.createElement("div");
|
|
1943
1988
|
this._initContentStyle();
|
|
1944
1989
|
(_this_$popupContainer = this.$popupContainer) == null ? void 0 : _this_$popupContainer.appendChild(this.$wrapperContent);
|
|
@@ -1957,7 +2002,7 @@
|
|
|
1957
2002
|
* ```ts
|
|
1958
2003
|
* Picker.VERSION; // 输出版本号
|
|
1959
2004
|
* ```
|
|
1960
|
-
*/ Picker.VERSION = "0.
|
|
2005
|
+
*/ Picker.VERSION = "1.0.3";
|
|
1961
2006
|
|
|
1962
2007
|
/*
|
|
1963
2008
|
* delegate.js v3.2.0
|
|
@@ -2838,8 +2883,7 @@
|
|
|
2838
2883
|
// 轻应用私有暂时不支持调节音量
|
|
2839
2884
|
if (!(Utils.isMobile || _this._options.PLAY_TYPE === 'ezopen')) {
|
|
2840
2885
|
var _this__options_props4, _this__options_props5;
|
|
2841
|
-
_this.picker = new Picker({
|
|
2842
|
-
container: _this.$container,
|
|
2886
|
+
_this.picker = new Picker(_this.$container, {
|
|
2843
2887
|
getPopupContainer: function() {
|
|
2844
2888
|
return _this.$container;
|
|
2845
2889
|
},
|
|
@@ -5128,8 +5172,7 @@
|
|
|
5128
5172
|
}) : IconComponents.moreDot({
|
|
5129
5173
|
title: (_this_locale1 = this.locale) == null ? void 0 : _this_locale1.BTN_MORE
|
|
5130
5174
|
});
|
|
5131
|
-
this.picker = new Picker({
|
|
5132
|
-
container: this.$container,
|
|
5175
|
+
this.picker = new Picker(this.$container, {
|
|
5133
5176
|
getPopupContainer: function() {
|
|
5134
5177
|
return _this.$container;
|
|
5135
5178
|
},
|
|
@@ -5571,6 +5614,14 @@
|
|
|
5571
5614
|
theme.controls.timeLineControl.on(EVENTS.control.timeLineChange, function(date) {
|
|
5572
5615
|
theme.emit(EVENTS.control.timeLineChange, date);
|
|
5573
5616
|
});
|
|
5617
|
+
theme.controls.timeLineControl.on(EVENTS.control.timeLinePanelOpenChange, function(open) {
|
|
5618
|
+
var _theme_controls_dateControl;
|
|
5619
|
+
if ((_theme_controls_dateControl = theme.controls.dateControl) == null ? void 0 : _theme_controls_dateControl.dataPickerUtil) {
|
|
5620
|
+
var _theme_controls_dateControl_dataPickerUtil, _theme_controls_dateControl1;
|
|
5621
|
+
(_theme_controls_dateControl1 = theme.controls.dateControl) == null ? void 0 : (_theme_controls_dateControl_dataPickerUtil = _theme_controls_dateControl1.dataPickerUtil) == null ? void 0 : _theme_controls_dateControl_dataPickerUtil.hide();
|
|
5622
|
+
}
|
|
5623
|
+
theme.emit(EVENTS.control.timeLinePanelOpenChange, open);
|
|
5624
|
+
});
|
|
5574
5625
|
theme.controls.timeLineControl.on(EVENTS.control.timeLineDestroy, function() {
|
|
5575
5626
|
theme.emit(EVENTS.control.timeLineDestroy);
|
|
5576
5627
|
});
|
|
@@ -9132,8 +9183,7 @@
|
|
|
9132
9183
|
}
|
|
9133
9184
|
var _this__options_fieldNames_value;
|
|
9134
9185
|
var valueKey = (_this__options_fieldNames_value = (_this__options_fieldNames = _this._options.fieldNames) == null ? void 0 : _this__options_fieldNames.value) != null ? _this__options_fieldNames_value : 'value';
|
|
9135
|
-
_this._picker = new Picker({
|
|
9136
|
-
container: _this.$container,
|
|
9186
|
+
_this._picker = new Picker(_this.$container, {
|
|
9137
9187
|
// 由于某些原因, 移动端强制渲染在 body 上
|
|
9138
9188
|
getPopupContainer: function() {
|
|
9139
9189
|
return Utils.isMobile ? options.rootContainer : _this.$container;
|
|
@@ -9416,16 +9466,14 @@
|
|
|
9416
9466
|
controlType: 'button',
|
|
9417
9467
|
classNameSuffix: 'definition',
|
|
9418
9468
|
renderLabel: function(label, item, list) {
|
|
9419
|
-
var _list_;
|
|
9420
9469
|
if ((item == null ? void 0 : item.level) === 'auto') {
|
|
9421
9470
|
var _options_locales_options_language;
|
|
9422
|
-
var
|
|
9471
|
+
var realIitem = list.find(function(it) {
|
|
9423
9472
|
return it.level === _assert_this_initialized$1(_this)._level;
|
|
9424
9473
|
});
|
|
9425
|
-
return "<span>" + (options == null ? void 0 : (_options_locales_options_language = options.locales[options.language]) == null ? void 0 : _options_locales_options_language.VIDEO_LEVEL_AUTO) + "(" + ((
|
|
9474
|
+
return "<span>" + (options == null ? void 0 : (_options_locales_options_language = options.locales[options.language]) == null ? void 0 : _options_locales_options_language.VIDEO_LEVEL_AUTO) + "(" + ((realIitem == null ? void 0 : realIitem.name) || '') + ")</span>";
|
|
9426
9475
|
}
|
|
9427
|
-
|
|
9428
|
-
return "<span>" + (label || ((_list_ = list[0]) == null ? void 0 : _list_.name) || '') + "</span>";
|
|
9476
|
+
return "<span>" + label + "</span>";
|
|
9429
9477
|
},
|
|
9430
9478
|
onChange: function(value, item) {
|
|
9431
9479
|
var _options_onChange;
|
|
@@ -9452,10 +9500,10 @@
|
|
|
9452
9500
|
_this._level = realLevel + '';
|
|
9453
9501
|
if (l === 'auto') {
|
|
9454
9502
|
var _options_locales_options_language;
|
|
9455
|
-
var
|
|
9503
|
+
var realIitem = _this.list.find(function(it) {
|
|
9456
9504
|
return it.level === _this._level;
|
|
9457
9505
|
});
|
|
9458
|
-
_this.$container.querySelector("." + PREFIX_CLASS + "-select-btn").innerHTML = "\n <span>" + (options == null ? void 0 : (_options_locales_options_language = options.locales[options.language]) == null ? void 0 : _options_locales_options_language.VIDEO_LEVEL_AUTO) + "(" + ((
|
|
9506
|
+
_this.$container.querySelector("." + PREFIX_CLASS + "-select-btn").innerHTML = "\n <span>" + (options == null ? void 0 : (_options_locales_options_language = options.locales[options.language]) == null ? void 0 : _options_locales_options_language.VIDEO_LEVEL_AUTO) + "(" + ((realIitem == null ? void 0 : realIitem.name) || '') + ")</span>\n ";
|
|
9459
9507
|
} else {
|
|
9460
9508
|
if (_this.value !== _this._level + '') _this.value = _this._level + '';
|
|
9461
9509
|
}
|
|
@@ -9674,7 +9722,7 @@
|
|
|
9674
9722
|
};
|
|
9675
9723
|
/**
|
|
9676
9724
|
* 日期选择器
|
|
9677
|
-
*/
|
|
9725
|
+
*/ class DatePicker {
|
|
9678
9726
|
_init() {
|
|
9679
9727
|
// 因为挂载在行内,需要父标签设置 position: relative;
|
|
9680
9728
|
this.$container.style.cssText += `;position: relative;`;
|
|
@@ -9802,7 +9850,7 @@
|
|
|
9802
9850
|
}
|
|
9803
9851
|
});
|
|
9804
9852
|
}
|
|
9805
|
-
}
|
|
9853
|
+
}
|
|
9806
9854
|
|
|
9807
9855
|
/**
|
|
9808
9856
|
* @description 时间操作
|
|
@@ -9988,9 +10036,9 @@
|
|
|
9988
10036
|
/**
|
|
9989
10037
|
* 日历选择器控件
|
|
9990
10038
|
* @category Control
|
|
9991
|
-
*/ var
|
|
9992
|
-
_inherits$6(
|
|
9993
|
-
function
|
|
10039
|
+
*/ var DatePickerControl = /*#__PURE__*/ function(Control) {
|
|
10040
|
+
_inherits$6(DatePickerControl, Control);
|
|
10041
|
+
function DatePickerControl(options) {
|
|
9994
10042
|
var _this;
|
|
9995
10043
|
var _this_options_props_urlInfo_searchParams, _this_options_props_urlInfo, _this_options_props;
|
|
9996
10044
|
_this = Control.call(this, _extends$6({}, options, {
|
|
@@ -10003,7 +10051,7 @@
|
|
|
10003
10051
|
_this._render();
|
|
10004
10052
|
return _this;
|
|
10005
10053
|
}
|
|
10006
|
-
var _proto =
|
|
10054
|
+
var _proto = DatePickerControl.prototype;
|
|
10007
10055
|
_proto._render = function _render() {
|
|
10008
10056
|
var _this = this;
|
|
10009
10057
|
if (isMobile$1()) {
|
|
@@ -10015,7 +10063,7 @@
|
|
|
10015
10063
|
title: (_this_locale1 = this.locale) == null ? void 0 : _this_locale1.BTN_CALENDAR
|
|
10016
10064
|
});
|
|
10017
10065
|
}
|
|
10018
|
-
this.dataPickerUtil = new DatePicker
|
|
10066
|
+
this.dataPickerUtil = new DatePicker(this.$container, {
|
|
10019
10067
|
staticPath: this.options.staticPath,
|
|
10020
10068
|
language: this.options.language === 'zh' ? 'zh-CN' : 'en-US',
|
|
10021
10069
|
current: new Date(this._value + ' 00:00:00'),
|
|
@@ -10075,865 +10123,755 @@
|
|
|
10075
10123
|
*/ _proto._onControlClick = function _onControlClick(e) {
|
|
10076
10124
|
Control.prototype._onControlClick.call(this, e);
|
|
10077
10125
|
};
|
|
10078
|
-
return
|
|
10126
|
+
return DatePickerControl;
|
|
10079
10127
|
}(Control);
|
|
10080
10128
|
|
|
10081
|
-
|
|
10082
|
-
|
|
10083
|
-
|
|
10084
|
-
|
|
10085
|
-
|
|
10086
|
-
|
|
10087
|
-
|
|
10088
|
-
|
|
10089
|
-
|
|
10090
|
-
|
|
10091
|
-
|
|
10092
|
-
|
|
10093
|
-
|
|
10129
|
+
/**
|
|
10130
|
+
* drag scroll support move and touch
|
|
10131
|
+
*
|
|
10132
|
+
* @skax/drag-scroll v1.0.0
|
|
10133
|
+
* Copyright (c) 2025-11-03 ShineShao <xiaoshaoqq@gmail.com>
|
|
10134
|
+
*
|
|
10135
|
+
* This source code is licensed under the MIT license found in the
|
|
10136
|
+
* LICENSE file in the root directory of this source tree.
|
|
10137
|
+
*/
|
|
10138
|
+
/**
|
|
10139
|
+
* 拖拽滚动状态
|
|
10140
|
+
*/ /**
|
|
10141
|
+
* 默认参数
|
|
10142
|
+
*/ const _$DRAG_SCROLL_DEFAULT_OPTIONS$_ = {
|
|
10143
|
+
content: '',
|
|
10144
|
+
height: '400px',
|
|
10145
|
+
readonly: false,
|
|
10146
|
+
hideScrollbar: false
|
|
10094
10147
|
};
|
|
10095
|
-
|
|
10096
|
-
|
|
10097
|
-
|
|
10098
|
-
|
|
10148
|
+
/**
|
|
10149
|
+
* 前缀类名
|
|
10150
|
+
*/ const _$DRAG_SCROLL_PREFIX_CLASSNAME$_ = 'drag-scroll';
|
|
10151
|
+
/**
|
|
10152
|
+
* 拖拽滚动(使用 PointerEvent 统一处理鼠标和触摸事件)
|
|
10153
|
+
* @class DragScroll
|
|
10154
|
+
* @example
|
|
10155
|
+
* ```ts
|
|
10156
|
+
* const container = document.getElementById('scrollContainer');
|
|
10157
|
+
* const dragScroll = new DragScroll(container, {
|
|
10158
|
+
* width: '300px',
|
|
10159
|
+
* height: '500px',
|
|
10160
|
+
* content: '<div>...</div>',
|
|
10161
|
+
* });
|
|
10162
|
+
* ```
|
|
10163
|
+
*/ class DragScroll {
|
|
10099
10164
|
/**
|
|
10100
|
-
*
|
|
10101
|
-
* @
|
|
10102
|
-
|
|
10103
|
-
|
|
10104
|
-
|
|
10105
|
-
|
|
10106
|
-
|
|
10165
|
+
* 获取容器宽度
|
|
10166
|
+
* @example
|
|
10167
|
+
* ```ts
|
|
10168
|
+
* const width = dragScroll.width;
|
|
10169
|
+
* ```
|
|
10170
|
+
* @return {number}
|
|
10171
|
+
*/ get width() {
|
|
10172
|
+
return this.$container.clientWidth;
|
|
10107
10173
|
}
|
|
10108
|
-
resize(width, height) {}
|
|
10109
10174
|
/**
|
|
10110
|
-
*
|
|
10111
|
-
|
|
10112
|
-
|
|
10113
|
-
|
|
10114
|
-
|
|
10115
|
-
|
|
10116
|
-
|
|
10117
|
-
this.
|
|
10118
|
-
this.$container = container;
|
|
10119
|
-
this.options = deepmerge(BASE_TIME_LINE_DEFAULT_OPTIONS, options, {
|
|
10120
|
-
clone: false
|
|
10121
|
-
});
|
|
10122
|
-
}
|
|
10123
|
-
}
|
|
10124
|
-
|
|
10125
|
-
function toDate(time) {
|
|
10126
|
-
let date = null;
|
|
10127
|
-
if (typeof time === 'string' && time.includes(':')) {
|
|
10128
|
-
date = new Date(time);
|
|
10129
|
-
} else if ((typeof time === 'string' || typeof time === 'number') && /\d/.test(time + '') && (time + '').length === 10) {
|
|
10130
|
-
date = new Date(+time * 1000);
|
|
10131
|
-
} else if ((typeof time === 'string' || typeof time === 'number') && /\d/.test(time + '') && (time + '').length === 13) {
|
|
10132
|
-
date = new Date(+time);
|
|
10133
|
-
} else if (time instanceof Date) {
|
|
10134
|
-
date = time;
|
|
10175
|
+
* 获取容器高度
|
|
10176
|
+
* @example
|
|
10177
|
+
* ```ts
|
|
10178
|
+
* const height = dragScroll.height;
|
|
10179
|
+
* ```
|
|
10180
|
+
* @return {number}
|
|
10181
|
+
*/ get height() {
|
|
10182
|
+
return this.$container.clientHeight;
|
|
10135
10183
|
}
|
|
10136
|
-
|
|
10137
|
-
|
|
10138
|
-
|
|
10139
|
-
|
|
10140
|
-
* @param time
|
|
10141
|
-
* @returns
|
|
10142
|
-
*/ function formatDateToHHmmss(time) {
|
|
10143
|
-
const date = toDate(time);
|
|
10144
|
-
if (date) {
|
|
10145
|
-
const h = date.getHours(); // 返回日期中的小时数(0到23)
|
|
10146
|
-
const m = date.getMinutes(); // 返回日期中的分钟数(0到59)
|
|
10147
|
-
const s = date.getSeconds(); // 返回日期中的秒数(0到59)
|
|
10148
|
-
return (h > 9 ? h : '0' + h) + ':' + (m > 9 ? m : '0' + m) + ':' + (s > 9 ? s : '0' + s);
|
|
10149
|
-
}
|
|
10150
|
-
return '00:00:00';
|
|
10151
|
-
}
|
|
10152
|
-
function subTime(time) {
|
|
10153
|
-
if (+time < 10) {
|
|
10154
|
-
return '0' + time;
|
|
10155
|
-
} else {
|
|
10156
|
-
return time;
|
|
10184
|
+
/**
|
|
10185
|
+
* 只读属性
|
|
10186
|
+
*/ get readonly() {
|
|
10187
|
+
return this._readonly;
|
|
10157
10188
|
}
|
|
10158
|
-
|
|
10159
|
-
|
|
10160
|
-
|
|
10161
|
-
|
|
10162
|
-
if (fmt === 'YYYY-MM-DD') {
|
|
10163
|
-
return newDate.getFullYear() + '-' + subTime(newDate.getMonth() + 1) + '-' + subTime(newDate.getDate());
|
|
10164
|
-
} else if (fmt === 'HH:mm:ss') {
|
|
10165
|
-
return subTime(newDate.getHours()) + ':' + subTime(newDate.getMinutes()) + ':' + subTime(newDate.getSeconds());
|
|
10189
|
+
set readonly(value) {
|
|
10190
|
+
if (this._readonly !== value) {
|
|
10191
|
+
this.$container.style.cursor = value ? 'not-allowed' : 'grab';
|
|
10192
|
+
this._readonly = value;
|
|
10166
10193
|
}
|
|
10167
|
-
|
|
10168
|
-
|
|
10169
|
-
|
|
10170
|
-
|
|
10171
|
-
|
|
10172
|
-
|
|
10173
|
-
* @description 判读两个区间是否重叠
|
|
10174
|
-
* @param {number} a_start 一个区间的开始
|
|
10175
|
-
* @param {number} a_end 一个区间的结束
|
|
10176
|
-
* @param {number} b_start 另一个区间的开始
|
|
10177
|
-
* @param {number} b_end 另一个区间的结束
|
|
10178
|
-
* @returns {boolean}
|
|
10179
|
-
*/ function isOverlap(a_start, a_end, b_start, b_end) {
|
|
10180
|
-
return Math.max(a_start, b_start) <= Math.min(a_end, b_end);
|
|
10181
|
-
}
|
|
10182
|
-
|
|
10183
|
-
/* eslint-disable @typescript-eslint/no-non-null-assertion */ /* eslint-disable eqeqeq */ /* eslint-disable no-unneeded-ternary */ /* eslint-disable @typescript-eslint/no-this-alias */ /* eslint-disable @typescript-eslint/prefer-includes */ function _extends$5() {
|
|
10184
|
-
_extends$5 = Object.assign || function(target) {
|
|
10185
|
-
for(var i = 1; i < arguments.length; i++){
|
|
10186
|
-
var source = arguments[i];
|
|
10187
|
-
for(var key in source){
|
|
10188
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
10189
|
-
target[key] = source[key];
|
|
10190
|
-
}
|
|
10191
|
-
}
|
|
10194
|
+
this.$container.removeEventListener('touchmove', this._onTouchMove);
|
|
10195
|
+
if (!value) {
|
|
10196
|
+
// 当非只读时,添加 touchmove 事件监听, 阻止透传到body默认滚动行为
|
|
10197
|
+
this.$container.addEventListener('touchmove', this._onTouchMove, {
|
|
10198
|
+
passive: false
|
|
10199
|
+
}); //
|
|
10192
10200
|
}
|
|
10193
|
-
return target;
|
|
10194
|
-
};
|
|
10195
|
-
return _extends$5.apply(this, arguments);
|
|
10196
|
-
}
|
|
10197
|
-
const PREFIX = 'ez-time-line';
|
|
10198
|
-
/**
|
|
10199
|
-
* 0: 1分钟,
|
|
10200
|
-
* 1: 10分钟
|
|
10201
|
-
* 2: 半小时
|
|
10202
|
-
* 3: 1小时
|
|
10203
|
-
* 4: 2小时
|
|
10204
|
-
*/ const scaleEnum = {
|
|
10205
|
-
0: 1,
|
|
10206
|
-
1: 10,
|
|
10207
|
-
2: 30,
|
|
10208
|
-
3: 60,
|
|
10209
|
-
4: 120
|
|
10210
|
-
};
|
|
10211
|
-
const MOBILE_TIME_LINE_DEFAULT_OPTIONS = Object.assign({}, BASE_TIME_LINE_DEFAULT_OPTIONS, {
|
|
10212
|
-
// height: 400,
|
|
10213
|
-
scale: 0,
|
|
10214
|
-
readOnly: false
|
|
10215
|
-
});
|
|
10216
|
-
let TimeLine$1 = class TimeLine extends BaseTimeLine {
|
|
10217
|
-
/**
|
|
10218
|
-
* 更新状态
|
|
10219
|
-
* @param obj
|
|
10220
|
-
*/ setState(obj) {
|
|
10221
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
10222
|
-
Object.keys(obj).forEach((key)=>{
|
|
10223
|
-
this.state[key] = obj[key];
|
|
10224
|
-
if (key === 'scrollTop' && this._$itemList) {
|
|
10225
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
10226
|
-
this._$itemContainer.scrollTo(0, obj[key]);
|
|
10227
|
-
}
|
|
10228
|
-
if (key === 'current' && this._$currentTime) {
|
|
10229
|
-
this._$currentTime.querySelector(`.${PREFIX}-current-value`).innerHTML = obj[key];
|
|
10230
|
-
}
|
|
10231
|
-
});
|
|
10232
10201
|
}
|
|
10233
10202
|
/**
|
|
10234
|
-
*
|
|
10235
|
-
|
|
10236
|
-
|
|
10237
|
-
|
|
10238
|
-
this._readOnly = readOnly;
|
|
10239
|
-
if (this._$itemList) this._$itemContainer.style.overflowY = readOnly ? 'hidden' : 'scroll';
|
|
10203
|
+
* 内容是否可滚动
|
|
10204
|
+
*/ get canDrag() {
|
|
10205
|
+
const clientHeight = this.$content.clientHeight;
|
|
10206
|
+
return !this.readonly && clientHeight > this.$container.clientHeight;
|
|
10240
10207
|
}
|
|
10241
10208
|
/**
|
|
10242
|
-
*
|
|
10243
|
-
*
|
|
10244
|
-
*
|
|
10245
|
-
*
|
|
10246
|
-
*
|
|
10247
|
-
*
|
|
10248
|
-
*
|
|
10249
|
-
|
|
10250
|
-
|
|
10251
|
-
|
|
10252
|
-
|
|
10209
|
+
* 设置容器尺寸
|
|
10210
|
+
* @param width 容器宽度
|
|
10211
|
+
* @param height 容器高度
|
|
10212
|
+
* @example
|
|
10213
|
+
* ```ts
|
|
10214
|
+
* dragScroll.resize(500, '400px');
|
|
10215
|
+
* dragScroll.resize('80%', '600px');
|
|
10216
|
+
* ```
|
|
10217
|
+
*/ resize(width, height) {
|
|
10218
|
+
let css = ``;
|
|
10219
|
+
if (/^\d+(\.\d+)?$/.test(width + '')) {
|
|
10220
|
+
css = `width: ${width}px;`;
|
|
10221
|
+
} else if (typeof width === 'string') {
|
|
10222
|
+
css = `width: ${width};`;
|
|
10253
10223
|
}
|
|
10254
|
-
|
|
10255
|
-
|
|
10256
|
-
|
|
10224
|
+
if (/^\d+(\.\d+)?$/.test(height + '')) {
|
|
10225
|
+
css += `height: ${height}px;`;
|
|
10226
|
+
} else if (typeof height === 'string') {
|
|
10227
|
+
css += `height: ${height};`;
|
|
10228
|
+
}
|
|
10229
|
+
this.$container.style.cssText += css;
|
|
10230
|
+
this._applyTransform();
|
|
10257
10231
|
}
|
|
10258
10232
|
/**
|
|
10259
|
-
*
|
|
10260
|
-
|
|
10261
|
-
|
|
10262
|
-
|
|
10263
|
-
|
|
10264
|
-
|
|
10265
|
-
|
|
10266
|
-
|
|
10267
|
-
|
|
10268
|
-
|
|
10269
|
-
});
|
|
10270
|
-
if (list.length > 0) {
|
|
10271
|
-
if (typeof defaultIndex === 'undefined') {
|
|
10272
|
-
defaultIndex = list.length - 1;
|
|
10273
|
-
}
|
|
10274
|
-
// 若current不为0,则不重置current,避免拖动后时间轴回弹
|
|
10275
|
-
const { current } = this.state;
|
|
10276
|
-
this.setState({
|
|
10277
|
-
availTimeLine: list,
|
|
10278
|
-
start: list[defaultIndex].startTime,
|
|
10279
|
-
end: list[defaultIndex].endTime,
|
|
10280
|
-
current: current === 0 ? list[defaultIndex].startTime : current
|
|
10281
|
-
});
|
|
10282
|
-
this._matchRecTimeDot();
|
|
10283
|
-
this._primaryOffsetH();
|
|
10284
|
-
} else {
|
|
10285
|
-
this.setState({
|
|
10286
|
-
availTimeLine: []
|
|
10287
|
-
});
|
|
10288
|
-
this._matchRecTimeDot();
|
|
10289
|
-
}
|
|
10290
|
-
}
|
|
10291
|
-
_matchTimeDot() {
|
|
10292
|
-
const { end } = this.state;
|
|
10293
|
-
const scaleWidth = this._scaleWidth;
|
|
10294
|
-
const timeArr = [];
|
|
10295
|
-
// 时间转分钟
|
|
10296
|
-
let minute = this._timeToMinute(end);
|
|
10297
|
-
minute = Math.floor(minute / scaleWidth) * scaleWidth;
|
|
10298
|
-
for(let i = minute; i >= 0;){
|
|
10299
|
-
let marginTop = 0;
|
|
10300
|
-
let marginBottom = 0;
|
|
10301
|
-
// 视频片段
|
|
10302
|
-
if (i == minute) marginTop = 70;
|
|
10303
|
-
if (i == 0) {
|
|
10304
|
-
const height = this.$container.clientHeight;
|
|
10305
|
-
marginBottom = height - 70;
|
|
10306
|
-
}
|
|
10307
|
-
const time = this._minuteToTime(i);
|
|
10308
|
-
timeArr.push({
|
|
10309
|
-
id: i,
|
|
10310
|
-
current: time,
|
|
10311
|
-
label: 'a' + i,
|
|
10312
|
-
marginTop,
|
|
10313
|
-
marginBottom,
|
|
10314
|
-
recArr: []
|
|
10315
|
-
});
|
|
10316
|
-
i = i - scaleWidth;
|
|
10317
|
-
}
|
|
10318
|
-
this.setState({
|
|
10319
|
-
timeArr
|
|
10320
|
-
});
|
|
10321
|
-
this._renderDateLine();
|
|
10233
|
+
* 设置 HTML 内容
|
|
10234
|
+
* @param html HTML 字符串或返回 HTML 字符串的函数
|
|
10235
|
+
* @example
|
|
10236
|
+
* ```ts
|
|
10237
|
+
* dragScroll.innerHtml('<div>New Content</div>');
|
|
10238
|
+
* dragScroll.innerHtml(() => '<div>Dynamic Content</div>');
|
|
10239
|
+
* ```
|
|
10240
|
+
*/ innerHtml(html) {
|
|
10241
|
+
this.$content.innerHTML = typeof html === 'function' ? html() : html;
|
|
10242
|
+
this._applyTransform();
|
|
10322
10243
|
}
|
|
10323
|
-
|
|
10324
|
-
|
|
10325
|
-
|
|
10326
|
-
|
|
10327
|
-
|
|
10328
|
-
|
|
10329
|
-
|
|
10330
|
-
|
|
10331
|
-
|
|
10332
|
-
|
|
10333
|
-
|
|
10334
|
-
|
|
10335
|
-
|
|
10336
|
-
|
|
10337
|
-
|
|
10338
|
-
|
|
10339
|
-
|
|
10340
|
-
let stAvailPercent = 0;
|
|
10341
|
-
let etAvailPercent = 0;
|
|
10342
|
-
const stMinute = Math.floor(st / (scaleWidth * 60)) * scaleWidth;
|
|
10343
|
-
stAvailPercent = (st - stMinute * 60) / scaleWidth;
|
|
10344
|
-
const etMinute = Math.floor(et / (scaleWidth * 60)) * scaleWidth;
|
|
10345
|
-
etAvailPercent = (et - etMinute * 60) / scaleWidth;
|
|
10346
|
-
for(let j = 0; j < timeArr.length; j++){
|
|
10347
|
-
if (timeArr[j].id == stMinute && timeArr[j].id == etMinute) {
|
|
10348
|
-
const height = etAvailPercent - stAvailPercent;
|
|
10349
|
-
const top = 60 - etAvailPercent;
|
|
10350
|
-
timeArr[j].recArr.push({
|
|
10351
|
-
height,
|
|
10352
|
-
top
|
|
10353
|
-
});
|
|
10354
|
-
} else {
|
|
10355
|
-
if (timeArr[j].id == stMinute) {
|
|
10356
|
-
timeArr[j].recArr.push({
|
|
10357
|
-
height: 60 - stAvailPercent,
|
|
10358
|
-
top: 0
|
|
10359
|
-
});
|
|
10360
|
-
} else if (timeArr[j].id == etMinute) {
|
|
10361
|
-
timeArr[j].recArr.push({
|
|
10362
|
-
height: etAvailPercent,
|
|
10363
|
-
top: 60 - etAvailPercent
|
|
10364
|
-
});
|
|
10365
|
-
} else if (timeArr[j].id > stMinute && timeArr[j].id < etMinute) {
|
|
10366
|
-
timeArr[j].recArr.push({
|
|
10367
|
-
height: 60,
|
|
10368
|
-
top: 0
|
|
10369
|
-
});
|
|
10370
|
-
}
|
|
10371
|
-
}
|
|
10372
|
-
}
|
|
10373
|
-
}
|
|
10374
|
-
}
|
|
10375
|
-
this.setState({
|
|
10376
|
-
timeArr
|
|
10377
|
-
});
|
|
10378
|
-
this._renderDateLine();
|
|
10379
|
-
}
|
|
10380
|
-
_renderDateLine() {
|
|
10381
|
-
const { timeArr } = this.state;
|
|
10382
|
-
const container = this._$itemList;
|
|
10383
|
-
container.innerHTML = '';
|
|
10384
|
-
timeArr.forEach((item, index)=>{
|
|
10385
|
-
const timeItemDOM = document.createElement('div');
|
|
10386
|
-
timeItemDOM.setAttribute('class', PREFIX + '-time-scale-area');
|
|
10387
|
-
timeItemDOM.style.cssText = `margin-top: ${item.marginTop}px; margin-bottom: ${item.marginBottom}px; border-right-color: ${item.borderColor};`;
|
|
10388
|
-
const scaleDOM = document.createElement('div');
|
|
10389
|
-
scaleDOM.setAttribute('class', PREFIX + '-scale');
|
|
10390
|
-
let timeItemHtml = `
|
|
10391
|
-
<div class="${PREFIX}-time-scale"></div>
|
|
10392
|
-
<div class="${PREFIX}-time-scale"></div>
|
|
10393
|
-
<div class="${PREFIX}-time-scale"></div>
|
|
10394
|
-
<div class="${PREFIX}-time-scale"></div>
|
|
10395
|
-
<div class="${PREFIX}-time-scale"></div>
|
|
10396
|
-
<div class="${PREFIX}-time-scale" style="width:10px"></div>
|
|
10397
|
-
`;
|
|
10398
|
-
item.recArr.forEach((i, j)=>{
|
|
10399
|
-
timeItemHtml += `<div class="${PREFIX}-time-unavail" style="height: ${i.height}px;background-color:#A8B9ED; top: ${i.top}px"></div>`;
|
|
10400
|
-
});
|
|
10401
|
-
timeItemHtml += `<div id=${item.label} class="${PREFIX}-time-label"> ${item.current}</div>`;
|
|
10402
|
-
timeItemDOM.innerHTML = timeItemHtml;
|
|
10403
|
-
container.appendChild(timeItemDOM);
|
|
10404
|
-
});
|
|
10244
|
+
/**
|
|
10245
|
+
* Y轴滚动到指定位置
|
|
10246
|
+
* @param y Y轴平移值 (需正值不支持负值)
|
|
10247
|
+
* @example
|
|
10248
|
+
* ```ts
|
|
10249
|
+
* dragScroll.scrollToY(200);
|
|
10250
|
+
* dragScroll.scrollToY(0); // 平移到顶部
|
|
10251
|
+
* dragScroll.scrollToY(-2); // 无效
|
|
10252
|
+
* ```
|
|
10253
|
+
*/ scrollToY(y, triggerChange = true) {
|
|
10254
|
+
const maxScroll = this.$content.scrollHeight - this.$container.clientHeight;
|
|
10255
|
+
// 边界检查
|
|
10256
|
+
if (y < 0 || y > maxScroll) return;
|
|
10257
|
+
this.currentY = y;
|
|
10258
|
+
this.velocity = 0;
|
|
10259
|
+
this._applyTransform();
|
|
10260
|
+
if (triggerChange) this._updateState();
|
|
10405
10261
|
}
|
|
10406
|
-
|
|
10407
|
-
|
|
10408
|
-
|
|
10409
|
-
|
|
10410
|
-
|
|
10411
|
-
|
|
10412
|
-
|
|
10413
|
-
|
|
10414
|
-
|
|
10415
|
-
this.
|
|
10416
|
-
|
|
10417
|
-
|
|
10262
|
+
/**
|
|
10263
|
+
* 销毁方法,用于清理资源
|
|
10264
|
+
* @example
|
|
10265
|
+
* ```ts
|
|
10266
|
+
* dragScroll.destroy();
|
|
10267
|
+
* dragScroll = null;
|
|
10268
|
+
* ```
|
|
10269
|
+
*/ destroy() {
|
|
10270
|
+
var _this__$scrollbarThumb, _this__$scrollbar, _this_$content;
|
|
10271
|
+
if (this._animationId) {
|
|
10272
|
+
cancelAnimationFrame(this._animationId);
|
|
10273
|
+
this._animationId = null;
|
|
10274
|
+
}
|
|
10275
|
+
if (this._indicatorTimeout) {
|
|
10276
|
+
clearTimeout(this._indicatorTimeout);
|
|
10277
|
+
this._indicatorTimeout = null;
|
|
10278
|
+
}
|
|
10279
|
+
(_this__$scrollbarThumb = this._$scrollbarThumb) == null ? void 0 : _this__$scrollbarThumb.remove();
|
|
10280
|
+
this._$scrollbarThumb = null;
|
|
10281
|
+
(_this__$scrollbar = this._$scrollbar) == null ? void 0 : _this__$scrollbar.remove();
|
|
10282
|
+
this._$scrollbar = null;
|
|
10283
|
+
(_this_$content = this.$content) == null ? void 0 : _this_$content.remove();
|
|
10284
|
+
this.$content = null;
|
|
10285
|
+
this._removeEventListeners();
|
|
10418
10286
|
}
|
|
10419
|
-
|
|
10420
|
-
|
|
10421
|
-
|
|
10422
|
-
|
|
10423
|
-
|
|
10424
|
-
|
|
10425
|
-
|
|
10426
|
-
|
|
10427
|
-
this.
|
|
10428
|
-
|
|
10429
|
-
|
|
10287
|
+
// ---------------------------------------------------------------------- //
|
|
10288
|
+
// 私有方法
|
|
10289
|
+
// ---------------------------------------------------------------------- //
|
|
10290
|
+
_renderScrollbar() {
|
|
10291
|
+
this._$scrollbar = document.createElement('div');
|
|
10292
|
+
this._$scrollbar.className = `${_$DRAG_SCROLL_PREFIX_CLASSNAME$_}-scrollbar`;
|
|
10293
|
+
this._$scrollbarThumb = document.createElement('div');
|
|
10294
|
+
this._$scrollbarThumb.className = `${_$DRAG_SCROLL_PREFIX_CLASSNAME$_}-scrollbar-thumb`;
|
|
10295
|
+
this._$scrollbar.appendChild(this._$scrollbarThumb);
|
|
10296
|
+
this.$container.appendChild(this._$scrollbar);
|
|
10297
|
+
}
|
|
10298
|
+
// 初始化
|
|
10299
|
+
_init() {
|
|
10300
|
+
this.resize(this.options.width, this.options.height);
|
|
10301
|
+
this._addEventListeners();
|
|
10302
|
+
// 初始化滚动条
|
|
10303
|
+
this._updateScrollbar();
|
|
10304
|
+
// 初始化动画
|
|
10305
|
+
this._animate();
|
|
10306
|
+
}
|
|
10307
|
+
// ----------- 事件处理 ----------- //
|
|
10308
|
+
/**
|
|
10309
|
+
* 添加事件监听器
|
|
10310
|
+
*/ _addEventListeners() {
|
|
10311
|
+
// 添加事件监听器
|
|
10312
|
+
this.$container.addEventListener('pointerdown', this._onMouseDown);
|
|
10313
|
+
document.addEventListener('pointermove', this._onMouseMove);
|
|
10314
|
+
// 务必同时监听 pointerup 和 pointercancel,都要做收尾和状态清理,否则会出现“拖动卡死”问题
|
|
10315
|
+
document.addEventListener('pointerup', this._onMouseUp); // 指针正常抬起时
|
|
10316
|
+
document.addEventListener('pointercancel', this._onMouseUp); // 指针操作被系统/外部原因打断时
|
|
10317
|
+
}
|
|
10318
|
+
/**
|
|
10319
|
+
* 移除事件监听器
|
|
10320
|
+
*/ _removeEventListeners() {
|
|
10321
|
+
this.$container.removeEventListener('touchmove', this._onTouchMove);
|
|
10322
|
+
// 移除事件监听器
|
|
10323
|
+
this.$container.removeEventListener('pointerdown', this._onMouseDown);
|
|
10324
|
+
document.removeEventListener('pointermove', this._onMouseMove);
|
|
10325
|
+
document.removeEventListener('pointerup', this._onMouseUp);
|
|
10326
|
+
document.removeEventListener('pointercancel', this._onMouseUp);
|
|
10327
|
+
}
|
|
10328
|
+
/**
|
|
10329
|
+
* 鼠标按下
|
|
10330
|
+
* @param e 鼠标事件
|
|
10331
|
+
*/ _onMouseDown(e) {
|
|
10332
|
+
if (!this.canDrag) return;
|
|
10333
|
+
this._startDrag(e.clientY);
|
|
10334
|
+
this.options.onDragStart == null ? void 0 : this.options.onDragStart.call(this.options, e);
|
|
10430
10335
|
}
|
|
10431
|
-
|
|
10432
|
-
|
|
10433
|
-
|
|
10434
|
-
|
|
10435
|
-
|
|
10436
|
-
const offsetH = reactTop - index * 60; // 偏移高度
|
|
10437
|
-
let current;
|
|
10438
|
-
let offsetSecond;
|
|
10439
|
-
if (offsetH == 0) {
|
|
10440
|
-
var _this_state_timeArr_;
|
|
10441
|
-
current = (_this_state_timeArr_ = this.state.timeArr[index - 1]) == null ? void 0 : _this_state_timeArr_.current;
|
|
10442
|
-
offsetSecond = 0;
|
|
10443
|
-
} else {
|
|
10444
|
-
// 当scaleWidth==120, scaleWidth==60, scaleWidth==30, scaleWidth==10, scaleWidth==1
|
|
10445
|
-
const time = this.state.timeArr[index].current;
|
|
10446
|
-
const minute = this._timeToMinute(time);
|
|
10447
|
-
// 相对于下一元素偏移
|
|
10448
|
-
const offsetY = 60 - offsetH;
|
|
10449
|
-
const offsetS = offsetY * scaleWidth; // offsetY / 60 * scaleWidth * 60
|
|
10450
|
-
const offsetM = Math.floor(offsetS / 60) + minute;
|
|
10451
|
-
const second = Math.floor(offsetS / 60) * 60;
|
|
10452
|
-
offsetSecond = Math.ceil(offsetS - second); // 保留两位小数
|
|
10453
|
-
current = this._minuteToTime(offsetM);
|
|
10454
|
-
}
|
|
10455
|
-
if (current === undefined || +current.split(':')[0] >= 24 && (+current.split(':')[1] > 0 || offsetSecond > 0)) {
|
|
10456
|
-
// 超出 24h 后不允许
|
|
10457
|
-
this.update(new Date(`${new Date().getFullYear()}-${subTime(new Date().getMonth() + 1)}-${subTime(new Date().getDate())} 23:59:59`));
|
|
10458
|
-
return;
|
|
10459
|
-
}
|
|
10460
|
-
this.setState({
|
|
10461
|
-
current: current + ':' + (offsetSecond > 9 ? offsetSecond : '0' + offsetSecond),
|
|
10462
|
-
scrollTop: reactTop
|
|
10463
|
-
});
|
|
10336
|
+
/**
|
|
10337
|
+
* 触摸移动
|
|
10338
|
+
* @param e 触摸移动事件
|
|
10339
|
+
*/ _onTouchMove(e) {
|
|
10340
|
+
e.preventDefault();
|
|
10464
10341
|
}
|
|
10465
10342
|
/**
|
|
10466
|
-
*
|
|
10467
|
-
* @param
|
|
10468
|
-
*/
|
|
10469
|
-
|
|
10470
|
-
|
|
10471
|
-
|
|
10472
|
-
|
|
10473
|
-
|
|
10343
|
+
* 开始拖拽
|
|
10344
|
+
* @param clientY 鼠标或触摸的 Y 坐标
|
|
10345
|
+
*/ _startDrag(clientY) {
|
|
10346
|
+
var _this__$scrollbar_classList, _this__$scrollbar;
|
|
10347
|
+
if (!this.canDrag) return;
|
|
10348
|
+
this.isDragging = true;
|
|
10349
|
+
this._startY = clientY;
|
|
10350
|
+
this.velocity = 0;
|
|
10351
|
+
(_this__$scrollbar = this._$scrollbar) == null ? void 0 : (_this__$scrollbar_classList = _this__$scrollbar.classList) == null ? void 0 : _this__$scrollbar_classList.add(`${_$DRAG_SCROLL_PREFIX_CLASSNAME$_}-show`);
|
|
10352
|
+
// 更新光标样式
|
|
10353
|
+
this.$container.style.cursor = 'grabbing';
|
|
10354
|
+
}
|
|
10355
|
+
/**
|
|
10356
|
+
* 鼠标移动
|
|
10357
|
+
* @param e 鼠标事件
|
|
10358
|
+
*/ _onMouseMove(e) {
|
|
10359
|
+
// e.preventDefault();
|
|
10360
|
+
if (!this.canDrag) return;
|
|
10361
|
+
if (!this.isDragging) return;
|
|
10362
|
+
this._drag(e.clientY);
|
|
10363
|
+
this.options.onDragging == null ? void 0 : this.options.onDragging.call(this.options, 0, this.currentY);
|
|
10364
|
+
}
|
|
10365
|
+
/**
|
|
10366
|
+
* 拖动
|
|
10367
|
+
* @param clientY 鼠标或触摸的 Y 坐标
|
|
10368
|
+
*/ _drag(clientY) {
|
|
10369
|
+
if (!this.canDrag) return;
|
|
10370
|
+
const deltaY = this._startY - clientY;
|
|
10371
|
+
this._startY = clientY;
|
|
10372
|
+
// 更新位置
|
|
10373
|
+
this.currentY += deltaY;
|
|
10374
|
+
// 计算速度(用于惯性滚动)
|
|
10375
|
+
this.velocity = deltaY;
|
|
10376
|
+
// 限制速度
|
|
10377
|
+
this.velocity = Math.max(Math.min(this.velocity, this._maxVelocity), -this._maxVelocity);
|
|
10378
|
+
this._applyTransform();
|
|
10379
|
+
this._updateState();
|
|
10380
|
+
}
|
|
10381
|
+
/**
|
|
10382
|
+
* 鼠标释放
|
|
10383
|
+
*/ _onMouseUp(e) {
|
|
10384
|
+
if (!this.canDrag) return;
|
|
10385
|
+
if (!this.isDragging) return;
|
|
10386
|
+
this.isDragging = false; // 停止拖动, 放置在最后
|
|
10387
|
+
this._endDrag();
|
|
10388
|
+
this.options.onDragEnd == null ? void 0 : this.options.onDragEnd.call(this.options, e);
|
|
10389
|
+
}
|
|
10390
|
+
/**
|
|
10391
|
+
* 结束拖动
|
|
10392
|
+
*/ _endDrag() {
|
|
10393
|
+
// 恢复光标样式
|
|
10394
|
+
this.$container.style.cursor = 'grab';
|
|
10395
|
+
// 延迟隐藏滚动条
|
|
10396
|
+
setTimeout(()=>{
|
|
10397
|
+
var _this__$scrollbar;
|
|
10398
|
+
if (!this.isDragging) (_this__$scrollbar = this._$scrollbar) == null ? void 0 : _this__$scrollbar.classList.remove(`${_$DRAG_SCROLL_PREFIX_CLASSNAME$_}-show`);
|
|
10399
|
+
}, 1500);
|
|
10400
|
+
}
|
|
10401
|
+
/**
|
|
10402
|
+
* 平移内容
|
|
10403
|
+
*/ _applyTransform() {
|
|
10404
|
+
const clientHeight = this.$content.clientHeight;
|
|
10405
|
+
// 内容高度小于等于容器高度时,不进行滚动
|
|
10406
|
+
if (clientHeight <= this.$container.clientHeight) {
|
|
10407
|
+
this.$content.style.transform = `translate3d(0, 0, 0)`;
|
|
10408
|
+
return;
|
|
10474
10409
|
}
|
|
10475
|
-
|
|
10476
|
-
|
|
10477
|
-
if (this.
|
|
10478
|
-
|
|
10479
|
-
this.
|
|
10410
|
+
const maxScroll = this.$content.scrollHeight - this.$container.clientHeight;
|
|
10411
|
+
// 边界检查与弹性效果
|
|
10412
|
+
if (this.currentY < 0) {
|
|
10413
|
+
// 超出顶部边界
|
|
10414
|
+
this.currentY = 0; // this.currentY * this._bounceDamping;
|
|
10415
|
+
this.velocity *= this._bounceDamping;
|
|
10416
|
+
} else if (this.currentY > maxScroll) {
|
|
10417
|
+
// 超出底部边界
|
|
10418
|
+
this.currentY = maxScroll; // maxScroll + (this.currentY - maxScroll) * this._bounceDamping;
|
|
10419
|
+
this.velocity *= this._bounceDamping;
|
|
10420
|
+
}
|
|
10421
|
+
// 应用 transform
|
|
10422
|
+
this.$content.style.transform = `translate3d(0, ${-this.currentY}px, 0)`;
|
|
10423
|
+
this._updateScrollbar();
|
|
10424
|
+
}
|
|
10425
|
+
/**
|
|
10426
|
+
* 动画
|
|
10427
|
+
* @param timestamp 时间戳
|
|
10428
|
+
*/ _animate(timestamp = 0) {
|
|
10429
|
+
const clientHeight = this.$content.clientHeight;
|
|
10430
|
+
// 内容高度小于等于容器高度时,不进行滚动
|
|
10431
|
+
if (clientHeight <= this.$container.clientHeight) {
|
|
10432
|
+
return;
|
|
10480
10433
|
}
|
|
10481
|
-
this.
|
|
10482
|
-
|
|
10483
|
-
|
|
10484
|
-
|
|
10485
|
-
|
|
10486
|
-
|
|
10487
|
-
|
|
10488
|
-
|
|
10489
|
-
|
|
10490
|
-
|
|
10491
|
-
|
|
10492
|
-
|
|
10493
|
-
|
|
10494
|
-
|
|
10495
|
-
|
|
10496
|
-
|
|
10497
|
-
|
|
10498
|
-
|
|
10499
|
-
|
|
10500
|
-
|
|
10501
|
-
|
|
10502
|
-
|
|
10503
|
-
|
|
10504
|
-
this.
|
|
10505
|
-
|
|
10506
|
-
|
|
10507
|
-
|
|
10508
|
-
|
|
10509
|
-
|
|
10510
|
-
|
|
10511
|
-
|
|
10512
|
-
|
|
10513
|
-
|
|
10514
|
-
|
|
10515
|
-
} else {
|
|
10516
|
-
const height = this.$container.clientHeight;
|
|
10517
|
-
this._$itemContainer.style.cssText += `height: ${height}px`;
|
|
10434
|
+
if (!this._lastTimestamp) this._lastTimestamp = timestamp;
|
|
10435
|
+
const deltaTime = Math.min(timestamp - this._lastTimestamp, 100) / 16; // 限制最大时间增量
|
|
10436
|
+
this._lastTimestamp = timestamp;
|
|
10437
|
+
if (!this.isDragging) {
|
|
10438
|
+
// 惯性滚动
|
|
10439
|
+
this.velocity *= this._friction;
|
|
10440
|
+
this.currentY += this.velocity;
|
|
10441
|
+
// 弹性回弹
|
|
10442
|
+
const maxScroll = this.$content.scrollHeight - this.$container.clientHeight;
|
|
10443
|
+
if (this.currentY < 0) {
|
|
10444
|
+
// 顶部弹性
|
|
10445
|
+
this.velocity -= this.currentY * this._spring * deltaTime;
|
|
10446
|
+
} else if (this.currentY > maxScroll) {
|
|
10447
|
+
// 底部弹性
|
|
10448
|
+
this.velocity -= (this.currentY - maxScroll) * this._spring * deltaTime;
|
|
10449
|
+
}
|
|
10450
|
+
this._applyTransform();
|
|
10451
|
+
this._updateState();
|
|
10452
|
+
// 当速度足够小时停止动画
|
|
10453
|
+
if (Math.abs(this.velocity) < 0.1 && this.currentY >= 0 && this.currentY <= maxScroll) {
|
|
10454
|
+
this.velocity = 0;
|
|
10455
|
+
}
|
|
10456
|
+
}
|
|
10457
|
+
this._animationId = requestAnimationFrame(this._animate.bind(this));
|
|
10458
|
+
}
|
|
10459
|
+
/**
|
|
10460
|
+
* 更新滚动条
|
|
10461
|
+
*/ _updateScrollbar() {
|
|
10462
|
+
const containerHeight = this.$container.clientHeight;
|
|
10463
|
+
const contentHeight = this.$content.scrollHeight;
|
|
10464
|
+
const maxScroll = contentHeight - containerHeight;
|
|
10465
|
+
if (maxScroll <= 0) {
|
|
10466
|
+
if (this._$scrollbarThumb) this._$scrollbarThumb.style.height = '0';
|
|
10467
|
+
return;
|
|
10518
10468
|
}
|
|
10519
|
-
|
|
10520
|
-
|
|
10521
|
-
this.
|
|
10522
|
-
|
|
10523
|
-
|
|
10524
|
-
|
|
10525
|
-
_addEventListener() {
|
|
10526
|
-
// js安卓、IOS、鸿蒙系统监听开始触摸
|
|
10527
|
-
if (this._$itemContainer) {
|
|
10528
|
-
// 监听手动滚动时间轴时,停止时间轴滚动,时刻仍然变化
|
|
10529
|
-
this._$itemContainer.addEventListener('touchstart', this._touchstart, false);
|
|
10530
|
-
// 监听手动滚动时间轴时,停止时间轴滚动,时刻仍然变化
|
|
10531
|
-
this._$itemContainer.addEventListener('touchmove', this._touchmove, false);
|
|
10532
|
-
// 手动滚动停止,选定时刻自动播放
|
|
10533
|
-
this._$itemContainer.addEventListener('touchend', this._touchend, false);
|
|
10469
|
+
// 计算滚动条高度和位置
|
|
10470
|
+
const thumbHeight = Math.max(containerHeight / contentHeight * containerHeight, 20);
|
|
10471
|
+
const thumbPosition = this.currentY / maxScroll * (containerHeight - thumbHeight);
|
|
10472
|
+
if (this._$scrollbarThumb) {
|
|
10473
|
+
this._$scrollbarThumb.style.height = `${thumbHeight}px`;
|
|
10474
|
+
this._$scrollbarThumb.style.transform = `translateY(${thumbPosition}px)`;
|
|
10534
10475
|
}
|
|
10535
|
-
this._matchTimeDot();
|
|
10536
10476
|
}
|
|
10537
|
-
|
|
10538
|
-
|
|
10539
|
-
|
|
10540
|
-
|
|
10541
|
-
|
|
10542
|
-
this.
|
|
10543
|
-
|
|
10544
|
-
this._$itemContainer.removeEventListener('touchend', this._touchend);
|
|
10545
|
-
}
|
|
10546
|
-
}
|
|
10547
|
-
_touchstart() {
|
|
10548
|
-
if (this._readOnly) return false;
|
|
10549
|
-
this._isTouchStart = true;
|
|
10550
|
-
this.options.onDragStart == null ? void 0 : this.options.onDragStart.call(this.options, this.state.current);
|
|
10551
|
-
}
|
|
10552
|
-
_touchmove() {
|
|
10553
|
-
var _this__$itemContainer;
|
|
10554
|
-
if (this._readOnly) return false;
|
|
10555
|
-
const reactTop = (_this__$itemContainer = this._$itemContainer) == null ? void 0 : _this__$itemContainer.scrollTop; // 实际偏移高度
|
|
10556
|
-
this._rectTopToTime(reactTop);
|
|
10557
|
-
this.options.onDragging == null ? void 0 : this.options.onDragging.call(this.options, this.state.current);
|
|
10558
|
-
}
|
|
10559
|
-
_touchend() {
|
|
10560
|
-
if (this._readOnly) return false;
|
|
10561
|
-
// 这里有问题, 滚动是利用滚动操作(overflow-y: scroll;)的
|
|
10562
|
-
new Promise((resolve, _reject)=>{
|
|
10563
|
-
let preTop = -1;
|
|
10564
|
-
if (this._scrollTimer) {
|
|
10565
|
-
clearInterval(this._scrollTimer);
|
|
10566
|
-
this._scrollTimer = null;
|
|
10567
|
-
}
|
|
10568
|
-
this._scrollTimer = setInterval(()=>{
|
|
10569
|
-
var _this__$itemContainer;
|
|
10570
|
-
// debugger
|
|
10571
|
-
const reactTop = (_this__$itemContainer = this._$itemContainer) == null ? void 0 : _this__$itemContainer.scrollTop; // 实际偏移高度
|
|
10572
|
-
if (reactTop !== preTop) {
|
|
10573
|
-
preTop = reactTop;
|
|
10574
|
-
} else {
|
|
10575
|
-
if (this._scrollTimer) {
|
|
10576
|
-
clearInterval(this._scrollTimer);
|
|
10577
|
-
this._scrollTimer = null;
|
|
10578
|
-
}
|
|
10579
|
-
this._isTouchStart = false;
|
|
10580
|
-
resolve(reactTop);
|
|
10581
|
-
}
|
|
10582
|
-
}, 100);
|
|
10583
|
-
}).then((reactTop)=>{
|
|
10584
|
-
this._rectTopToTime(reactTop);
|
|
10585
|
-
this.options.onDragEnd == null ? void 0 : this.options.onDragEnd.call(this.options, this.state.current);
|
|
10586
|
-
this.options.onChange == null ? void 0 : this.options.onChange.call(this.options, this.state.current);
|
|
10477
|
+
/**
|
|
10478
|
+
* 更新统计信息
|
|
10479
|
+
*/ _updateState() {
|
|
10480
|
+
this.options.onChange == null ? void 0 : this.options.onChange.call(this.options, {
|
|
10481
|
+
x: 0,
|
|
10482
|
+
y: this.currentY,
|
|
10483
|
+
velocity: +this.velocity.toFixed(1)
|
|
10587
10484
|
});
|
|
10588
10485
|
}
|
|
10589
|
-
constructor(container, options){
|
|
10590
|
-
|
|
10591
|
-
|
|
10592
|
-
|
|
10593
|
-
|
|
10594
|
-
|
|
10595
|
-
|
|
10596
|
-
|
|
10597
|
-
|
|
10598
|
-
|
|
10599
|
-
|
|
10600
|
-
|
|
10601
|
-
|
|
10602
|
-
|
|
10603
|
-
|
|
10604
|
-
this.
|
|
10605
|
-
this.
|
|
10606
|
-
this.
|
|
10607
|
-
|
|
10608
|
-
this.
|
|
10609
|
-
this.
|
|
10486
|
+
constructor(container, options = {}){
|
|
10487
|
+
this._indicatorTimeout = null;
|
|
10488
|
+
/** 滚动条元素 */ this._$scrollbar = null;
|
|
10489
|
+
/** 滚动条指示器元素 */ this._$scrollbarThumb = null;
|
|
10490
|
+
/** 是否只读 */ this._readonly = false;
|
|
10491
|
+
this.$container = container;
|
|
10492
|
+
this.options = Object.assign({}, _$DRAG_SCROLL_DEFAULT_OPTIONS$_, options);
|
|
10493
|
+
this.$container.classList.add(_$DRAG_SCROLL_PREFIX_CLASSNAME$_, `${_$DRAG_SCROLL_PREFIX_CLASSNAME$_}-container`);
|
|
10494
|
+
this.$content = document.createElement('div');
|
|
10495
|
+
this.$content.classList.add(`${_$DRAG_SCROLL_PREFIX_CLASSNAME$_}-content`);
|
|
10496
|
+
this.innerHtml(this.options.content);
|
|
10497
|
+
this.$container.appendChild(this.$content);
|
|
10498
|
+
this.isDragging = false;
|
|
10499
|
+
this._startY = 0;
|
|
10500
|
+
this.currentY = 0;
|
|
10501
|
+
this.velocity = 0;
|
|
10502
|
+
this._animationId = null;
|
|
10503
|
+
this._lastTimestamp = 0;
|
|
10504
|
+
// 物理参数
|
|
10505
|
+
this._spring = 0.25; // 弹性系数
|
|
10506
|
+
this._friction = 0.92; // 摩擦力
|
|
10507
|
+
this._bounceDamping = 0.6; // 边界反弹阻尼
|
|
10508
|
+
this._maxVelocity = 30; // 最大速度限制
|
|
10509
|
+
if (!this.options.hideScrollbar) {
|
|
10510
|
+
this._renderScrollbar();
|
|
10511
|
+
}
|
|
10512
|
+
this._onMouseDown = this._onMouseDown.bind(this);
|
|
10513
|
+
this._onTouchMove = this._onTouchMove.bind(this);
|
|
10514
|
+
this._onMouseMove = this._onMouseMove.bind(this);
|
|
10515
|
+
this._onMouseUp = this._onMouseUp.bind(this);
|
|
10516
|
+
this.readonly = this.options.readonly;
|
|
10517
|
+
this._init();
|
|
10610
10518
|
}
|
|
10611
|
-
}
|
|
10519
|
+
}
|
|
10612
10520
|
|
|
10521
|
+
/*
|
|
10522
|
+
* @ezuikit/control-time-line v1.0.0
|
|
10523
|
+
* Copyright (c) 2025-11-03 Ezviz-OpenBiz
|
|
10524
|
+
* Released under the MIT License.
|
|
10525
|
+
*/
|
|
10526
|
+
var _$TIMELINE_LOCALES$_={zh:{title:"包含{{len}}段录像",foldTitle:"{{len}}个录像"},en:{title:"Includes {{len}} {{unit}}",foldTitle:"{{len}} {{unit}}"}};const _$BASE_TIME_LINE_DEFAULT_OPTIONS$_={current:new Date,language:"zh",timeSections:[],readOnly:false,className:"",timeWidth:0,width:"100%",
|
|
10527
|
+
// --------------------只支持初始化时,不支持动态变更 (不做对象冻结)--------------------
|
|
10528
|
+
timePointColor:"#1890ff",timeTextColor:"#FFF",timeScaleColor:"#FFF",timeSectionColor:"rgba(24, 144, 255, 0.5)",timeAxisBgColor:"#000",
|
|
10529
|
+
onChange:()=>{},onDragStart:()=>{},onDragging:()=>{},onDragEnd:()=>{},onDestroy:()=>{}};
|
|
10613
10530
|
/**
|
|
10614
|
-
*
|
|
10615
|
-
*
|
|
10616
|
-
*/
|
|
10617
|
-
* 时间刻度宽度, 需要满足 (24 * 60 * 60) % ([0] * [2]) = 0
|
|
10618
|
-
*/ const TIME_WIDTH = [
|
|
10619
|
-
[
|
|
10620
|
-
1,
|
|
10621
|
-
10,
|
|
10622
|
-
10,
|
|
10623
|
-
'单位 1秒'
|
|
10624
|
-
],
|
|
10625
|
-
[
|
|
10626
|
-
60,
|
|
10627
|
-
20,
|
|
10628
|
-
5,
|
|
10629
|
-
'单位 1分钟'
|
|
10630
|
-
],
|
|
10631
|
-
[
|
|
10632
|
-
600,
|
|
10633
|
-
20,
|
|
10634
|
-
6,
|
|
10635
|
-
'单位 10分钟'
|
|
10636
|
-
],
|
|
10637
|
-
[
|
|
10638
|
-
3600,
|
|
10639
|
-
30,
|
|
10640
|
-
6,
|
|
10641
|
-
'单位 1小时'
|
|
10642
|
-
],
|
|
10643
|
-
[
|
|
10644
|
-
14400,
|
|
10645
|
-
40,
|
|
10646
|
-
2,
|
|
10647
|
-
'单位 4小时'
|
|
10648
|
-
],
|
|
10649
|
-
[
|
|
10650
|
-
43200,
|
|
10651
|
-
80,
|
|
10652
|
-
2,
|
|
10653
|
-
'单位 12小时'
|
|
10654
|
-
]
|
|
10655
|
-
];
|
|
10656
|
-
|
|
10531
|
+
* 时间轴基类
|
|
10532
|
+
* @internal
|
|
10533
|
+
*/class BaseTimeLine{
|
|
10657
10534
|
/**
|
|
10658
|
-
|
|
10659
|
-
|
|
10660
|
-
|
|
10661
|
-
className: '',
|
|
10662
|
-
wrapClassName: '',
|
|
10663
|
-
timeSections: [],
|
|
10664
|
-
timeWidth: 0,
|
|
10665
|
-
currentTime: new Date(new Date().setHours(0, 0, 8, 0)),
|
|
10666
|
-
dpr: window.devicePixelRatio || 2,
|
|
10667
|
-
wheelSpeed: 0.1,
|
|
10668
|
-
readOnly: false,
|
|
10669
|
-
scaleOffsetTop: 4,
|
|
10670
|
-
showYearMonthDay: true,
|
|
10671
|
-
// --------------------只支持初始化时,不支持动态变更 (不做对象冻结)--------------------
|
|
10672
|
-
timePointColor: '#1890ff',
|
|
10673
|
-
timeTextColor: '#FFF',
|
|
10674
|
-
timeScaleColor: '#FFF',
|
|
10675
|
-
timeSectionColor: 'rgba(24, 144, 255, 0.5)',
|
|
10676
|
-
timeAxisBgColor: '#000',
|
|
10677
|
-
onChange: ()=>{},
|
|
10678
|
-
onDragEnd: ()=>{},
|
|
10679
|
-
onHover: ()=>{},
|
|
10680
|
-
onDestroy: ()=>{}
|
|
10681
|
-
};
|
|
10535
|
+
* 当前时间
|
|
10536
|
+
*/
|
|
10537
|
+
get current(){return this._current}
|
|
10682
10538
|
/**
|
|
10683
|
-
|
|
10684
|
-
|
|
10685
|
-
|
|
10686
|
-
|
|
10687
|
-
|
|
10688
|
-
|
|
10689
|
-
|
|
10690
|
-
|
|
10691
|
-
|
|
10692
|
-
*
|
|
10693
|
-
|
|
10694
|
-
this._$canvas = document.createElement('canvas');
|
|
10695
|
-
this._ctx = this._$canvas.getContext('2d');
|
|
10696
|
-
if (this._options.className) {
|
|
10697
|
-
this._$canvas.className = this._options.className;
|
|
10698
|
-
}
|
|
10699
|
-
this._$canvas.style.cssText += 'cursor: pointer;';
|
|
10700
|
-
this.width = this._options.width || this.$container.offsetWidth;
|
|
10701
|
-
this.height = this._options.height || this.$container.offsetHeight;
|
|
10702
|
-
if (this._options.wrapClassName) this.$container.classList.add(this._options.wrapClassName);
|
|
10703
|
-
this.$container.appendChild(this._$canvas);
|
|
10704
|
-
this._addEventListener();
|
|
10705
|
-
this.setReadOnly(this._options.readOnly);
|
|
10706
|
-
this._update({
|
|
10707
|
-
currentTime: this._options.currentTime,
|
|
10708
|
-
timeWidth: this._options.timeWidth,
|
|
10709
|
-
timeSections: this._options.timeSections
|
|
10710
|
-
});
|
|
10711
|
-
}
|
|
10712
|
-
/**
|
|
10713
|
-
* 获取当前时间
|
|
10539
|
+
* 当前时间
|
|
10540
|
+
*/set current(current){this._current=current;}set readOnly(readOnly){if(this._readOnly!==readOnly){this._readOnly=readOnly;this.$container.style.cursor=readOnly?"not-allowed":"pointer";}}
|
|
10541
|
+
/**
|
|
10542
|
+
* 只读状态
|
|
10543
|
+
*/get readOnly(){return this._readOnly}
|
|
10544
|
+
/**
|
|
10545
|
+
* 时间片段
|
|
10546
|
+
*/get timeSections(){return this._timeSections}
|
|
10547
|
+
/**
|
|
10548
|
+
* 设置只读或取消只读, 推荐使用 timeLine.readOnly = false
|
|
10549
|
+
* @param readOnly - 只读或取消只读
|
|
10714
10550
|
* @returns
|
|
10715
|
-
*/
|
|
10716
|
-
|
|
10717
|
-
|
|
10718
|
-
|
|
10719
|
-
|
|
10720
|
-
|
|
10721
|
-
|
|
10722
|
-
|
|
10723
|
-
|
|
10724
|
-
|
|
10725
|
-
/**
|
|
10551
|
+
*/setReadOnly(readOnly){this.readOnly=readOnly;}
|
|
10552
|
+
/**
|
|
10553
|
+
* 更新当前时间
|
|
10554
|
+
* @param current 能转成时间的值, 如 时间对象 Date, 时间戳,时间戳字符串
|
|
10555
|
+
*/update(current){this._current=current;}
|
|
10556
|
+
/**
|
|
10557
|
+
* 更新时间片段
|
|
10558
|
+
* @param timeSections 片段数据
|
|
10559
|
+
*/updateTimeSections(timeSections){if(timeSections&&Array.isArray(timeSections))this._timeSections=timeSections;}
|
|
10560
|
+
/**
|
|
10726
10561
|
* 获取 TimeLine 的宽度
|
|
10727
10562
|
* @returns
|
|
10728
|
-
*/
|
|
10729
|
-
|
|
10730
|
-
}
|
|
10731
|
-
set width(width) {
|
|
10732
|
-
if (this._$canvas && width) {
|
|
10733
|
-
width = Math.floor(width);
|
|
10734
|
-
this._$canvas.width = width * this._options.dpr;
|
|
10735
|
-
this._$canvas.style.cssText += `width: ${width}px;`;
|
|
10736
|
-
this.$container.style.width = width + 'px';
|
|
10737
|
-
this._width = width;
|
|
10738
|
-
this._update();
|
|
10739
|
-
}
|
|
10740
|
-
}
|
|
10741
|
-
/**
|
|
10563
|
+
*/get width(){return this._width}
|
|
10564
|
+
/**
|
|
10742
10565
|
* 获取 TimeLine 的高度
|
|
10566
|
+
*/get height(){return this._height}
|
|
10567
|
+
/**
|
|
10568
|
+
* 重置尺寸
|
|
10569
|
+
*/resize(width,height){this._resize(width,height);}_resize(width,height){let cssText="";if(/\d/.test(width+""))cssText+=`width: ${width}px;`;else if(width)cssText+=`width: ${width};`;if(/\d/.test(height+""))cssText+=`height: ${height}px;`;else if(height)cssText+=`height: ${height};`;if(this.$container)this.$container.style.cssText+=cssText;this._width=Math.floor(this.$container.clientWidth);this._height=Math.floor(this.$container.clientHeight);}get timeWidth(){return this._timeWidth}
|
|
10570
|
+
/**
|
|
10571
|
+
* 改变时间轴刻度
|
|
10572
|
+
* 移动端间距: 0:1分钟,1:10分钟,2:半小时,3:1小时,4:2小时, 5:4小时
|
|
10573
|
+
* PC间距:
|
|
10574
|
+
* @param timeWidth 时间轴刻度
|
|
10575
|
+
*/setTimeWidth(timeWidth){if([0,1,2,3,4,5].includes(timeWidth))this._timeWidth=timeWidth;}
|
|
10576
|
+
/**
|
|
10577
|
+
* 销毁
|
|
10578
|
+
*/destroy(){
|
|
10579
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
10580
|
+
this._current=null;this.options.onDestroy==null?void 0:this.options.onDestroy.call(this.options);this._timeSections=[];this._readOnly=false;this._destroyed=true;}constructor(container,options){this._current=new Date;
|
|
10581
|
+
/** 只读 */this._readOnly=false;this._width=0;this._height=0;this._destroyed=false;this._timeWidth=0;
|
|
10582
|
+
/** 片段列表 */this._timeSections=[];this.$container=container;this.options=deepmerge(_$BASE_TIME_LINE_DEFAULT_OPTIONS$_,options,{clone:false});if(this.options.timeSections&&Array.isArray(this.options.timeSections))this._timeSections=this.options.timeSections;if(this.options.readOnly)this.readOnly=this.options.readOnly;if(this.options.className)this.$container.classList.add(this.options.className);if(this.options.current&&this.options.current instanceof Date)this._current=this.options.current||new Date;
|
|
10583
|
+
// prettier-ignore
|
|
10584
|
+
this.i18n=new I18n(deepmerge(_$TIMELINE_LOCALES$_,this.options.locales||{},{clone:false}),{defaultLocale:this.options.language||"zh"});this._timeWidth=this.options.timeWidth||0;this._resize(this.options.width||"100%",this.options.height);}}
|
|
10585
|
+
/** 语言包 */BaseTimeLine.LOCALES=_$TIMELINE_LOCALES$_;
|
|
10586
|
+
/**
|
|
10587
|
+
* 时间轴工具类
|
|
10588
|
+
*/class TimeLineUtil{
|
|
10589
|
+
/**
|
|
10590
|
+
* 时间转成日期
|
|
10591
|
+
* @param time 时间 (秒, 毫秒, 日期字符串, Date)
|
|
10592
|
+
* @returns 日期
|
|
10593
|
+
*/
|
|
10594
|
+
static toDate(time){let date=null;if(typeof time==="string"&&time.includes(":"))date=new Date(time);else if((typeof time==="string"||typeof time==="number")&&/\d/.test(time+"")&&(time+"").length===10)date=new Date(+time*1e3);else if((typeof time==="string"||typeof time==="number")&&/\d/.test(time+"")&&(time+"").length===13)date=new Date(+time);else if(time instanceof Date)date=time;return date}
|
|
10595
|
+
/**
|
|
10596
|
+
* 时间转成 HH:mm:ss
|
|
10597
|
+
* @param time 时间
|
|
10743
10598
|
* @returns
|
|
10744
|
-
*/
|
|
10745
|
-
|
|
10746
|
-
|
|
10747
|
-
|
|
10748
|
-
|
|
10749
|
-
|
|
10750
|
-
|
|
10751
|
-
|
|
10752
|
-
|
|
10753
|
-
|
|
10754
|
-
|
|
10755
|
-
|
|
10756
|
-
|
|
10757
|
-
/**
|
|
10758
|
-
* 设置时间轴刻度宽度
|
|
10759
|
-
* @param timeWidth - 时间轴刻度宽度 [0, TIME_WIDTH.length - 1]
|
|
10599
|
+
*/static formatDateToHHmmss(time){const date=TimeLineUtil.toDate(time);if(date){const h=date.getHours();// 返回日期中的小时数(0到23)
|
|
10600
|
+
const m=date.getMinutes();// 返回日期中的分钟数(0到59)
|
|
10601
|
+
const s=date.getSeconds();// 返回日期中的秒数(0到59)
|
|
10602
|
+
return (h>9?h:"0"+h)+":"+(m>9?m:"0"+m)+":"+(s>9?s:"0"+s)}return "00:00:00"}
|
|
10603
|
+
/**
|
|
10604
|
+
* 十位补充 0
|
|
10605
|
+
* @param m 数字
|
|
10606
|
+
* @returns 十位补充 0后的结果字符串
|
|
10607
|
+
*/static subTime(m){return +m>9?m+"":"0"+m}
|
|
10608
|
+
/**
|
|
10609
|
+
* 格式化时间, 支持 'YYYY-MM-DD','YYYY-MM-DD HH:mm:ss', 'HH:mm:ss'
|
|
10610
|
+
* @param time 时间
|
|
10611
|
+
* @param fmt 时间格式
|
|
10760
10612
|
* @returns
|
|
10761
|
-
*/
|
|
10762
|
-
|
|
10763
|
-
|
|
10764
|
-
|
|
10765
|
-
|
|
10766
|
-
|
|
10767
|
-
|
|
10768
|
-
|
|
10769
|
-
|
|
10613
|
+
*/static tranTime(time,fmt="YYYY-MM-DD HH:mm:ss"){const newDate=TimeLineUtil.toDate(time);if(newDate){if(fmt==="YYYY-MM-DD")return newDate.getFullYear()+"-"+TimeLineUtil.subTime(newDate.getMonth()+1)+"-"+TimeLineUtil.subTime(newDate.getDate());else if(fmt==="HH:mm:ss")return TimeLineUtil.subTime(newDate.getHours())+":"+TimeLineUtil.subTime(newDate.getMinutes())+":"+TimeLineUtil.subTime(newDate.getSeconds());else if(fmt==="HH")return TimeLineUtil.subTime(newDate.getHours());else if(fmt==="mm:ss")return TimeLineUtil.subTime(newDate.getMinutes())+":"+TimeLineUtil.subTime(newDate.getSeconds());else if(fmt==="HH:mm")return TimeLineUtil.subTime(newDate.getHours())+":"+TimeLineUtil.subTime(newDate.getMinutes());else if(fmt==="YYYYMMDDTHHmmssZ")return newDate.getFullYear()+""+TimeLineUtil.subTime(newDate.getMonth()+1)+TimeLineUtil.subTime(newDate.getDate())+"T"+TimeLineUtil.subTime(newDate.getHours())+TimeLineUtil.subTime(newDate.getMinutes())+TimeLineUtil.subTime(newDate.getSeconds())+"Z";
|
|
10614
|
+
// prettier-ignore
|
|
10615
|
+
return newDate.getFullYear()+"-"+TimeLineUtil.subTime(newDate.getMonth()+1)+"-"+TimeLineUtil.subTime(newDate.getDate())+" "+TimeLineUtil.subTime(newDate.getHours())+":"+TimeLineUtil.subTime(newDate.getMinutes())+":"+TimeLineUtil.subTime(newDate.getSeconds())}return ""}
|
|
10616
|
+
/**
|
|
10617
|
+
* 时间转成秒
|
|
10618
|
+
* @param time
|
|
10619
|
+
* @returns
|
|
10620
|
+
*/static timeToSecond(time){const e=time.split(":");const h=Number(e[0]);const m=Number(e[1]);const s=Number(e[2]);return h*60*60+m*60+(s||0)}
|
|
10621
|
+
/**
|
|
10622
|
+
* 分钟转成 HH:mm
|
|
10623
|
+
* @param minute
|
|
10624
|
+
* @returns
|
|
10625
|
+
*/static minuteToTime(minute){const hour=Math.floor(minute/60);const m=minute%60;return (hour>9?hour:"0"+hour)+":"+(m>9?m:"0"+m)}
|
|
10626
|
+
/**
|
|
10627
|
+
* 时间转成分钟
|
|
10628
|
+
* @param time
|
|
10629
|
+
* @returns
|
|
10630
|
+
*/static timeToMinute(time){const e=time.split(":");const h=Number(e[0]);const m=Number(e[1]);
|
|
10631
|
+
// const s = Number(e[2]);
|
|
10632
|
+
return h*60+m}
|
|
10633
|
+
/**
|
|
10634
|
+
* @description 判读两个区间是否重叠
|
|
10635
|
+
* @param {number} a_start 一个区间的开始
|
|
10636
|
+
* @param {number} a_end 一个区间的结束
|
|
10637
|
+
* @param {number} b_start 另一个区间的开始
|
|
10638
|
+
* @param {number} b_end 另一个区间的结束
|
|
10639
|
+
* @returns {boolean}
|
|
10640
|
+
*/static isOverlap(a_start,a_end,b_start,b_end){return Math.max(a_start,b_start)<=Math.min(a_end,b_end)}static tranTimeToString(start,end){var _TimeLineUtil_toDate,_TimeLineUtil_toDate1;const secondNum=Math.floor(((_TimeLineUtil_toDate=TimeLineUtil.toDate(end))==null?void 0:_TimeLineUtil_toDate.getTime())-((_TimeLineUtil_toDate1=TimeLineUtil.toDate(start))==null?void 0:_TimeLineUtil_toDate1.getTime()))/1e3;const second=secondNum%60;const minute=Math.floor(secondNum/60);return `${minute>0?TimeLineUtil.subTime(minute)+"'":"0'"}${TimeLineUtil.subTime(second)}''`}}
|
|
10641
|
+
/**
|
|
10642
|
+
* 时间轴图标集
|
|
10643
|
+
*/const _$TIMELINE_ICONS$_={tip:`<svg viewBox="0 0 57 24" fill="currentColor" width="1em" height="1em" focusable="false" aria-hidden="true" data-icon="tip">\n <path class="ez-time-line-icon-tip" fill-rule="evenodd" d="m4,0l44,0c2.2091,0 4,1.7909 4,4l0,3.8218l4.9399,3.3572c0.5839,0.3968 0.5839,1.2574 0,1.6542l-4.9399,3.3572l0,3.8096c0,2.2091 -1.7909,4 -4,4l-44,0c-2.2091,0 -4,-1.7909 -4,-4l0,-16c0,-2.2091 1.7909,-4 4,-4z"/>\n </svg>`,plus:`\n <svg viewBox="0 0 16 16" fill="currentColor" width="1em" height="1em" focusable="false" aria-hidden="true" data-icon="plus">\n <path d="M0 0L10.6667 0" stroke="rgb(44,44,44)" stroke-linecap="round" stroke-width="1.5" transform="matrix(0,1,-1,0,8,2.66663)"/>\n <path d="M2.66669 8L13.3334 8" stroke="rgb(44,44,44)" stroke-linecap="round" stroke-width="1.5"/>\n </svg>\n `,minus:`\n <svg viewBox="0 0 16 16" fill="currentColor" width="1em" height="1em" focusable="false" aria-hidden="true" data-icon="minus">\n <path d="M2.66669 8L13.3334 8" stroke="rgb(44,44,44)" stroke-linecap="round" stroke-width="1.5"/>\n </svg>\n `,close:`\n <svg viewBox="0 0 24 24" fill="none" width="1em" height="1em" stroke="currentColor" focusable="false" aria-hidden="true" data-icon="close">\n\t <path d="M0 0L15.9998 0" stroke-linecap="round" stroke-width="1.5" transform="matrix(0.707099,0.707114,-0.707114,0.707099,6.34277,6.34326)" />\n\t\t <path d="M0 0L15.9998 0" stroke-linecap="round" stroke-width="1.5" transform="matrix(0.707099,-0.707114,0.707114,0.707099,6.34277,17.6567)" />\n </svg>\n `,pause:`<svg viewBox="0 0 20 20" fill="currentColor" width="1em" height="1em" focusable="false" aria-hidden="true" data-icon="pause">\n\t\t <path d="M9.43914 2.47881L13.4688 8.4912C14.3594 9.81998 13.4071 11.6047 11.8074 11.6047L3.74811 11.6047C2.14849 11.6047 1.19616 9.81998 2.08675 8.4912L6.11641 2.47881C6.90863 1.2968 8.64693 1.2968 9.43914 2.47881Z" fill-rule="evenodd" transform="matrix(0,1,-1,0,16.5781,2.22229)" />\n </svg>\n `,picture:`\n <svg viewBox="0 0 19.1613 19.4583" fill="currentColor" width="1em" height="1em" focusable="false" aria-hidden="true" data-icon="picture">\n <path xmlns="http://www.w3.org/2000/svg" id="形状结合" d="M15.3276 2.63477L3.83173 2.63477C2.70848 2.63477 1.79541 3.55027 1.79541 4.68419L1.79541 14.7737C1.79541 15.9076 2.70848 16.8231 3.83173 16.8231L15.3276 16.8231C16.4504 16.8231 17.364 15.9074 17.364 14.7737L17.364 4.68419C17.364 3.55027 16.4509 2.63477 15.3276 2.63477ZM3.83247 3.851L15.3284 3.851C15.7936 3.851 16.1671 4.22551 16.1671 4.68429L16.1671 14.7738C16.1671 15.2323 15.7932 15.6071 15.3284 15.6071L3.83247 15.6071C3.36725 15.6071 2.99373 15.2326 2.99373 14.7738L2.99373 12.2622L6.7356 9.56381L6.78139 9.53916C6.84532 9.51493 6.91856 9.52524 6.9742 9.56947L13.2644 14.5698L13.3381 14.62C13.5918 14.7666 13.9197 14.7063 14.105 14.4658C14.3089 14.2014 14.263 13.8192 14.0026 13.6122L7.71239 8.61184L7.60526 8.5346C7.12945 8.22451 6.51026 8.23473 6.04222 8.57224L2.99373 10.7706L2.99373 4.68429C2.99373 4.22551 3.36725 3.851 3.83247 3.851ZM10.5794 7.29679C10.5794 6.06542 11.5624 5.0672 12.7749 5.0672C13.9875 5.0672 14.9705 6.06542 14.9705 7.29679C14.9705 8.52817 13.9875 9.52639 12.7749 9.52639C11.5624 9.52639 10.5794 8.52817 10.5794 7.29679ZM13.7722 7.2967C13.7722 6.73699 13.3254 6.28325 12.7742 6.28325C12.223 6.28325 11.7762 6.73699 11.7762 7.2967C11.7762 7.85642 12.223 8.31015 12.7742 8.31015C13.3254 8.31015 13.7722 7.85642 13.7722 7.2967Z" fill-rule="evenodd"/>\n </svg>\n `};
|
|
10644
|
+
/**
|
|
10645
|
+
* 时间刻度宽度 [刻度间隔秒数s, 刻度间隔宽度px, 长刻度间隔短刻度个数, 说明]
|
|
10646
|
+
* 需要满足 (24 * 60 * 60) % ([0] * [2]) = 0, 这样 0 点刻度才能正确显示
|
|
10647
|
+
*/
|
|
10648
|
+
/**
|
|
10649
|
+
* 时间刻度宽度, 需要满足 (24 * 60 * 60) % ([0] * [2]) = 0
|
|
10650
|
+
*/const TIME_WIDTH=[[1,10,10,"单位 1秒"],[60,20,5,"单位 1分钟"],[600,20,6,"单位 10分钟"],[3600,30,6,"单位 1小时"],[14400,40,2,"单位 4小时"],[43200,80,2,"单位 12小时"]];
|
|
10651
|
+
/**
|
|
10652
|
+
* 时间刻度宽度, 需要满足 (24 * 60 * 60) % ([0] * [2]) = 0
|
|
10653
|
+
* // * 0: 1分钟,
|
|
10654
|
+
// * 1: 10分钟
|
|
10655
|
+
// * 2: 半小时
|
|
10656
|
+
// * 3: 1小时
|
|
10657
|
+
// * 4: 2小时
|
|
10658
|
+
// * 5: 4小时
|
|
10659
|
+
*/const MOBILE_TIME_WIDTH=[[1,10,10,"单位 1分钟"],[10,20,5,"单位 10分钟"],[30,20,6,"单位 30分钟"],[60,30,6,"单位 1小时"],[120,40,2,"单位 2小时"],[240,80,2,"单位 4小时"]];
|
|
10660
|
+
/* eslint-disable @typescript-eslint/no-non-null-assertion */ /* eslint-disable eqeqeq */ /* eslint-disable no-unneeded-ternary */ /* eslint-disable @typescript-eslint/no-this-alias */ /* eslint-disable @typescript-eslint/prefer-includes */function _extends$1$1(){_extends$1$1=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source)if(Object.prototype.hasOwnProperty.call(source,key))target[key]=source[key];}return target};return _extends$1$1.apply(this,arguments)}
|
|
10661
|
+
/**
|
|
10662
|
+
* 时间轴样式类前缀
|
|
10663
|
+
*/const _$MOBILE_TIMELINE_PREFIX$_="ez-time-line";const _$MOBILE_TIME_LINE_DEFAULT_OPTIONS$_=Object.assign({},_$BASE_TIME_LINE_DEFAULT_OPTIONS$_,{height:400,width:"100%",timeWidth:0,readOnly:false,timePointColor:"#648FFC",timeTextColor:"#666666",timeScaleColor:"transparent",timeSectionColor:"#369FFF",timeAxisBgColor:"#BDCDFF",
|
|
10664
|
+
/** 当前时间背景颜色 */currentTimeBgColor:"#648FFC",
|
|
10665
|
+
/** 当前时间颜色 */currentTimeColor:"#FFFFFF",showTimeWidthBtn:true});const _$DAY_TIME_SECOND$_=60*60*24;// 一天的秒数
|
|
10666
|
+
class MobileTimeLine extends BaseTimeLine{
|
|
10667
|
+
/**
|
|
10668
|
+
* 设置只读或取消只读
|
|
10669
|
+
* @param readOnly - 只读或取消只读
|
|
10670
|
+
* @returns
|
|
10671
|
+
*/
|
|
10672
|
+
setReadOnly(readOnly){super.setReadOnly(readOnly);if(this._dragScroll)this._dragScroll.readonly=readOnly;}
|
|
10673
|
+
/**
|
|
10674
|
+
* 改变时间轴刻度
|
|
10675
|
+
* 0: 1分钟,
|
|
10676
|
+
* 1: 10分钟
|
|
10677
|
+
* 2: 半小时
|
|
10678
|
+
* 3: 1小时
|
|
10679
|
+
* 4: 2小时
|
|
10680
|
+
* @param timeWidth // 120: 2小时, 60:1小时, 30:半小时,10:10分钟,1:1分钟
|
|
10681
|
+
*/setTimeWidth(timeWidth){if(MOBILE_TIME_WIDTH[timeWidth]){super.setTimeWidth(timeWidth);this._matchTimeDot();}else console.warn(`scale ${timeWidth} not exist!`);}
|
|
10682
|
+
/**
|
|
10683
|
+
* 获取真实时间刻度(时间单位 分钟)
|
|
10684
|
+
*/get _scaleWidth(){return (MOBILE_TIME_WIDTH[this.timeWidth]||MOBILE_TIME_WIDTH[0])[0]}
|
|
10685
|
+
/**
|
|
10686
|
+
* 更新片段数组
|
|
10687
|
+
* @param timeSections
|
|
10688
|
+
* @param defaultIndex
|
|
10689
|
+
*/updateTimeSections(timeSections,defaultIndex){super.updateTimeSections(timeSections);const list=timeSections.map(record=>_extends$1$1({},record,{startTime:TimeLineUtil.formatDateToHHmmss(record.startTime),endTime:TimeLineUtil.formatDateToHHmmss(record.endTime)}));if(list.length>0){if(typeof defaultIndex==="undefined")defaultIndex=list.length-1;// 默认选中最后一个片段位置
|
|
10690
|
+
// 若current不为 null,则不重置current,避免拖动后时间轴回弹
|
|
10691
|
+
const{current:current}=this.state;this._setState({availTimeLine:list,start:list[defaultIndex].startTime,end:list[defaultIndex].endTime,current:current===null?list[defaultIndex].startTime:current});this._matchTimeDot();}else {this._setState({availTimeLine:[]});this._matchTimeDot();}}
|
|
10692
|
+
/**
|
|
10693
|
+
* 更新当前时间
|
|
10694
|
+
* @param time 能转成时间的值, 如 时间对象 Date, 时间戳,时间戳字符串
|
|
10695
|
+
*/update(time){var _this__dragScroll;if(time&&!((_this__dragScroll=this._dragScroll)==null?void 0:_this__dragScroll.isDragging)){this._setState({current:TimeLineUtil.tranTime(time,"HH:mm:ss")});this._currentOffsetH();}}
|
|
10696
|
+
/**
|
|
10697
|
+
* 销毁
|
|
10698
|
+
*/destroy(){var _this__dragScroll;if(this._scrollTimer){clearInterval(this._scrollTimer);this._scrollTimer=null;}if(this._$currentTime)try{this.$container.removeChild(this._$currentTime);this._$currentTime=null;}catch(error){}if(this._$itemList)this._imageRemoveErrorEvent(this._$itemList.querySelectorAll(`img.${_$MOBILE_TIMELINE_PREFIX$_}-img`)||[]);if(this._$itemContainer&&this._$itemList)try{this._$itemContainer.removeChild(this._$itemList);this._$itemList=null;}catch(error){}if(this._$itemContainer)try{this.$container.removeChild(this._$itemContainer);this._$itemContainer=null;}catch(error){}if(this._$op)try{this.$container.removeChild(this._$op);this._$op=null;}catch(error){}if(this._picker){var _this__picker_$body_querySelectorAll,_this__picker_$body;this._imageRemoveErrorEvent(((_this__picker_$body=this._picker.$body)==null?void 0:(_this__picker_$body_querySelectorAll=_this__picker_$body.querySelectorAll)==null?void 0:_this__picker_$body_querySelectorAll.call(_this__picker_$body,"img"))||[]);this._picker.destroy();this._picker=null;}this._removeEventListener();(_this__dragScroll=this._dragScroll)==null?void 0:_this__dragScroll.destroy();this._dragScroll=null;super.destroy();}
|
|
10699
|
+
/**
|
|
10700
|
+
* 更新状态
|
|
10701
|
+
* @param obj
|
|
10702
|
+
*/_setState(obj){
|
|
10703
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
10704
|
+
Object.keys(obj).forEach(key=>{if(key==="current"&&obj[key]){var _this__dragScroll;this._setCurrentDOM(obj[key]);if(this.state.current!==obj[key]&&!((_this__dragScroll=this._dragScroll)==null?void 0:_this__dragScroll.isDragging)){var _this_timeSections_;this.state[key]=obj[key];this.current=new Date(TimeLineUtil.tranTime((_this_timeSections_=this.timeSections[0])==null?void 0:_this_timeSections_.endTime,"YYYY-MM-DD")+" "+obj[key]);this.options.onChange==null?void 0:this.options.onChange.call(this.options,this.current);}}else this.state[key]=obj[key];});}_setCurrentDOM(time){if(this._$currentTime)this._$currentTime.querySelector(`.${_$MOBILE_TIMELINE_PREFIX$_}-current-value`).innerHTML=time;}
|
|
10705
|
+
/**
|
|
10706
|
+
* 渲染时间轴刻度数组
|
|
10707
|
+
*/_matchTimeDot(){const scaleWidth=this._scaleWidth;// 时间单位 分钟
|
|
10708
|
+
const timeArr=[];
|
|
10709
|
+
// 时间转分钟
|
|
10710
|
+
let minute=TimeLineUtil.timeToMinute("24:00:00");minute=Math.floor(minute/scaleWidth)*scaleWidth;for(let i=minute;i>=0;){let marginTop=0;let marginBottom=0;
|
|
10711
|
+
// 视频片段
|
|
10712
|
+
if(i==minute)marginTop=70;if(i==0)marginBottom=this.$container.clientHeight-70;const time=TimeLineUtil.minuteToTime(i);timeArr.push({id:i,current:time,label:"a"+i,marginTop:marginTop,marginBottom:marginBottom,recArr:[],coverArr:this._filterTimeSectionsByTime(time)});i-=scaleWidth;}this._setState({timeArr:timeArr});this._matchRecTimeDot();}_matchRecTimeDot(){const{availTimeLine:availTimeLine,timeArr:timeArr}=this.state;const scaleWidth=this._scaleWidth;const len=availTimeLine.length;if(len===0)for(let j=0;j<timeArr.length;j++)timeArr[j].recArr=[];else {for(let k=0;k<timeArr.length;k++)timeArr[k].recArr=[];for(let i=0;i<len;i++){const temp=availTimeLine[i];const st=TimeLineUtil.timeToSecond(temp.startTime);// "00:01:00" -> 60 // 秒
|
|
10713
|
+
const et=TimeLineUtil.timeToSecond(temp.endTime);let stAvailPercent=0;let etAvailPercent=0;const stMinute=Math.floor(st/(scaleWidth*60))*scaleWidth;stAvailPercent=(st-stMinute*60)/scaleWidth;const etMinute=Math.floor(et/(scaleWidth*60))*scaleWidth;etAvailPercent=(et-etMinute*60)/scaleWidth;for(let j=0;j<timeArr.length;j++)if(timeArr[j].id==stMinute&&timeArr[j].id==etMinute){const height=etAvailPercent-stAvailPercent;const top=60-etAvailPercent;
|
|
10714
|
+
// prettier-ignore
|
|
10715
|
+
timeArr[j].recArr.push({height:height,top:top});}else if(timeArr[j].id==stMinute)timeArr[j].recArr.push({height:60-stAvailPercent,top:0});else if(timeArr[j].id==etMinute)timeArr[j].recArr.push({height:etAvailPercent,top:60-etAvailPercent});else if(timeArr[j].id>stMinute&&timeArr[j].id<etMinute)timeArr[j].recArr.push({height:60,top:0});}}this._setState({timeArr:timeArr});this._renderDateLine();}_renderDateLine(){const{timeArr:timeArr}=this.state;const container=this._$itemList;
|
|
10716
|
+
// 清理上一次的error 事件
|
|
10717
|
+
this._imageRemoveErrorEvent(container.querySelectorAll(`img.${_$MOBILE_TIMELINE_PREFIX$_}-img`)||[]);container.innerHTML="";timeArr.forEach((item,index)=>{const timeItemDOM=document.createElement("div");timeItemDOM.setAttribute("class",_$MOBILE_TIMELINE_PREFIX$_+"-time-scale-area");if(item.marginTop)timeItemDOM.style.cssText+=`margin-top: ${item.marginTop}px;`;if(item.marginBottom)timeItemDOM.style.cssText+=`margin-bottom: ${item.marginBottom}px;`;timeItemDOM.style.cssText+=`border-right-color: ${this.options.timeAxisBgColor||"rgba(189, 205, 255, 1)"};`;timeItemDOM.setAttribute("data-time",item.current);timeItemDOM.setAttribute("data-index",index+"");const scaleDOM=document.createElement("div");scaleDOM.setAttribute("class",_$MOBILE_TIMELINE_PREFIX$_+"-scale");let timeItemHtml=``;if(item.coverArr.length)timeItemHtml+=`\n <div class="${_$MOBILE_TIMELINE_PREFIX$_}-time-cover-fold ${item.coverArr.length>1?`${_$MOBILE_TIMELINE_PREFIX$_}-time-cover-fold-multiple`:""}"\n data-start="${item.current}">\n ${item.coverArr.length>1?`<div class="${_$MOBILE_TIMELINE_PREFIX$_}-cover-fold-placeholder" style="color: #FFF"></div>`:""}\n <div class="${_$MOBILE_TIMELINE_PREFIX$_}-time-cover-fold-img">\n <img src="${this._setImageScr(item.coverArr[0].coverPic)}" class="${_$MOBILE_TIMELINE_PREFIX$_}-img"/>\n <span class="${_$MOBILE_TIMELINE_PREFIX$_}-time-cover-fold-len">\n ${item.coverArr.length>1?this.i18n.t("foldTitle",{len:item.coverArr.length,unit:"videos"}):`${TimeLineUtil.tranTime(item.coverArr[0].startTime,"HH:mm")}`}\n </span>\n ${item.coverArr.length===1?`<span class="${_$MOBILE_TIMELINE_PREFIX$_}-time-cover-fold-time">${TimeLineUtil.tranTimeToString(item.coverArr[0].startTime,item.coverArr[0].endTime)}</span>`:""}\n <span class="${_$MOBILE_TIMELINE_PREFIX$_}-time-cover-fold-pause">${_$TIMELINE_ICONS$_.pause}</span>\n </div>\n </div>`;
|
|
10718
|
+
// 六个详细刻度
|
|
10719
|
+
// <div class="${_$MOBILE_TIMELINE_PREFIX$_}-time-scale"></div>
|
|
10720
|
+
// <div class="${_$MOBILE_TIMELINE_PREFIX$_}-time-scale"></div>
|
|
10721
|
+
// <div class="${_$MOBILE_TIMELINE_PREFIX$_}-time-scale"></div>
|
|
10722
|
+
// <div class="${_$MOBILE_TIMELINE_PREFIX$_}-time-scale"></div>
|
|
10723
|
+
// <div class="${_$MOBILE_TIMELINE_PREFIX$_}-time-scale"></div>
|
|
10724
|
+
// <div class="${_$MOBILE_TIMELINE_PREFIX$_}-time-scale" style="width:10px"></div>
|
|
10725
|
+
item.recArr.forEach(i=>{timeItemHtml+=`<div class="${_$MOBILE_TIMELINE_PREFIX$_}-time-unavail"\n style="height: ${i.height}px;background-color:${this.options.timeSectionColor||"#369FFF"}; top: ${i.top}px">\n </div>`;});timeItemHtml+=`<div id=${item.label} class="${_$MOBILE_TIMELINE_PREFIX$_}-time-label" style="color: ${this.options.timeTextColor||"#666"}">${item.current}</div>`;timeItemDOM.innerHTML=timeItemHtml;container.appendChild(timeItemDOM);this._imageErrorEvent(container.querySelectorAll(`img.${_$MOBILE_TIMELINE_PREFIX$_}-img`)||[]);});this._currentOffsetH();}_currentOffsetH(){const{current:current}=this.state;if(current){var _this__dragScroll;const currentSecond=TimeLineUtil.timeToSecond(current);const daySecond=24*3600;// 一天的秒数
|
|
10726
|
+
const y=(daySecond-currentSecond||0)/this._scaleWidth;(_this__dragScroll=this._dragScroll)==null?void 0:_this__dragScroll.scrollToY(y+60,false);}}_render(){this._$currentTime=document.createElement("div");this._$currentTime.classList.add(_$MOBILE_TIMELINE_PREFIX$_+"-current");this._$currentTime.innerHTML=`<div class="${_$MOBILE_TIMELINE_PREFIX$_}-current-content" style="color: ${this.options.currentTimeBgColor||"#648FFC"}">\n <span class="${_$MOBILE_TIMELINE_PREFIX$_}-current-tip">${_$TIMELINE_ICONS$_.tip}</span>\n <span class="${_$MOBILE_TIMELINE_PREFIX$_}-current-tip-line" style="background-color: ${this.options.timePointColor||"#648FFC"};"></span>\n <div class="${_$MOBILE_TIMELINE_PREFIX$_}-current-value" style="color: ${this.options.currentTimeColor||"#FFFFFF"}">00:00:00</div>\n </div>`;this.$container.appendChild(this._$currentTime);this._$itemContainer=document.createElement("div");this._$itemContainer.classList.add(_$MOBILE_TIMELINE_PREFIX$_+"-container");this.$container.appendChild(this._$itemContainer);this._dragScroll=new DragScroll(this._$itemContainer,{hideScrollbar:true,onChange:state=>{const result=this._offsetYToTime(state.y);if(result[1]!==this.state.current)this._setCurrentDOM(result[0]>=_$DAY_TIME_SECOND$_?"23:59:59":result[1]);},onDragStart:()=>{this.options.onDragStart==null?void 0:this.options.onDragStart.call(this.options,this.state.current);},onDragging:()=>{this.options.onDragging==null?void 0:this.options.onDragging.call(this.options,this.state.current);},onDragEnd:()=>{var _this__dragScroll;const result=this._offsetYToTime((_this__dragScroll=this._dragScroll)==null?void 0:_this__dragScroll.currentY);if(result[1]!==this.state.current)this._setState({current:result[0]>=_$DAY_TIME_SECOND$_?"23:59:59":result[1]});this.options.onDragEnd==null?void 0:this.options.onDragEnd.call(this.options,this.state.current);}});
|
|
10727
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
10728
|
+
if(/\d/.test(this.options.height))this._$itemContainer.style.cssText+=`height: ${this.options.height}px`;else if(typeof this.options.height==="string")this._$itemContainer.style.cssText+=`height: ${this.options.height}`;else {const height=this.$container.clientHeight;this._$itemContainer.style.cssText+=`height: ${height}px`;}this._$itemList=document.createElement("div");this._$itemList.classList.add(_$MOBILE_TIMELINE_PREFIX$_+"-item");this._dragScroll.$content.appendChild(this._$itemList);if(this.options.showTimeWidthBtn){
|
|
10729
|
+
// 加减
|
|
10730
|
+
this._$op=document.createElement("div");this._$op.classList.add(_$MOBILE_TIMELINE_PREFIX$_+"-op");this._$op.innerHTML=`<span class="${_$MOBILE_TIMELINE_PREFIX$_}-op-wrapper"><span class="${_$MOBILE_TIMELINE_PREFIX$_}-icon-plus">${_$TIMELINE_ICONS$_.plus}</span> <span class="${_$MOBILE_TIMELINE_PREFIX$_}-icon-minus">${_$TIMELINE_ICONS$_.minus}</span></span>`;this.$container.appendChild(this._$op);}this._picker=new Picker(null,{isMobile:true,wrapClassName:`${_$MOBILE_TIMELINE_PREFIX$_}-picker`,onOpenChange:isOpen=>{var _this_options_onPickerOpenChange,_this_options;(_this_options=this.options)==null?void 0:(_this_options_onPickerOpenChange=_this_options.onPickerOpenChange)==null?void 0:_this_options_onPickerOpenChange.call(_this_options,isOpen);}});this._addEventListener();}_addEventListener(){if(this.options.showTimeWidthBtn&&this._$op){var// this._$op.addEventListener('click', this._opClick, false);
|
|
10731
|
+
_this__$op_querySelector,_this__$op_querySelector1;(_this__$op_querySelector=this._$op.querySelector(`.${_$MOBILE_TIMELINE_PREFIX$_}-icon-plus`))==null?void 0:_this__$op_querySelector.addEventListener("click",this._plusClick,false);(_this__$op_querySelector1=this._$op.querySelector(`.${_$MOBILE_TIMELINE_PREFIX$_}-icon-minus`))==null?void 0:_this__$op_querySelector1.addEventListener("click",this._minusClick,false);}this._matchTimeDot();if(this._picker){this._delegatePickerClose=delegate(this._picker.$body,`.${_$MOBILE_TIMELINE_PREFIX$_}-picker-close`,"click",this._onPickerClose,false);this._delegateItemContent=delegate(this._picker.$body,`.${_$MOBILE_TIMELINE_PREFIX$_}-picker-item-content`,"click",this._onClickItem,false);this._delegateCoverFold=delegate(this._$itemList,`.${_$MOBILE_TIMELINE_PREFIX$_}-time-cover-fold`,"click",this._onClickCoverFold,false);}}_removeEventListener(){if(this.options.showTimeWidthBtn&&this._$op){var _this__$op_querySelector,_this__$op_querySelector1;(_this__$op_querySelector=this._$op.querySelector(`.${_$MOBILE_TIMELINE_PREFIX$_}-icon-plus`))==null?void 0:_this__$op_querySelector.removeEventListener("click",this._plusClick);(_this__$op_querySelector1=this._$op.querySelector(`.${_$MOBILE_TIMELINE_PREFIX$_}-icon-minus`))==null?void 0:_this__$op_querySelector1.removeEventListener("click",this._minusClick);}if(this._picker){var _this__picker_$body_querySelector,_this__picker_$body;(_this__picker_$body=this._picker.$body)==null?void 0:(_this__picker_$body_querySelector=_this__picker_$body.querySelector(`.${_$MOBILE_TIMELINE_PREFIX$_}-picker-close`))==null?void 0:_this__picker_$body_querySelector.removeEventListener("click",this._onPickerClose);if(this._delegateItemContent){this._delegateItemContent.forEach(function(delegation){delegation.destroy();});this._delegateItemContent=null;}if(this._delegatePickerClose){this._delegatePickerClose.forEach(function(delegation){delegation.destroy();});this._delegatePickerClose=null;}if(this._delegateCoverFold){this._delegateCoverFold.forEach(function(delegation){delegation.destroy();});this._delegateCoverFold=null;}}}_plusClick(){const timeWidth=this.timeWidth+1;if(timeWidth>0&&timeWidth<MOBILE_TIME_WIDTH.length)this.setTimeWidth(timeWidth);else console.warn("时间轴刻度宽度不能再加了");}_minusClick(){const timeWidth=this.timeWidth-1;if(timeWidth>=0&&timeWidth<MOBILE_TIME_WIDTH.length)this.setTimeWidth(Math.floor(timeWidth));else console.warn("时间轴刻度宽度不能再减了");}_timeSectionsToGroupsByHour(list){const obj={};list.forEach((item,index)=>{
|
|
10732
|
+
// 移动端仅支持一天
|
|
10733
|
+
// if (TimeLineUtil.tranTime(item.startTime, 'YYYY-MM-DD') !== TimeLineUtil.tranTime(item.endTime, 'YYYY-MM-DD')) {
|
|
10734
|
+
// }
|
|
10735
|
+
const hour=TimeLineUtil.tranTime(item.startTime,"HH");if(obj[+hour])
|
|
10736
|
+
// prettier-ignore
|
|
10737
|
+
obj[+hour].push(_extends$1$1({},item,{_index:index}));else
|
|
10738
|
+
// prettier-ignore
|
|
10739
|
+
obj[+hour]=[_extends$1$1({},item,{_index:index})];});return obj}
|
|
10740
|
+
/**
|
|
10741
|
+
*
|
|
10742
|
+
* @param start 仅支持判断同一天的, 如果是多天的或出错
|
|
10743
|
+
*/_filterTimeSectionsByTime(start){if(!start)return [];const startSecond=TimeLineUtil.timeToSecond(start+":00");const endSecond=TimeLineUtil.timeToSecond(start+":00")+this._scaleWidth*60;return this.timeSections.filter(item=>{const start=TimeLineUtil.timeToSecond(TimeLineUtil.tranTime(item.startTime,"HH:mm:ss"));return start>=startSecond&&start<endSecond})}
|
|
10744
|
+
/**
|
|
10745
|
+
* 渲染选择器内容
|
|
10746
|
+
*/_renderPickerContent(start){var _this__picker_innerHTML,_this__picker,_this__picker1;const list=this._filterTimeSectionsByTime(start);const hourGroups=this._timeSectionsToGroupsByHour(list);(_this__picker=this._picker)==null?void 0:(_this__picker_innerHTML=_this__picker.innerHTML)==null?void 0:_this__picker_innerHTML.call(_this__picker,`<div class="${_$MOBILE_TIMELINE_PREFIX$_}-picker-container">\n <div class="${_$MOBILE_TIMELINE_PREFIX$_}-picker-header">\n <span class="${_$MOBILE_TIMELINE_PREFIX$_}-picker-close">${_$TIMELINE_ICONS$_.close}</span>\n ${this.i18n.t("title",{len:list.length,unit:list.length>1?"videos":"video"})}\n </div>\n <div class="${_$MOBILE_TIMELINE_PREFIX$_}-picker-content">\n <div class="${_$MOBILE_TIMELINE_PREFIX$_}-picker-list">\n ${Object.keys(hourGroups).reverse().map(key=>`<div class="${_$MOBILE_TIMELINE_PREFIX$_}-picker-item">\n <div class="${_$MOBILE_TIMELINE_PREFIX$_}-picker-item-title">${key}:00</div>\n <div class="${_$MOBILE_TIMELINE_PREFIX$_}-picker-item-list">\n ${hourGroups[key].reverse().map(item=>`<div class="${_$MOBILE_TIMELINE_PREFIX$_}-picker-item-content"\n data-start="${TimeLineUtil.tranTime(item.startTime,"YYYYMMDDTHHmmssZ")}"\n data-end="${TimeLineUtil.tranTime(item.endTime,"YYYYMMDDTHHmmssZ")}"\n data-index="${item._index}">\n <span class="${_$MOBILE_TIMELINE_PREFIX$_}-picker-item-time">${TimeLineUtil.tranTime(item.startTime,"HH:mm")}</span>\n <span class="${_$MOBILE_TIMELINE_PREFIX$_}-picker-item-duration">\n ${TimeLineUtil.tranTimeToString(item.startTime,item.endTime)}\n </span>\n <img class="${_$MOBILE_TIMELINE_PREFIX$_}-picker-item-cover" src="${this._setImageScr(item.coverPic)}"/>\n </div>`).join("")}\n </div>\n </div>`).join("")}\n </div>\n </div>\n </div>\n </div>`);if((_this__picker1=this._picker)==null?void 0:_this__picker1.$body){var _this__picker2;this._imageErrorEvent(((_this__picker2=this._picker)==null?void 0:_this__picker2.$body.querySelectorAll("img"))||[]);}}
|
|
10747
|
+
/**
|
|
10748
|
+
* 图片加载失败事件监听
|
|
10749
|
+
* @param list
|
|
10750
|
+
*/_imageErrorEvent(list=[]){Array.from(list).forEach(img=>{
|
|
10751
|
+
// 避免重复添加事件
|
|
10752
|
+
if(!img.hasAttribute("data-error"))img.addEventListener("error",this._onImageError);});}
|
|
10753
|
+
/**
|
|
10754
|
+
* 图片加载失败移除
|
|
10755
|
+
* @param list
|
|
10756
|
+
*/_imageRemoveErrorEvent(list=[]){Array.from(list).forEach(img=>{
|
|
10757
|
+
// 避免重复添加事件
|
|
10758
|
+
img.removeEventListener("error",this._onImageError);});}
|
|
10759
|
+
/**
|
|
10760
|
+
* 图片加载失败
|
|
10761
|
+
* @param e
|
|
10762
|
+
*/_onImageError(e){const img=e.target;if(!img.hasAttribute("data-error")){var _img_parentNode;
|
|
10763
|
+
// 加密图片不能加载或没有图片
|
|
10764
|
+
const placeholder=document.createElement("div");placeholder.classList.add(`${_$MOBILE_TIMELINE_PREFIX$_}-item-cover-placeholder`);placeholder.innerHTML=`${_$TIMELINE_ICONS$_.picture}`;(_img_parentNode=img.parentNode)==null?void 0:_img_parentNode.appendChild(placeholder);img.remove();
|
|
10765
|
+
// img.setAttribute('data-error', 'true'); // 失败仅设置一次, 否则会死循环
|
|
10766
|
+
}}_onPickerClose(){if(this._picker)this._picker.open=false;}_onClickItem(e){var _e_delegateTarget_getAttribute,_e_delegateTarget;const index=(_e_delegateTarget=e.delegateTarget)==null?void 0:(_e_delegateTarget_getAttribute=_e_delegateTarget.getAttribute)==null?void 0:_e_delegateTarget_getAttribute.call(_e_delegateTarget,"data-index");if(this._picker)this._picker.open=false;this.options.onPickerSelect==null?void 0:this.options.onPickerSelect.call(this.options,this.timeSections[+index]);}_onClickCoverFold(e){var _e_delegateTarget_parentElement_getAttribute,_e_delegateTarget_parentElement,_e_delegateTarget;e.preventDefault();e.stopPropagation();const time=(_e_delegateTarget=e.delegateTarget)==null?void 0:(_e_delegateTarget_parentElement=_e_delegateTarget.parentElement)==null?void 0:(_e_delegateTarget_parentElement_getAttribute=_e_delegateTarget_parentElement.getAttribute)==null?void 0:_e_delegateTarget_parentElement_getAttribute.call(_e_delegateTarget_parentElement,"data-time");if(this._picker&&time){this._renderPickerContent(time);this._picker.open=true;}}_setImageScr(src){if(src){const query="x=1000&"+(this.options.coverQuery||"");return src+(src.includes("?")?"&":"?")+query}return ""}_offsetYToTime(offsetY){let y=offsetY;if(offsetY<60){var _this__dragScroll;
|
|
10767
|
+
// 60 是下限
|
|
10768
|
+
y=60;(_this__dragScroll=this._dragScroll)==null?void 0:_this__dragScroll.scrollToY(y);}const second=_$DAY_TIME_SECOND$_-Math.floor((y-60)*this._scaleWidth);return [second,TimeLineUtil.subTime(Math.floor(second/3600))+":"+TimeLineUtil.subTime(Math.floor(second%3600/60))+":"+TimeLineUtil.subTime(second%60)]}constructor(container,options){super(container,deepmerge(_$MOBILE_TIME_LINE_DEFAULT_OPTIONS$_,options,{clone:false})),this._isTouchStart=false,this._dragScroll=null,this.state={start:"00:00:00",end:"24:00:00",current:null,timeArr:[],availTimeLine:[],index:0};this._plusClick=this._plusClick.bind(this);this._minusClick=this._minusClick.bind(this);this._onPickerClose=this._onPickerClose.bind(this);this._onClickItem=this._onClickItem.bind(this);this._onClickCoverFold=this._onClickCoverFold.bind(this);this._onImageError=this._onImageError.bind(this);this._render();}}function _extends$5(){_extends$5=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source)if(Object.prototype.hasOwnProperty.call(source,key))target[key]=source[key];}return target};return _extends$5.apply(this,arguments)}
|
|
10769
|
+
/**
|
|
10770
|
+
* 时间轴配置项
|
|
10771
|
+
*/const _$TIMELINE_DEFAULT_OPTIONS$_={height:36,dpr:window.devicePixelRatio||2,
|
|
10772
|
+
// wheelSpeed: 0.1,
|
|
10773
|
+
scaleOffsetTop:4,showYearMonthDay:true};
|
|
10774
|
+
/**
|
|
10775
|
+
* 时间轴控件类, 支持PC/Mobile 拖动和缩放
|
|
10776
|
+
* @beta
|
|
10777
|
+
* @example
|
|
10778
|
+
* ```ts
|
|
10779
|
+
* import TimeLine from './TimeLine';
|
|
10780
|
+
* const timeLine = new TimeLine(document.getElementById('container'), {})
|
|
10781
|
+
* ```
|
|
10782
|
+
*/class TimeLine extends BaseTimeLine{
|
|
10783
|
+
/**
|
|
10784
|
+
* 初始化 (canvas)
|
|
10785
|
+
*/
|
|
10786
|
+
_init(){this._$canvas=document.createElement("canvas");this._ctx=this._$canvas.getContext("2d");if(!this.readOnly)this._$canvas.style.cssText+="cursor: pointer;";this.$container.appendChild(this._$canvas);this.resize(this.width,this.height);this._update({current:this.current,timeWidth:this.timeWidth,timeSections:this.timeSections});this._addEventListener();}
|
|
10787
|
+
/**
|
|
10788
|
+
* 重置尺寸
|
|
10789
|
+
*/resize(width,height){super.resize(width,height);if(this._$canvas&&width){this._$canvas.width=this.width*this.options.dpr;this._$canvas.style.cssText+=`width: ${this.width}px;`;}if(this._$canvas&&height){this._$canvas.height=this.height*this.options.dpr;this._$canvas.style.cssText+=`height: ${this.height}px;`;}this._draw();}
|
|
10790
|
+
/**
|
|
10770
10791
|
* 设置时间轴刻度宽度
|
|
10771
10792
|
* @param timeWidth - 时间轴刻度宽度 [0, TIME_WIDTH.length - 1]
|
|
10772
10793
|
* @returns
|
|
10773
|
-
*/
|
|
10774
|
-
|
|
10775
|
-
}
|
|
10776
|
-
/**
|
|
10794
|
+
*/setTimeWidth(timeWidth){this._update({timeWidth:timeWidth});}
|
|
10795
|
+
/**
|
|
10777
10796
|
* 设置片段数组
|
|
10778
10797
|
* @param timeSections - 片段数组
|
|
10779
10798
|
* @returns
|
|
10780
|
-
*/
|
|
10781
|
-
|
|
10782
|
-
timeSections
|
|
10783
|
-
});
|
|
10784
|
-
}
|
|
10785
|
-
/**
|
|
10799
|
+
*/updateTimeSections(timeSections){this._update({timeSections:timeSections});}
|
|
10800
|
+
/**
|
|
10786
10801
|
* 更新当前时间
|
|
10787
10802
|
* @param time 能转成时间的值, 如 时间对象 Date, 时间戳,时间戳字符串
|
|
10788
|
-
*/
|
|
10789
|
-
|
|
10790
|
-
this._update({
|
|
10791
|
-
currentTime: new Date(tranTime(time, 'YYYY-MM-DD HH:mm:ss'))
|
|
10792
|
-
});
|
|
10793
|
-
}
|
|
10794
|
-
}
|
|
10795
|
-
/**
|
|
10803
|
+
*/update(time){if(time&&!this._isMouseDown)this._update({current:new Date(TimeLineUtil.tranTime(time,"YYYY-MM-DD HH:mm:ss"))});}
|
|
10804
|
+
/**
|
|
10796
10805
|
* 更新
|
|
10797
10806
|
* @param options - 更新参数
|
|
10798
10807
|
* @returns
|
|
10799
|
-
*/
|
|
10800
|
-
|
|
10801
|
-
this._currentTime = options.currentTime;
|
|
10802
|
-
}
|
|
10803
|
-
if (options == null ? void 0 : options.timeSections) {
|
|
10804
|
-
this._timeSections = this._mergeTimeSections(options.timeSections);
|
|
10805
|
-
}
|
|
10806
|
-
if (typeof (options == null ? void 0 : options.timeWidth) === 'number' && (options == null ? void 0 : options.timeWidth) < TIME_WIDTH.length) {
|
|
10807
|
-
this._timeWidth = options == null ? void 0 : options.timeWidth;
|
|
10808
|
-
this._timeWidthArray = TIME_WIDTH[Math.floor(this._timeWidth)];
|
|
10809
|
-
}
|
|
10810
|
-
if (!this._timeWidthArray) {
|
|
10811
|
-
// 不存在 默认取第一个
|
|
10812
|
-
this._timeWidth = 0;
|
|
10813
|
-
this._timeWidthArray = TIME_WIDTH[0];
|
|
10814
|
-
}
|
|
10815
|
-
if (typeof (options == null ? void 0 : options.timeWidth) === 'number' && this._timeWidthArray) {
|
|
10816
|
-
if (this._timeWidthArray[3]) {
|
|
10817
|
-
var _this__$canvas;
|
|
10818
|
-
(_this__$canvas = this._$canvas) == null ? void 0 : _this__$canvas.setAttribute('data-title', this._timeWidthArray[3]);
|
|
10819
|
-
}
|
|
10820
|
-
}
|
|
10821
|
-
// 清空画布
|
|
10822
|
-
if (this._ctx) {
|
|
10823
|
-
this._ctx.fillStyle = this._options.timeAxisBgColor;
|
|
10824
|
-
// prettier-ignore
|
|
10825
|
-
this._ctx.fillRect(0, 0, this._width * this._options.dpr, this._height * this._options.dpr);
|
|
10826
|
-
}
|
|
10827
|
-
this._draw();
|
|
10828
|
-
}
|
|
10829
|
-
/**
|
|
10830
|
-
* 设置只读或取消只读
|
|
10831
|
-
* @param readOnly - 只读或取消只读
|
|
10832
|
-
* @returns
|
|
10833
|
-
*/ setReadOnly(readOnly) {
|
|
10834
|
-
this._readOnly = readOnly;
|
|
10835
|
-
if (this._$canvas) {
|
|
10836
|
-
if (this._readOnly) {
|
|
10837
|
-
this._$canvas.style.cursor = 'not-allowed';
|
|
10838
|
-
} else {
|
|
10839
|
-
this._$canvas.style.cursor = 'pointer';
|
|
10840
|
-
}
|
|
10841
|
-
}
|
|
10842
|
-
}
|
|
10843
|
-
/**
|
|
10808
|
+
*/_update(options={}){if((options==null?void 0:options.current)&&options.current instanceof Date)this.current=options.current;if(options==null?void 0:options.timeSections)super.updateTimeSections(this._mergeTimeSections(options.timeSections));if(typeof(options==null?void 0:options.timeWidth)==="number"&&(options==null?void 0:options.timeWidth)<TIME_WIDTH.length){super.setTimeWidth(options.timeWidth);this._timeWidthArray=TIME_WIDTH[Math.floor(this.timeWidth)];}if(typeof(options==null?void 0:options.timeWidth)==="number"&&this._timeWidthArray)if(this._timeWidthArray[3]){var _this__$canvas;(_this__$canvas=this._$canvas)==null?void 0:_this__$canvas.setAttribute("data-title",this._timeWidthArray[3]);}this._draw();}setReadOnly(readOnly){super.setReadOnly(readOnly);if(this._$canvas)this._$canvas.style.cssText+=`cursor: ${readOnly?"not-allowed":"pointer"}`;}
|
|
10809
|
+
/**
|
|
10844
10810
|
* 销毁
|
|
10845
10811
|
* @returns
|
|
10846
|
-
*/
|
|
10847
|
-
|
|
10848
|
-
|
|
10849
|
-
|
|
10850
|
-
|
|
10851
|
-
|
|
10852
|
-
|
|
10853
|
-
|
|
10854
|
-
|
|
10855
|
-
|
|
10856
|
-
|
|
10857
|
-
|
|
10858
|
-
|
|
10859
|
-
|
|
10860
|
-
|
|
10861
|
-
}
|
|
10862
|
-
// -----------------------------------------------------------------------------------------
|
|
10863
|
-
// private
|
|
10864
|
-
// -----------------------------------------------------------------------------------------
|
|
10865
|
-
/**
|
|
10812
|
+
*/destroy(){this._removeEventListener();if(this._$canvas)try{this.$container.removeChild(this._$canvas);
|
|
10813
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
10814
|
+
this._$canvas=null;}catch(e){
|
|
10815
|
+
// console.error(e);
|
|
10816
|
+
}super.destroy();
|
|
10817
|
+
// if (this._$tip) {
|
|
10818
|
+
// this.$container.removeChild(this._$tip);
|
|
10819
|
+
// // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
10820
|
+
// this._$tip = null!;
|
|
10821
|
+
// }
|
|
10822
|
+
}
|
|
10823
|
+
// -----------------------------------------------------------------------------------------
|
|
10824
|
+
// private
|
|
10825
|
+
// -----------------------------------------------------------------------------------------
|
|
10826
|
+
/**
|
|
10866
10827
|
* 缩放时间轴 动态减少间距 (没处理 dpr)
|
|
10867
10828
|
* @returns 刻度间距
|
|
10868
|
-
*/
|
|
10869
|
-
|
|
10870
|
-
|
|
10871
|
-
|
|
10872
|
-
/**
|
|
10829
|
+
*/
|
|
10830
|
+
get _curScaleSpacing(){var _this__timeWidthArray,_this__timeWidthArray1;return Math.floor(((_this__timeWidthArray=this._timeWidthArray)==null?void 0:_this__timeWidthArray[1])-((_this__timeWidthArray1=this._timeWidthArray)==null?void 0:_this__timeWidthArray1[1])*+(this.timeWidth%1/2).toFixed(2));// 刻度间距
|
|
10831
|
+
}
|
|
10832
|
+
/**
|
|
10873
10833
|
* 绘制
|
|
10874
|
-
*/
|
|
10875
|
-
|
|
10876
|
-
|
|
10877
|
-
|
|
10878
|
-
|
|
10834
|
+
*/_draw(){
|
|
10835
|
+
// 清空画布
|
|
10836
|
+
if(this._ctx){this._ctx.fillStyle=this.options.timeAxisBgColor;
|
|
10837
|
+
// prettier-ignore
|
|
10838
|
+
this._ctx.fillRect(0,0,this.width*this.options.dpr,this.height*this.options.dpr);}this._drawSections();this._drawScale();}
|
|
10839
|
+
/**
|
|
10879
10840
|
* 绘制刻度
|
|
10880
|
-
*/
|
|
10881
|
-
|
|
10882
|
-
|
|
10883
|
-
|
|
10884
|
-
|
|
10885
|
-
|
|
10886
|
-
|
|
10887
|
-
|
|
10888
|
-
|
|
10889
|
-
|
|
10890
|
-
|
|
10891
|
-
|
|
10892
|
-
|
|
10893
|
-
|
|
10894
|
-
|
|
10895
|
-
|
|
10896
|
-
|
|
10897
|
-
|
|
10898
|
-
|
|
10899
|
-
|
|
10900
|
-
|
|
10901
|
-
|
|
10902
|
-
|
|
10903
|
-
|
|
10904
|
-
|
|
10905
|
-
|
|
10906
|
-
|
|
10907
|
-
|
|
10908
|
-
|
|
10909
|
-
|
|
10910
|
-
|
|
10911
|
-
|
|
10912
|
-
|
|
10913
|
-
|
|
10914
|
-
}
|
|
10915
|
-
// 右扩展刻度
|
|
10916
|
-
// prettier-ignore
|
|
10917
|
-
for(let x = rightLastScaleTimeX; x <= this._width * this._options.dpr; x += spacing){
|
|
10918
|
-
// prettier-ignore
|
|
10919
|
-
const rightOffsetSecond = rightLastScaleTime - Math.floor(new Date(tranTime(new Date(rightLastScaleTime * 1000), "YYYY-MM-DD") + " 00:00:00").getTime() / 1000);
|
|
10920
|
-
// prettier-ignore
|
|
10921
|
-
const curScale = rightOffsetSecond % (this._timeWidthArray[0] * this._timeWidthArray[2]);
|
|
10922
|
-
if (curScale === 0) {
|
|
10923
|
-
// prettier-ignore
|
|
10924
|
-
this._drawSolidLine(x, padding, x, padding + (this._options.scaleOffsetTop + 4) * this._options.dpr, lineWidth);
|
|
10925
|
-
// prettier-ignore
|
|
10926
|
-
this._drawTextString(tranTime(new Date(rightLastScaleTime * 1000)), x, padding + (this._options.scaleOffsetTop + 4 + 4) * this._options.dpr, "center");
|
|
10927
|
-
} else {
|
|
10928
|
-
this._drawSolidLine(x, padding, x, padding + this._options.scaleOffsetTop * this._options.dpr, lineWidth);
|
|
10929
|
-
}
|
|
10930
|
-
rightLastScaleTime = rightLastScaleTime + this._timeWidthArray[0];
|
|
10931
|
-
}
|
|
10932
|
-
// 当前中心位置(当前时间 currentTime)
|
|
10933
|
-
// prettier-ignore
|
|
10934
|
-
this._drawSolidLine(centerPosition.x, 0, centerPosition.x, centerPosition.y, lineWidth, this._options.timePointColor);
|
|
10935
|
-
}
|
|
10936
|
-
/**
|
|
10841
|
+
*/_drawScale(){const lineWidth=1*this.options.dpr;
|
|
10842
|
+
/** 中心位置 */this._centerPositionX=parseInt(this.width*this.options.dpr/2+"");const centerPosition={x:this.width*this.options.dpr/2,y:this.height*this.options.dpr};const curScaleTime=Math.floor(this.current.getTime()/1e3);// current 秒
|
|
10843
|
+
// 由于时区问题 当前时间戳(秒)处理但前刻度有偏移,所以改成使用当天便宜量, 这样就能保证当天的 0 点刻度能展示
|
|
10844
|
+
// prettier-ignore
|
|
10845
|
+
const offsetSecond=(curScaleTime-Math.floor(new Date(TimeLineUtil.tranTime(new Date(curScaleTime*1e3),"YYYY-MM-DD")+" 00:00:00").getTime()/1e3))%this._timeWidthArray[0];const padding=this.height*this.options.dpr/20;// 刻度顶部偏移量 高度的 1/8
|
|
10846
|
+
const spacing=this._curScaleSpacing*this.options.dpr;
|
|
10847
|
+
// 因为右偏移 右侧靠近中心点的X坐标 减去偏移量
|
|
10848
|
+
// prettier-ignore
|
|
10849
|
+
const rightLastScaleTimeX=Math.floor(this._centerPositionX+(this._timeWidthArray[0]-offsetSecond)/this._timeWidthArray[0]*spacing);let leftLastScaleTime=curScaleTime-offsetSecond;let rightLastScaleTime=leftLastScaleTime+this._timeWidthArray[0];const leftLastScaleTimeX=rightLastScaleTimeX-spacing;
|
|
10850
|
+
// 左扩展刻度
|
|
10851
|
+
for(let x=leftLastScaleTimeX;x>0;x-=spacing){
|
|
10852
|
+
// prettier-ignore
|
|
10853
|
+
const leftOffsetSecond=leftLastScaleTime-Math.floor(new Date(TimeLineUtil.tranTime(new Date(leftLastScaleTime*1e3),"YYYY-MM-DD")+" 00:00:00").getTime()/1e3);
|
|
10854
|
+
// prettier-ignore
|
|
10855
|
+
const curScale=leftOffsetSecond%(this._timeWidthArray[0]*this._timeWidthArray[2]);if(curScale===0){
|
|
10856
|
+
// prettier-ignore
|
|
10857
|
+
this._drawSolidLine(x,padding,x,padding+(this.options.scaleOffsetTop+4)*this.options.dpr,lineWidth);
|
|
10858
|
+
// prettier-ignore
|
|
10859
|
+
this._drawTextString(TimeLineUtil.tranTime(new Date(leftLastScaleTime*1e3)),x,padding+(this.options.scaleOffsetTop+4+4)*this.options.dpr,"center");}else this._drawSolidLine(x,padding,x,padding+this.options.scaleOffsetTop*this.options.dpr,lineWidth);leftLastScaleTime-=this._timeWidthArray[0];}
|
|
10860
|
+
// 右扩展刻度
|
|
10861
|
+
// prettier-ignore
|
|
10862
|
+
for(let x=rightLastScaleTimeX;x<=this.width*this.options.dpr;x+=spacing){
|
|
10863
|
+
// prettier-ignore
|
|
10864
|
+
const rightOffsetSecond=rightLastScaleTime-Math.floor(new Date(TimeLineUtil.tranTime(new Date(rightLastScaleTime*1e3),"YYYY-MM-DD")+" 00:00:00").getTime()/1e3);
|
|
10865
|
+
// prettier-ignore
|
|
10866
|
+
const curScale=rightOffsetSecond%(this._timeWidthArray[0]*this._timeWidthArray[2]);if(curScale===0){
|
|
10867
|
+
// prettier-ignore
|
|
10868
|
+
this._drawSolidLine(x,padding,x,padding+(this.options.scaleOffsetTop+4)*this.options.dpr,lineWidth);
|
|
10869
|
+
// prettier-ignore
|
|
10870
|
+
this._drawTextString(TimeLineUtil.tranTime(new Date(rightLastScaleTime*1e3)),x,padding+(this.options.scaleOffsetTop+4+4)*this.options.dpr,"center");}else this._drawSolidLine(x,padding,x,padding+this.options.scaleOffsetTop*this.options.dpr,lineWidth);rightLastScaleTime+=this._timeWidthArray[0];}
|
|
10871
|
+
// 当前中心位置(当前时间 current)
|
|
10872
|
+
// prettier-ignore
|
|
10873
|
+
this._drawSolidLine(centerPosition.x,0,centerPosition.x,centerPosition.y,lineWidth,this.options.timePointColor);}
|
|
10874
|
+
/**
|
|
10937
10875
|
* 绘制线
|
|
10938
10876
|
* @param startX - 线起点 x 坐标
|
|
10939
10877
|
* @param startY - 线起点 y 坐标
|
|
@@ -10942,409 +10880,211 @@
|
|
|
10942
10880
|
* @param lineWidth - 线宽度
|
|
10943
10881
|
* @param color - 线颜色
|
|
10944
10882
|
*
|
|
10945
|
-
*/
|
|
10946
|
-
|
|
10947
|
-
|
|
10948
|
-
|
|
10949
|
-
this._ctx.strokeStyle = color != null ? color : this._options.timeScaleColor;
|
|
10950
|
-
this._ctx.lineWidth = lineWidth;
|
|
10951
|
-
this._ctx.beginPath();
|
|
10952
|
-
this._ctx.moveTo(startX, startY);
|
|
10953
|
-
this._ctx.lineTo(endX, endY);
|
|
10954
|
-
this._ctx.stroke();
|
|
10955
|
-
this._ctx.restore();
|
|
10956
|
-
}
|
|
10957
|
-
}
|
|
10958
|
-
/**
|
|
10883
|
+
*/
|
|
10884
|
+
// prettier-ignore
|
|
10885
|
+
_drawSolidLine(startX,startY,endX,endY,lineWidth,color){if(this._ctx){this._ctx.save();this._ctx.strokeStyle=color!=null?color:this.options.timeScaleColor;this._ctx.lineWidth=lineWidth;this._ctx.beginPath();this._ctx.moveTo(startX,startY);this._ctx.lineTo(endX,endY);this._ctx.stroke();this._ctx.restore();}}
|
|
10886
|
+
/**
|
|
10959
10887
|
* 绘制刻度文字
|
|
10960
10888
|
* @param text - 文本
|
|
10961
10889
|
* @param x - X
|
|
10962
10890
|
* @param y - Y
|
|
10963
10891
|
* @param align - 文本对齐方式
|
|
10964
|
-
*/
|
|
10965
|
-
|
|
10966
|
-
|
|
10967
|
-
|
|
10968
|
-
|
|
10969
|
-
|
|
10970
|
-
|
|
10971
|
-
|
|
10972
|
-
timeTexts[1] = timeTexts[1].replace(/:00$/, '');
|
|
10973
|
-
}
|
|
10974
|
-
this._ctx.fillText(timeTexts[1], x, y + 8 * this._options.dpr);
|
|
10975
|
-
// prettier-ignore
|
|
10976
|
-
if (this._options.showYearMonthDay && (timeTexts[1] === "00:00:00" || timeTexts[1] === "00:00" || this._timeWidthArray[0] * this._timeWidthArray[2] === 24 * 3600)) {
|
|
10977
|
-
// 展示年月日
|
|
10978
|
-
this._ctx.textAlign = align || "left";
|
|
10979
|
-
this._ctx.fillText(timeTexts[0], x, y + (8 + 10) * this._options.dpr);
|
|
10980
|
-
}
|
|
10981
|
-
}
|
|
10982
|
-
}
|
|
10983
|
-
/**
|
|
10892
|
+
*/_drawTextString(text,x,y,align){if(this._ctx){const timeTexts=text.split(" ");this._ctx.font=`${12*this.options.dpr*1}px serif`;this._ctx.fillStyle=this.options.timeTextColor;this._ctx.textAlign=align||"left";if(this._timeWidthArray[0]%60===0)
|
|
10893
|
+
// 仅展示 hh:mm
|
|
10894
|
+
timeTexts[1]=timeTexts[1].replace(/:00$/,"");this._ctx.fillText(timeTexts[1],x,y+8*this.options.dpr);
|
|
10895
|
+
// prettier-ignore
|
|
10896
|
+
if(this.options.showYearMonthDay&&(timeTexts[1]==="00:00:00"||timeTexts[1]==="00:00"||this._timeWidthArray[0]*this._timeWidthArray[2]===24*3600)){
|
|
10897
|
+
// 展示年月日
|
|
10898
|
+
this._ctx.textAlign=align||"left";this._ctx.fillText(timeTexts[0],x,y+(8+10)*this.options.dpr);}}}
|
|
10899
|
+
/**
|
|
10984
10900
|
* 画录像区间
|
|
10985
|
-
*/
|
|
10986
|
-
|
|
10987
|
-
|
|
10988
|
-
|
|
10989
|
-
|
|
10990
|
-
|
|
10991
|
-
|
|
10992
|
-
|
|
10993
|
-
|
|
10994
|
-
|
|
10995
|
-
|
|
10996
|
-
this._ctx.fillRect(position.x1, 0, position.x2 - position.x1, this._height * this._options.dpr);
|
|
10997
|
-
}
|
|
10998
|
-
}
|
|
10999
|
-
}
|
|
11000
|
-
/**
|
|
10901
|
+
*/_drawSections(){
|
|
10902
|
+
// 绘制蓝色区域
|
|
10903
|
+
const timeArr=this.timeSections||[];
|
|
10904
|
+
// 根据时间查找当前位置
|
|
10905
|
+
for(let i=0;i<timeArr.length;i++){const position=this._findPosition(timeArr[i]);
|
|
10906
|
+
// 判断一下绘制区域是否在画布区域, 不在可以不用绘制
|
|
10907
|
+
// prettier-ignore
|
|
10908
|
+
if(this._ctx&&TimeLineUtil.isOverlap(0,this.width*this.options.dpr,position.x1,position.x2)){this._ctx.fillStyle=this.options.timeSectionColor;
|
|
10909
|
+
// prettier-ignore
|
|
10910
|
+
this._ctx.fillRect(position.x1,0,position.x2-position.x1,this.height*this.options.dpr);}}}
|
|
10911
|
+
/**
|
|
11001
10912
|
* 获取时间片段在时间轴中的x1 ,x2坐标 (已做 dpr 处理)
|
|
11002
10913
|
* @param item - 时间片段
|
|
11003
10914
|
* @returns {void}
|
|
11004
|
-
*/
|
|
11005
|
-
|
|
11006
|
-
|
|
11007
|
-
|
|
11008
|
-
|
|
11009
|
-
+ this._width / 2) * this._options.dpr;
|
|
11010
|
-
const x2 = x1 + parseInt((item.endTime - item.startTime) / 1000 + '', 10) / this._timeWidthArray[0] * this._curScaleSpacing * this._options.dpr;
|
|
11011
|
-
return {
|
|
11012
|
-
x1,
|
|
11013
|
-
x2
|
|
11014
|
-
};
|
|
11015
|
-
}
|
|
11016
|
-
/**
|
|
10915
|
+
*/_findPosition(item){
|
|
10916
|
+
// 中间的当前时间 current 为基准, 然后计算时间片段的 x 坐标和 y 坐标
|
|
10917
|
+
// prettier-ignore
|
|
10918
|
+
const x1=(parseInt((item.startTime-this.current.getTime())/1e3+"",10)/this._timeWidthArray[0]*this._curScaleSpacing+this.width/2)*this.options.dpr;const x2=x1+parseInt((item.endTime-item.startTime)/1e3+"",10)/this._timeWidthArray[0]*this._curScaleSpacing*this.options.dpr;return {x1:x1,x2:x2}}
|
|
10919
|
+
/**
|
|
11017
10920
|
* 合并相邻两个时间区间
|
|
11018
10921
|
* @param timeSections - 时间区间数组
|
|
11019
10922
|
*
|
|
11020
10923
|
* @returns 合并后的时间区间
|
|
11021
|
-
*/
|
|
11022
|
-
|
|
11023
|
-
|
|
11024
|
-
|
|
11025
|
-
|
|
11026
|
-
|
|
11027
|
-
|
|
11028
|
-
|
|
11029
|
-
|
|
11030
|
-
|
|
11031
|
-
|
|
11032
|
-
startTime: item.startTime,
|
|
11033
|
-
endTime: item.endTime
|
|
11034
|
-
};
|
|
11035
|
-
});
|
|
11036
|
-
const merged = [
|
|
11037
|
-
timeSections[0]
|
|
11038
|
-
];
|
|
11039
|
-
for(let i = 1; i < timeSections.length; i++){
|
|
11040
|
-
const prev = merged[merged.length - 1];
|
|
11041
|
-
const curr = timeSections[i];
|
|
11042
|
-
// 如果当前区间与上一个区间重叠或相邻(即 prev.end >= curr.start)
|
|
11043
|
-
if (prev.endTime >= curr.startTime) {
|
|
11044
|
-
// 合并区间
|
|
11045
|
-
prev.endTime = Math.max(prev.endTime, curr.endTime);
|
|
11046
|
-
} else {
|
|
11047
|
-
merged.push(curr);
|
|
11048
|
-
}
|
|
11049
|
-
}
|
|
11050
|
-
return merged;
|
|
11051
|
-
}
|
|
11052
|
-
// -------------------------------------
|
|
11053
|
-
// mouse event
|
|
11054
|
-
// -------------------------------------
|
|
11055
|
-
/**
|
|
10924
|
+
*/_mergeTimeSections(timeSections){if(timeSections.length===0)return timeSections;timeSections=timeSections.map(item=>{
|
|
10925
|
+
// 处理秒
|
|
10926
|
+
if((item.startTime+"").length===10)item.startTime=item.startTime*1e3;if((item.endTime+"").length===10)item.endTime=item.endTime*1e3;return _extends$5({},item,{startTime:item.startTime,endTime:item.endTime})});const merged=[timeSections[0]];for(let i=1;i<timeSections.length;i++){const prev=merged[merged.length-1];const curr=timeSections[i];
|
|
10927
|
+
// 如果当前区间与上一个区间重叠或相邻(即 prev.end >= curr.start)
|
|
10928
|
+
if(prev.endTime>=curr.startTime)
|
|
10929
|
+
// 合并区间
|
|
10930
|
+
prev.endTime=Math.max(prev.endTime,curr.endTime);else merged.push(curr);}return merged}
|
|
10931
|
+
// -------------------------------------
|
|
10932
|
+
// mouse event
|
|
10933
|
+
// -------------------------------------
|
|
10934
|
+
/**
|
|
11056
10935
|
* 添加事件监听
|
|
11057
10936
|
* @returns
|
|
11058
|
-
*/
|
|
11059
|
-
|
|
11060
|
-
|
|
11061
|
-
|
|
11062
|
-
|
|
11063
|
-
|
|
11064
|
-
|
|
11065
|
-
|
|
11066
|
-
|
|
11067
|
-
|
|
11068
|
-
|
|
11069
|
-
|
|
11070
|
-
|
|
11071
|
-
|
|
11072
|
-
|
|
11073
|
-
|
|
11074
|
-
|
|
11075
|
-
passive: false
|
|
11076
|
-
});
|
|
11077
|
-
this._$canvas.addEventListener('keydown', this._ctrlKeyDownFun);
|
|
11078
|
-
this._$canvas.addEventListener('keyup', this._ctrlKeyUpFun);
|
|
11079
|
-
// ctrl 键事件
|
|
11080
|
-
document.addEventListener('keydown', this._ctrlKeyDownFun, false);
|
|
11081
|
-
document.addEventListener('keyup', this._ctrlKeyUpFun, false);
|
|
11082
|
-
this._$canvas.addEventListener('touchstart', this._touchstartFun, {
|
|
11083
|
-
passive: false
|
|
11084
|
-
});
|
|
11085
|
-
this._$canvas.addEventListener('touchmove', this._touchmoveFun, {
|
|
11086
|
-
passive: false
|
|
11087
|
-
});
|
|
11088
|
-
this._$canvas.addEventListener('touchend', this._touchendFun, {
|
|
11089
|
-
passive: false
|
|
11090
|
-
});
|
|
11091
|
-
}
|
|
11092
|
-
}
|
|
11093
|
-
/**
|
|
10937
|
+
*/
|
|
10938
|
+
_addEventListener(){if(this._$canvas){
|
|
10939
|
+
// 事件监听
|
|
10940
|
+
this._$canvas.addEventListener("mousemove",this._mousemoveFun);
|
|
10941
|
+
// prettier-ignore
|
|
10942
|
+
this._$canvas.addEventListener("mouseover",this._mouseoverFun);
|
|
10943
|
+
// prettier-ignore
|
|
10944
|
+
this._$canvas.addEventListener("mouseleave",this._mouseleaveFun);
|
|
10945
|
+
// prettier-ignore
|
|
10946
|
+
this._$canvas.addEventListener("mousedown",this._mousedownFun);
|
|
10947
|
+
// prettier-ignore
|
|
10948
|
+
this._$canvas.addEventListener("mouseup",this._mouseUpFun);this._$canvas.addEventListener("wheel",this._mousewheelFun);
|
|
10949
|
+
// prettier-ignore
|
|
10950
|
+
this.$container.addEventListener("wheel",e=>{e.preventDefault();},{passive:false});this._$canvas.addEventListener("keydown",this._ctrlKeyDownFun);this._$canvas.addEventListener("keyup",this._ctrlKeyUpFun);
|
|
10951
|
+
// ctrl 键事件
|
|
10952
|
+
document.addEventListener("keydown",this._ctrlKeyDownFun,false);document.addEventListener("keyup",this._ctrlKeyUpFun,false);this._$canvas.addEventListener("touchstart",this._touchstartFun,{passive:false});this._$canvas.addEventListener("touchmove",this._touchmoveFun,{passive:false});this._$canvas.addEventListener("touchend",this._touchendFun,{passive:false});}}
|
|
10953
|
+
/**
|
|
11094
10954
|
* 移除事件监听
|
|
11095
10955
|
* @returns
|
|
11096
|
-
*/
|
|
11097
|
-
|
|
11098
|
-
|
|
11099
|
-
|
|
11100
|
-
|
|
11101
|
-
|
|
11102
|
-
|
|
11103
|
-
|
|
11104
|
-
|
|
11105
|
-
|
|
11106
|
-
|
|
11107
|
-
|
|
11108
|
-
|
|
11109
|
-
|
|
11110
|
-
|
|
11111
|
-
|
|
11112
|
-
document.removeEventListener('keydown', this._ctrlKeyDownFun);
|
|
11113
|
-
document.removeEventListener('keyup', this._ctrlKeyUpFun);
|
|
11114
|
-
// touch
|
|
11115
|
-
this._$canvas.removeEventListener('touchstart', this._touchstartFun);
|
|
11116
|
-
this._$canvas.removeEventListener('touchmove', this._touchmoveFun);
|
|
11117
|
-
this._$canvas.removeEventListener('touchend', this._touchendFun);
|
|
11118
|
-
}
|
|
11119
|
-
}
|
|
11120
|
-
/**
|
|
10956
|
+
*/_removeEventListener(){if(this._$canvas){
|
|
10957
|
+
// 事件监听
|
|
10958
|
+
this._$canvas.removeEventListener("mousemove",this._mousemoveFun);
|
|
10959
|
+
// prettier-ignore
|
|
10960
|
+
this._$canvas.removeEventListener("mouseover",this._mouseoverFun);
|
|
10961
|
+
// prettier-ignore
|
|
10962
|
+
this._$canvas.removeEventListener("mouseleave",this._mouseleaveFun);
|
|
10963
|
+
// prettier-ignore
|
|
10964
|
+
this._$canvas.removeEventListener("mousedown",this._mousedownFun);
|
|
10965
|
+
// prettier-ignore
|
|
10966
|
+
this._$canvas.removeEventListener("mouseup",this._mouseUpFun);this._$canvas.removeEventListener("wheel",this._mousewheelFun);this._$canvas.removeEventListener("keydown",this._ctrlKeyDownFun);this._$canvas.removeEventListener("keyup",this._ctrlKeyUpFun);
|
|
10967
|
+
// ctrl 键事件
|
|
10968
|
+
document.removeEventListener("keydown",this._ctrlKeyDownFun);document.removeEventListener("keyup",this._ctrlKeyUpFun);
|
|
10969
|
+
// touch
|
|
10970
|
+
this._$canvas.removeEventListener("touchstart",this._touchstartFun);this._$canvas.removeEventListener("touchmove",this._touchmoveFun);this._$canvas.removeEventListener("touchend",this._touchendFun);}}
|
|
10971
|
+
/**
|
|
11121
10972
|
* 鼠标按下事件监听
|
|
11122
10973
|
* @param e - 鼠标事件
|
|
11123
10974
|
* @returns
|
|
11124
|
-
*/
|
|
11125
|
-
|
|
11126
|
-
this._isMouseDown = true;
|
|
11127
|
-
this._mousePosition = e.pageX;
|
|
11128
|
-
this._oldTime = this._currentTime;
|
|
11129
|
-
this._options.onDragStart == null ? void 0 : this._options.onDragStart.call(this._options, this._currentTime);
|
|
11130
|
-
}
|
|
11131
|
-
/**
|
|
10975
|
+
*/_mousedownFun(e){if(this.readOnly)return;this._isMouseDown=true;this._mousePosition=e.pageX;this._oldTime=this.current;this.options.onDragStart==null?void 0:this.options.onDragStart.call(this.options,this.current);}
|
|
10976
|
+
/**
|
|
11132
10977
|
* 鼠标移入事件监听
|
|
11133
10978
|
* @returns
|
|
11134
|
-
*/
|
|
11135
|
-
|
|
11136
|
-
this._isOver = true;
|
|
11137
|
-
}
|
|
11138
|
-
/**
|
|
10979
|
+
*/_mouseoverFun(){if(this.readOnly)return;this._isOver=true;}
|
|
10980
|
+
/**
|
|
11139
10981
|
* 鼠标离开事件监听
|
|
11140
10982
|
* @returns
|
|
11141
|
-
*/
|
|
11142
|
-
|
|
11143
|
-
this._isOver = false;
|
|
11144
|
-
this._moveEndOrTouchEndFun(e);
|
|
11145
|
-
}
|
|
11146
|
-
/**
|
|
10983
|
+
*/_mouseleaveFun(e){if(this.readOnly)return;this._isOver=false;this._moveEndOrTouchEndFun(e);}
|
|
10984
|
+
/**
|
|
11147
10985
|
* 鼠标抬起事件监听
|
|
11148
10986
|
* @returns
|
|
11149
|
-
*/
|
|
11150
|
-
|
|
11151
|
-
}
|
|
11152
|
-
/**
|
|
10987
|
+
*/_mouseUpFun(e){this._moveEndOrTouchEndFun(e);}
|
|
10988
|
+
/**
|
|
11153
10989
|
* 鼠标移动事件监听
|
|
11154
10990
|
* @param e - 鼠标事件
|
|
11155
10991
|
* @returns
|
|
11156
|
-
*/
|
|
11157
|
-
|
|
11158
|
-
|
|
11159
|
-
|
|
11160
|
-
|
|
11161
|
-
|
|
11162
|
-
|
|
11163
|
-
|
|
11164
|
-
|
|
11165
|
-
|
|
11166
|
-
new Date(// prettier-ignore
|
|
11167
|
-
this._currentTime.getTime() + parseInt((e.pageX - this._width / 2) / this._curScaleSpacing * this._timeWidthArray[0] + "", 10) * 1000);
|
|
11168
|
-
}
|
|
11169
|
-
/**
|
|
10992
|
+
*/_mousemoveFun(e){if(this.readOnly)return;if(this._isMouseDown&&this._isOver)
|
|
10993
|
+
// 鼠标按下位置和移动位置的偏移量
|
|
10994
|
+
this._moveUpdateFun(e.pageX);else {const left=parseInt(this.$container.offsetLeft+"",10);this._mousePosition=e.pageX-left;this._update();// 更新画面
|
|
10995
|
+
}
|
|
10996
|
+
// const time = new Date(
|
|
10997
|
+
// // prettier-ignore
|
|
10998
|
+
// this.current.getTime() + parseInt(((e.pageX - this.width / 2) / this._curScaleSpacing ) * this._timeWidthArray[0] + "", 10) * 1000,
|
|
10999
|
+
// );
|
|
11000
|
+
}
|
|
11001
|
+
/**
|
|
11170
11002
|
* 鼠标滚轮滚动
|
|
11171
11003
|
* @param e - 鼠标滚轮滚动事件
|
|
11172
11004
|
* @returns
|
|
11173
|
-
*/
|
|
11174
|
-
|
|
11175
|
-
|
|
11176
|
-
|
|
11177
|
-
|
|
11178
|
-
|
|
11179
|
-
|
|
11180
|
-
|
|
11181
|
-
|
|
11182
|
-
|
|
11183
|
-
|
|
11184
|
-
|
|
11185
|
-
|
|
11186
|
-
|
|
11187
|
-
|
|
11188
|
-
|
|
11189
|
-
|
|
11190
|
-
/**
|
|
11005
|
+
*/_mousewheelFun(e){e.preventDefault();// 阻止默认滚动行为
|
|
11006
|
+
// eslint-disable-next-line no-useless-return
|
|
11007
|
+
if(this.readOnly)return;
|
|
11008
|
+
// if (this._isCtrlKeyDown) {
|
|
11009
|
+
// const zoom = e.deltaY > 0 ? -this.options.wheelSpeed : this.options.wheelSpeed;
|
|
11010
|
+
// this._timeWidth = +(this._timeWidth + zoom).toFixed(2);
|
|
11011
|
+
// if (this._timeWidth <= 0) {
|
|
11012
|
+
// this._timeWidth = 0;
|
|
11013
|
+
// } else if (this._timeWidth >= TIME_WIDTH.length) {
|
|
11014
|
+
// this._timeWidth = TIME_WIDTH.length - 0.01;
|
|
11015
|
+
// }
|
|
11016
|
+
// this._update({
|
|
11017
|
+
// timeWidth: Math.floor(this._timeWidth),
|
|
11018
|
+
// });
|
|
11019
|
+
// }
|
|
11020
|
+
}
|
|
11021
|
+
/**
|
|
11191
11022
|
* ctrl键按下事件
|
|
11192
11023
|
* @param e - 键盘按下事件
|
|
11193
|
-
*/
|
|
11194
|
-
|
|
11195
|
-
this._isCtrlKeyDown = true;
|
|
11196
|
-
}
|
|
11197
|
-
}
|
|
11198
|
-
/**
|
|
11024
|
+
*/_ctrlKeyDownFun(e){if(e.ctrlKey||e.key==="Control"){console.log("Ctrl 键被按下");this._isCtrlKeyDown=true;}}
|
|
11025
|
+
/**
|
|
11199
11026
|
* ctrl键抬起事件
|
|
11200
11027
|
* @param e - 键盘按下事件
|
|
11201
|
-
*/
|
|
11202
|
-
|
|
11203
|
-
|
|
11204
|
-
|
|
11205
|
-
|
|
11206
|
-
// ----------------------------------------------------------------------
|
|
11207
|
-
// touch
|
|
11208
|
-
// ----------------------------------------------------------------------
|
|
11209
|
-
/**
|
|
11028
|
+
*/_ctrlKeyUpFun(e){if(e.ctrlKey||e.key==="Control"){console.log("Ctrl 键UP");this._isCtrlKeyDown=false;}}
|
|
11029
|
+
// ----------------------------------------------------------------------
|
|
11030
|
+
// touch
|
|
11031
|
+
// ----------------------------------------------------------------------
|
|
11032
|
+
/**
|
|
11210
11033
|
* 触摸距离
|
|
11211
11034
|
* @param touches - 两指触摸点
|
|
11212
11035
|
* @returns
|
|
11213
|
-
*/
|
|
11214
|
-
|
|
11215
|
-
|
|
11216
|
-
const dy = touch2.clientY - touch1.clientY;
|
|
11217
|
-
return Math.sqrt(dx * dx + dy * dy);
|
|
11218
|
-
}
|
|
11219
|
-
/**
|
|
11036
|
+
*/
|
|
11037
|
+
_getTouchDistance(touches){const[touch1,touch2]=touches;const dx=touch2.clientX-touch1.clientX;const dy=touch2.clientY-touch1.clientY;return Math.sqrt(dx*dx+dy*dy)}
|
|
11038
|
+
/**
|
|
11220
11039
|
* 触摸开始
|
|
11221
11040
|
* @param e - 触摸事件
|
|
11222
11041
|
* @returns
|
|
11223
|
-
*/
|
|
11224
|
-
|
|
11225
|
-
|
|
11226
|
-
|
|
11227
|
-
|
|
11228
|
-
|
|
11229
|
-
|
|
11230
|
-
|
|
11231
|
-
this._mousePosition = touch.clientX;
|
|
11232
|
-
// this._touchmoveFun(e);
|
|
11233
|
-
} else if (e.touches.length === 2) {
|
|
11234
|
-
// 双指
|
|
11235
|
-
this._lastTouchDist = this._getTouchDistance(e.touches);
|
|
11236
|
-
}
|
|
11237
|
-
}
|
|
11238
|
-
/**
|
|
11042
|
+
*/_touchstartFun(e){if(this.readOnly)return;this._oldTime=this.current;this._isOver=true;if(e.touches.length===1){
|
|
11043
|
+
// 单指
|
|
11044
|
+
const touch=e.touches[0];this._isMouseDown=true;this._mousePosition=touch.clientX;
|
|
11045
|
+
// this._touchmoveFun(e);
|
|
11046
|
+
}else if(e.touches.length===2){
|
|
11047
|
+
// 双指
|
|
11048
|
+
this._lastTouchDist=this._getTouchDistance(e.touches);console.warn("_touchstartFun",this._lastTouchDist);}}
|
|
11049
|
+
/**
|
|
11239
11050
|
* 触摸移动
|
|
11240
11051
|
* @param e - 触摸事件
|
|
11241
11052
|
* @returns
|
|
11242
|
-
*/
|
|
11243
|
-
|
|
11244
|
-
|
|
11245
|
-
|
|
11246
|
-
|
|
11247
|
-
|
|
11248
|
-
|
|
11249
|
-
|
|
11250
|
-
|
|
11251
|
-
|
|
11252
|
-
|
|
11253
|
-
|
|
11254
|
-
|
|
11255
|
-
// // 限制缩放范围
|
|
11256
|
-
// scale = Math.max(0.5, Math.min(3, scale));
|
|
11257
|
-
// img.style.transform = `scale(${scale})`;
|
|
11258
|
-
// lastDist = newDist;
|
|
11259
|
-
}
|
|
11260
|
-
}
|
|
11261
|
-
/**
|
|
11053
|
+
*/_touchmoveFun(e){e.preventDefault();// 防止页面缩放
|
|
11054
|
+
e.stopPropagation();if(this.readOnly)return;console.warn(e.touches.length);if(e.touches.length===1){
|
|
11055
|
+
// 单指
|
|
11056
|
+
const touch=e.touches[0];this._moveUpdateFun(touch.clientX);}else if(e.touches.length===2){
|
|
11057
|
+
// 双指
|
|
11058
|
+
const newDist=this._getTouchDistance(e.touches);const zoom=newDist/this._lastTouchDist;console.warn("_touchmoveFun",this._lastTouchDist,zoom);
|
|
11059
|
+
// scale *= zoom;
|
|
11060
|
+
// // 限制缩放范围
|
|
11061
|
+
// scale = Math.max(0.5, Math.min(3, scale));
|
|
11062
|
+
// img.style.transform = `scale(${scale})`;
|
|
11063
|
+
// lastDist = newDist;
|
|
11064
|
+
}}
|
|
11065
|
+
/**
|
|
11262
11066
|
* 触摸结束
|
|
11263
11067
|
* @param e - 触摸事件
|
|
11264
11068
|
* @returns
|
|
11265
|
-
*/
|
|
11266
|
-
|
|
11267
|
-
this._moveEndOrTouchEndFun(e);
|
|
11268
|
-
}
|
|
11269
|
-
/**
|
|
11069
|
+
*/_touchendFun(e){if(this.readOnly)return;this._moveEndOrTouchEndFun(e);}
|
|
11070
|
+
/**
|
|
11270
11071
|
* 拖动结束
|
|
11271
11072
|
* @returns
|
|
11272
|
-
*/
|
|
11273
|
-
|
|
11274
|
-
if (this._isMouseDown) {
|
|
11275
|
-
this._isMouseDown = false;
|
|
11276
|
-
if (this._moved) {
|
|
11277
|
-
this._moved = false;
|
|
11278
|
-
this._update({
|
|
11279
|
-
currentTime: this._currentTime
|
|
11280
|
-
});
|
|
11281
|
-
this._oldTime = this._currentTime;
|
|
11282
|
-
this._options.onDragEnd == null ? void 0 : this._options.onDragEnd.call(this._options, this._currentTime, this._isOver);
|
|
11283
|
-
}
|
|
11284
|
-
if (this._isOver && Math.abs(this._mousePosition - (e.pageX || e.clientX)) > 5) {
|
|
11285
|
-
this._options.onChange == null ? void 0 : this._options.onChange.call(this._options, this._currentTime);
|
|
11286
|
-
}
|
|
11287
|
-
this._mousePosition = 0;
|
|
11288
|
-
this._lastTouchDist = 0;
|
|
11289
|
-
}
|
|
11290
|
-
}
|
|
11291
|
-
/**
|
|
11073
|
+
*/_moveEndOrTouchEndFun(e){e.preventDefault();if(this.readOnly)return;if(this._isMouseDown){this._isMouseDown=false;if(this._moved){this._moved=false;this._update({current:this.current});this._oldTime=this.current;this.options.onDragEnd==null?void 0:this.options.onDragEnd.call(this.options,this.current,this._isOver);}if(this._isOver&&Math.abs(this._mousePosition-(e.pageX||0))>5)this.options.onChange==null?void 0:this.options.onChange.call(this.options,this.current);this._mousePosition=0;this._lastTouchDist=0;}}
|
|
11074
|
+
/**
|
|
11292
11075
|
* 移动更新时间
|
|
11293
11076
|
* @param x - 移动的x坐标
|
|
11294
11077
|
* @returns
|
|
11295
|
-
*/
|
|
11296
|
-
|
|
11297
|
-
|
|
11298
|
-
|
|
11299
|
-
|
|
11300
|
-
|
|
11301
|
-
|
|
11302
|
-
|
|
11303
|
-
|
|
11304
|
-
|
|
11305
|
-
});
|
|
11306
|
-
this._options.onDragging == null ? void 0 : this._options.onDragging.call(this._options, new Date(currentTime));
|
|
11307
|
-
}
|
|
11308
|
-
this._moved = true;
|
|
11309
|
-
}
|
|
11310
|
-
constructor(container, options){
|
|
11311
|
-
this._$canvas = null;
|
|
11312
|
-
this._ctx = null;
|
|
11313
|
-
this._width = 0;
|
|
11314
|
-
this._height = 0;
|
|
11315
|
-
this._currentTime = new Date(new Date().setHours(0, 0, 0, 0));
|
|
11316
|
-
this._timeWidth = 0;
|
|
11317
|
-
/** 时间刻度宽度 [刻度间隔秒数s, 刻度间隔宽度px, 长刻度间隔短刻度个数, 中文说明] */ this._timeWidthArray = TIME_WIDTH[0];
|
|
11318
|
-
this._centerPositionX = 0;
|
|
11319
|
-
this._timeSections = [];
|
|
11320
|
-
/** 只读 */ this._readOnly = false;
|
|
11321
|
-
// mouse
|
|
11322
|
-
this._isMouseDown = false;
|
|
11323
|
-
this._mousePosition = 0; // 鼠标在画布中X轴的位置
|
|
11324
|
-
this._oldTime = null;
|
|
11325
|
-
this._isOver = false;
|
|
11326
|
-
this._moved = false;
|
|
11327
|
-
this._isCtrlKeyDown = false;
|
|
11328
|
-
this._destroyed = false;
|
|
11329
|
-
this._lastTouchDist = 0;
|
|
11330
|
-
this.$container = container;
|
|
11331
|
-
// prettier-ignore
|
|
11332
|
-
this._options = Object.assign({}, TIMELINE_DEFAULT_OPTIONS, options);
|
|
11333
|
-
this._mousemoveFun = this._mousemoveFun.bind(this);
|
|
11334
|
-
this._mouseoverFun = this._mouseoverFun.bind(this);
|
|
11335
|
-
this._mouseleaveFun = this._mouseleaveFun.bind(this);
|
|
11336
|
-
this._mousedownFun = this._mousedownFun.bind(this);
|
|
11337
|
-
this._mouseUpFun = this._mouseUpFun.bind(this);
|
|
11338
|
-
this._mousewheelFun = this._mousewheelFun.bind(this);
|
|
11339
|
-
this._touchstartFun = this._touchstartFun.bind(this);
|
|
11340
|
-
this._touchmoveFun = this._touchmoveFun.bind(this);
|
|
11341
|
-
this._touchendFun = this._touchendFun.bind(this);
|
|
11342
|
-
this._ctrlKeyDownFun = this._ctrlKeyDownFun.bind(this);
|
|
11343
|
-
this._ctrlKeyUpFun = this._ctrlKeyUpFun.bind(this);
|
|
11344
|
-
this._init();
|
|
11345
|
-
}
|
|
11346
|
-
};
|
|
11347
|
-
TimeLine$2.TIME_WIDTH = TIME_WIDTH;
|
|
11078
|
+
*/_moveUpdateFun(x){
|
|
11079
|
+
// 鼠标按下位置和移动位置的偏移量
|
|
11080
|
+
const mouseOffset=this._mousePosition-x;
|
|
11081
|
+
// fix点击引起mousemove的问题
|
|
11082
|
+
if(mouseOffset===0)return;if(this._oldTime){
|
|
11083
|
+
// prettier-ignore
|
|
11084
|
+
const currentTime=this._oldTime.getTime()+parseInt(mouseOffset/this._curScaleSpacing*this._timeWidthArray[0]+"",10)*1e3;this._update({current:new Date(currentTime)});this.options.onDragging==null?void 0:this.options.onDragging.call(this.options,new Date(currentTime));}this._moved=true;}constructor(container,options){super(container,deepmerge(_$TIMELINE_DEFAULT_OPTIONS$_,options,{clone:true})),this._$canvas=null,this._ctx=null,/** 时间刻度宽度 [刻度间隔秒数s, 刻度间隔宽度px, 长刻度间隔短刻度个数, 中文说明] */this._timeWidthArray=TIME_WIDTH[0],this._centerPositionX=0,// mouse
|
|
11085
|
+
this._isMouseDown=false,this._mousePosition=0,this._oldTime=null,this._isOver=false,this._moved=false,this._isCtrlKeyDown=false,this._lastTouchDist=0;this.$container=container;
|
|
11086
|
+
// prettier-ignore
|
|
11087
|
+
console.log("TimeLine dpr",JSON.stringify(this.options));this._mousemoveFun=this._mousemoveFun.bind(this);this._mouseoverFun=this._mouseoverFun.bind(this);this._mouseleaveFun=this._mouseleaveFun.bind(this);this._mousedownFun=this._mousedownFun.bind(this);this._mouseUpFun=this._mouseUpFun.bind(this);this._mousewheelFun=this._mousewheelFun.bind(this);this._touchstartFun=this._touchstartFun.bind(this);this._touchmoveFun=this._touchmoveFun.bind(this);this._touchendFun=this._touchendFun.bind(this);this._ctrlKeyDownFun=this._ctrlKeyDownFun.bind(this);this._ctrlKeyUpFun=this._ctrlKeyUpFun.bind(this);this._init();}}TimeLine.TIME_WIDTH=TIME_WIDTH;
|
|
11348
11088
|
|
|
11349
11089
|
function _extends$4() {
|
|
11350
11090
|
_extends$4 = Object.assign || function(target) {
|
|
@@ -11382,86 +11122,109 @@
|
|
|
11382
11122
|
}
|
|
11383
11123
|
/**
|
|
11384
11124
|
* 回放时间轴控件
|
|
11385
|
-
*/ var
|
|
11386
|
-
_inherits$5(
|
|
11387
|
-
function
|
|
11125
|
+
*/ var TimeLineControl = /*#__PURE__*/ function(Control) {
|
|
11126
|
+
_inherits$5(TimeLineControl, Control);
|
|
11127
|
+
function TimeLineControl(options) {
|
|
11388
11128
|
var _this;
|
|
11389
11129
|
var _this__options_props, _this__options;
|
|
11390
11130
|
_this = Control.call(this, _extends$4({}, options, {
|
|
11391
11131
|
tagName: 'div',
|
|
11392
11132
|
controlType: 'block',
|
|
11393
11133
|
classNameSuffix: 'time-line'
|
|
11394
|
-
})) || this, _this.records = [];
|
|
11134
|
+
})) || this, _this._$add = null, _this._$reduce = null, _this._currentTime = 0, _this.records = [];
|
|
11135
|
+
_this._currentTime = 0;
|
|
11395
11136
|
_this._options = options;
|
|
11396
11137
|
_this.records = ((_this__options = _this._options) == null ? void 0 : (_this__options_props = _this__options.props) == null ? void 0 : _this__options_props.recordList) || [];
|
|
11397
11138
|
_this._render();
|
|
11398
11139
|
_this.on(EVENTS.setAllDayRecTimes, function(records) {
|
|
11399
11140
|
var // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
11400
|
-
|
|
11141
|
+
_this_timeLineUtil_updateTimeSections, _this_timeLineUtil;
|
|
11401
11142
|
_this.records = records;
|
|
11402
|
-
(_this_timeLineUtil = _this.timeLineUtil) == null ? void 0 : (
|
|
11143
|
+
(_this_timeLineUtil = _this.timeLineUtil) == null ? void 0 : (_this_timeLineUtil_updateTimeSections = _this_timeLineUtil.updateTimeSections) == null ? void 0 : _this_timeLineUtil_updateTimeSections.call(_this_timeLineUtil, records);
|
|
11403
11144
|
});
|
|
11404
11145
|
_this.on(EVENTS.getOSDTime, function(time) {
|
|
11405
|
-
|
|
11406
|
-
|
|
11407
|
-
|
|
11146
|
+
if (time) {
|
|
11147
|
+
var // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
11148
|
+
_this_timeLineUtil_update, _this_timeLineUtil;
|
|
11149
|
+
var date = new Date(time * 1000);
|
|
11150
|
+
_this._currentTime = date.getTime();
|
|
11151
|
+
(_this_timeLineUtil = _this.timeLineUtil) == null ? void 0 : (_this_timeLineUtil_update = _this_timeLineUtil.update) == null ? void 0 : _this_timeLineUtil_update.call(_this_timeLineUtil, date);
|
|
11152
|
+
}
|
|
11408
11153
|
});
|
|
11409
11154
|
return _this;
|
|
11410
11155
|
}
|
|
11411
|
-
var _proto =
|
|
11156
|
+
var _proto = TimeLineControl.prototype;
|
|
11412
11157
|
_proto._render = function _render() {
|
|
11413
11158
|
var _this = this;
|
|
11414
|
-
var
|
|
11159
|
+
var _this_timeLineUtil_updateTimeSections, _this_timeLineUtil;
|
|
11415
11160
|
var _timeLineOptions = {
|
|
11416
|
-
|
|
11161
|
+
language: this._options.language || 'zh',
|
|
11162
|
+
coverQuery: this._options.coverQuery || '',
|
|
11417
11163
|
onChange: function(date) {
|
|
11418
|
-
_this.
|
|
11419
|
-
|
|
11164
|
+
if (_this._currentTime !== (date == null ? void 0 : date.getTime())) {
|
|
11165
|
+
_this._options.onChange == null ? void 0 : _this._options.onChange.call(_this._options, date);
|
|
11166
|
+
_this.emit(EVENTS.control.timeLineChange, date);
|
|
11167
|
+
}
|
|
11168
|
+
},
|
|
11169
|
+
onPickerOpenChange: function(open) {
|
|
11170
|
+
_this.emit(EVENTS.control.timeLinePanelOpenChange, open);
|
|
11171
|
+
},
|
|
11172
|
+
// 2025-10-27 仅移动端支持
|
|
11173
|
+
onPickerSelect: function(item) {
|
|
11174
|
+
var date = null;
|
|
11175
|
+
try {
|
|
11176
|
+
if ((item.startTime + '').length === 10) date = new Date(item.startTime * 1000);
|
|
11177
|
+
else if ((item.startTime + '').length === 13) date = new Date(item.startTime);
|
|
11178
|
+
else date = new Date(item.startTime);
|
|
11179
|
+
_this._options.onChange == null ? void 0 : _this._options.onChange.call(_this._options, date);
|
|
11180
|
+
_this.emit(EVENTS.control.timeLineChange, date);
|
|
11181
|
+
} catch (error) {
|
|
11182
|
+
}
|
|
11420
11183
|
}
|
|
11421
11184
|
};
|
|
11422
11185
|
if (isMobile$1()) {
|
|
11423
|
-
this.timeLineUtil = new
|
|
11186
|
+
this.timeLineUtil = new MobileTimeLine(this.$container, _timeLineOptions);
|
|
11424
11187
|
} else {
|
|
11425
|
-
this.timeLineUtil = new TimeLine
|
|
11188
|
+
this.timeLineUtil = new TimeLine(this.$container, _timeLineOptions);
|
|
11426
11189
|
this._renderAddReduce();
|
|
11427
11190
|
}
|
|
11428
|
-
(_this_timeLineUtil = this.timeLineUtil) == null ? void 0 : (
|
|
11191
|
+
(_this_timeLineUtil = this.timeLineUtil) == null ? void 0 : (_this_timeLineUtil_updateTimeSections = _this_timeLineUtil.updateTimeSections) == null ? void 0 : _this_timeLineUtil_updateTimeSections.call(_this_timeLineUtil, this.records);
|
|
11429
11192
|
this.timeLineUtil.update(new Date());
|
|
11430
11193
|
};
|
|
11431
11194
|
_proto.setWidth = function setWidth(width) {
|
|
11432
|
-
if (!isMobile$1()) this.timeLineUtil.width
|
|
11195
|
+
if (!isMobile$1()) this.timeLineUtil.resize(width);
|
|
11433
11196
|
};
|
|
11434
11197
|
_proto._renderAddReduce = function _renderAddReduce() {
|
|
11435
11198
|
var _this = this;
|
|
11436
|
-
this
|
|
11437
|
-
this
|
|
11438
|
-
this
|
|
11439
|
-
this
|
|
11199
|
+
this._$add = document.createElement('span');
|
|
11200
|
+
this._$add.classList.add("" + PREFIX_CLASS + "-time-line-scale-add");
|
|
11201
|
+
this._$add.innerHTML = IconComponents.add();
|
|
11202
|
+
this._$add.addEventListener('click', function() {
|
|
11440
11203
|
if (_this.timeLineUtil) {
|
|
11441
|
-
var currentScale = Math.floor(_this.timeLineUtil.
|
|
11442
|
-
_this.timeLineUtil.
|
|
11204
|
+
var currentScale = Math.floor(_this.timeLineUtil.timeWidth);
|
|
11205
|
+
_this.timeLineUtil.setTimeWidth(currentScale + 1);
|
|
11443
11206
|
}
|
|
11444
11207
|
});
|
|
11445
|
-
this
|
|
11446
|
-
this
|
|
11447
|
-
this
|
|
11448
|
-
this
|
|
11208
|
+
this._$reduce = document.createElement('span');
|
|
11209
|
+
this._$reduce.classList.add("" + PREFIX_CLASS + "-time-line-scale-sub");
|
|
11210
|
+
this._$reduce.innerHTML = IconComponents.reduce();
|
|
11211
|
+
this._$reduce.addEventListener('click', function() {
|
|
11449
11212
|
if (_this.timeLineUtil) {
|
|
11450
|
-
var currentScale = Math.floor(_this.timeLineUtil.
|
|
11451
|
-
_this.timeLineUtil.
|
|
11213
|
+
var currentScale = Math.floor(_this.timeLineUtil.timeWidth);
|
|
11214
|
+
_this.timeLineUtil.setTimeWidth(currentScale - 1);
|
|
11452
11215
|
}
|
|
11453
11216
|
});
|
|
11454
|
-
this.$container.appendChild(this
|
|
11455
|
-
this.$container.appendChild(this
|
|
11217
|
+
this.$container.appendChild(this._$add);
|
|
11218
|
+
this.$container.appendChild(this._$reduce);
|
|
11456
11219
|
};
|
|
11457
11220
|
_proto.destroy = function destroy() {
|
|
11458
|
-
if (this
|
|
11459
|
-
this
|
|
11460
|
-
this
|
|
11221
|
+
if (this._$add) {
|
|
11222
|
+
this._$add.remove();
|
|
11223
|
+
this._$add = null;
|
|
11461
11224
|
}
|
|
11462
|
-
if (this
|
|
11463
|
-
this
|
|
11464
|
-
this
|
|
11225
|
+
if (this._$reduce) {
|
|
11226
|
+
this._$reduce.remove();
|
|
11227
|
+
this._$reduce = null;
|
|
11465
11228
|
}
|
|
11466
11229
|
if (this.timeLineUtil) {
|
|
11467
11230
|
this.timeLineUtil.destroy();
|
|
@@ -11475,7 +11238,7 @@
|
|
|
11475
11238
|
*/ _proto._onControlClick = function _onControlClick(e) {
|
|
11476
11239
|
this._options.onClick == null ? void 0 : this._options.onClick.call(this._options, e);
|
|
11477
11240
|
};
|
|
11478
|
-
return
|
|
11241
|
+
return TimeLineControl;
|
|
11479
11242
|
}(Control);
|
|
11480
11243
|
|
|
11481
11244
|
function _extends$3() {
|
|
@@ -11564,8 +11327,8 @@
|
|
|
11564
11327
|
globalFullscreen: GlobalFullscreen,
|
|
11565
11328
|
rec: Rec,
|
|
11566
11329
|
speed: Speed,
|
|
11567
|
-
date:
|
|
11568
|
-
timeLine:
|
|
11330
|
+
date: DatePickerControl,
|
|
11331
|
+
timeLine: TimeLineControl
|
|
11569
11332
|
};
|
|
11570
11333
|
|
|
11571
11334
|
/* eslint-disable @typescript-eslint/no-non-null-assertion */ function _inherits$3(subClass, superClass) {
|
|
@@ -12364,14 +12127,15 @@
|
|
|
12364
12127
|
var _renderTimeLine = function(theme, container, props) {
|
|
12365
12128
|
if (props === void 0) props = {};
|
|
12366
12129
|
if (!theme.controls.timeLineControl && theme.options.timeLineOptions !== null) {
|
|
12367
|
-
var _theme_options;
|
|
12130
|
+
var _theme_urlInfo, _theme_options;
|
|
12368
12131
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
12369
12132
|
theme.controls.timeLineControl = new Controls['timeLine'](_extends$1({
|
|
12370
12133
|
getPopupContainer: function() {
|
|
12371
12134
|
return container;
|
|
12372
12135
|
},
|
|
12373
12136
|
language: theme.options.language,
|
|
12374
|
-
locales: theme.i18n.translations
|
|
12137
|
+
locales: theme.i18n.translations,
|
|
12138
|
+
coverQuery: ((_theme_urlInfo = theme.urlInfo) == null ? void 0 : _theme_urlInfo.validateCode) ? "decodekey=" + theme.urlInfo.validateCode : ''
|
|
12375
12139
|
}, ((_theme_options = theme.options) == null ? void 0 : _theme_options["timeLineOptions"]) || {}, {
|
|
12376
12140
|
props: props
|
|
12377
12141
|
}));
|
|
@@ -12921,7 +12685,7 @@
|
|
|
12921
12685
|
// ==============================================================================================
|
|
12922
12686
|
/** 初始化配置项 */ _proto._initOptions = function _initOptions(options) {
|
|
12923
12687
|
if (options === void 0) options = {};
|
|
12924
|
-
var _this_options_loggerOptions
|
|
12688
|
+
var _this_options_loggerOptions;
|
|
12925
12689
|
this.options = deepmerge(THEME_DEFAULT_OPTIONS, options, {
|
|
12926
12690
|
clone: false
|
|
12927
12691
|
});
|
|
@@ -12935,7 +12699,7 @@
|
|
|
12935
12699
|
}
|
|
12936
12700
|
if (!this.$container) throw new Error('container option is required!');
|
|
12937
12701
|
if ([
|
|
12938
|
-
'
|
|
12702
|
+
'VIDOE',
|
|
12939
12703
|
'CANVAS'
|
|
12940
12704
|
].includes(this.$container.tagName)) {
|
|
12941
12705
|
throw new Error('container node cannot be video or canvas!');
|
|
@@ -12946,10 +12710,6 @@
|
|
|
12946
12710
|
}));
|
|
12947
12711
|
this.logger.log(navigator.userAgent || 'unknown');
|
|
12948
12712
|
this.logger.log('[Theme Version] ', Theme.THEME_VERSION);
|
|
12949
|
-
if ('container' in this.options) {
|
|
12950
|
-
// JSON 不能序列化dom节点, 不要使用 this.options.container, 请使用 this.container
|
|
12951
|
-
delete this.options.container;
|
|
12952
|
-
}
|
|
12953
12713
|
this.logger.log(JSON.stringify(this.options));
|
|
12954
12714
|
var language = this.options.language || 'zh';
|
|
12955
12715
|
var locales = deepmerge({
|
|
@@ -12962,11 +12722,6 @@
|
|
|
12962
12722
|
this.i18n = new I18n(locales, {
|
|
12963
12723
|
defaultLocale: language
|
|
12964
12724
|
});
|
|
12965
|
-
// 默认清晰度列表
|
|
12966
|
-
if (((_this_options_definitionOptions = this.options.definitionOptions) == null ? void 0 : (_this_options_definitionOptions_list = _this_options_definitionOptions.list) == null ? void 0 : _this_options_definitionOptions_list.length) > 0 || ((_this_options_videoLevelList = this.options.videoLevelList) == null ? void 0 : _this_options_videoLevelList.length) > 0) {
|
|
12967
|
-
var _this_options_definitionOptions1;
|
|
12968
|
-
this.videoLevelList = ((_this_options_definitionOptions1 = this.options.definitionOptions) == null ? void 0 : _this_options_definitionOptions1.list) || this.options.videoLevelList;
|
|
12969
|
-
}
|
|
12970
12725
|
};
|
|
12971
12726
|
/**
|
|
12972
12727
|
* 初始化设置类名和设置宽高
|
|
@@ -13861,7 +13616,7 @@
|
|
|
13861
13616
|
zh: zh,
|
|
13862
13617
|
en: en
|
|
13863
13618
|
};
|
|
13864
|
-
/** 版本号 @since 0.0.1 */ Theme.THEME_VERSION = '0.0
|
|
13619
|
+
/** 版本号 @since 0.0.1 */ Theme.THEME_VERSION = '1.0.0';
|
|
13865
13620
|
|
|
13866
13621
|
// 不要动这里的代码, 这个出口是为了编译成 umd 规范的文件
|
|
13867
13622
|
|