@whitesev/pops 1.8.6 → 1.8.8
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.amd.js +87 -28
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +87 -28
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +87 -28
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +87 -28
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +87 -28
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +87 -28
- package/dist/index.umd.js.map +1 -1
- package/dist/types/src/components/tooltip/index.d.ts +34 -5
- package/package.json +1 -1
- package/src/components/tooltip/index.ts +101 -28
package/dist/index.iife.js
CHANGED
|
@@ -9461,8 +9461,8 @@ var pops = (function () {
|
|
|
9461
9461
|
$data = {
|
|
9462
9462
|
config: null,
|
|
9463
9463
|
guid: null,
|
|
9464
|
-
|
|
9465
|
-
|
|
9464
|
+
timeId_close_TouchEvent: [],
|
|
9465
|
+
timeId_close_MouseEvent: [],
|
|
9466
9466
|
};
|
|
9467
9467
|
constructor(config, guid, ShadowInfo) {
|
|
9468
9468
|
this.$data.config = config;
|
|
@@ -9480,6 +9480,7 @@ var pops = (function () {
|
|
|
9480
9480
|
this.changeZIndex();
|
|
9481
9481
|
this.changePosition();
|
|
9482
9482
|
if (!this.$data.config.alwaysShow) {
|
|
9483
|
+
this.offEvent();
|
|
9483
9484
|
this.onEvent();
|
|
9484
9485
|
}
|
|
9485
9486
|
}
|
|
@@ -9634,23 +9635,60 @@ var pops = (function () {
|
|
|
9634
9635
|
this.offAnimationFinishEvent();
|
|
9635
9636
|
this.offShowEvent();
|
|
9636
9637
|
this.offCloseEvent();
|
|
9638
|
+
this.offMouseEnterEvent();
|
|
9639
|
+
this.offMouseLeaveEvent();
|
|
9640
|
+
}
|
|
9641
|
+
/**
|
|
9642
|
+
* 添加关闭的timeId
|
|
9643
|
+
* @param type
|
|
9644
|
+
* @param timeId
|
|
9645
|
+
*/
|
|
9646
|
+
addCloseTimeoutId(type, timeId) {
|
|
9647
|
+
if (type === "MouseEvent") {
|
|
9648
|
+
this.$data.timeId_close_MouseEvent.push(timeId);
|
|
9649
|
+
}
|
|
9650
|
+
else {
|
|
9651
|
+
this.$data.timeId_close_TouchEvent.push(timeId);
|
|
9652
|
+
}
|
|
9653
|
+
}
|
|
9654
|
+
/**
|
|
9655
|
+
* 清除延迟的timeId
|
|
9656
|
+
* @param type 事件类型
|
|
9657
|
+
*/
|
|
9658
|
+
clearCloseTimeoutId(type, timeId) {
|
|
9659
|
+
let timeIdList = type === "MouseEvent"
|
|
9660
|
+
? this.$data.timeId_close_MouseEvent
|
|
9661
|
+
: this.$data.timeId_close_TouchEvent;
|
|
9662
|
+
for (let index = 0; index < timeIdList.length; index++) {
|
|
9663
|
+
const currentTimeId = timeIdList[index];
|
|
9664
|
+
if (typeof timeId === "number") {
|
|
9665
|
+
// 只清除一个
|
|
9666
|
+
if (timeId == currentTimeId) {
|
|
9667
|
+
clearTimeout(timeId);
|
|
9668
|
+
timeIdList.splice(index, 1);
|
|
9669
|
+
break;
|
|
9670
|
+
}
|
|
9671
|
+
}
|
|
9672
|
+
else {
|
|
9673
|
+
clearTimeout(currentTimeId);
|
|
9674
|
+
timeIdList.splice(index, 1);
|
|
9675
|
+
index--;
|
|
9676
|
+
}
|
|
9677
|
+
}
|
|
9637
9678
|
}
|
|
9638
9679
|
/**
|
|
9639
9680
|
* 显示提示框
|
|
9640
9681
|
*/
|
|
9641
|
-
show() {
|
|
9682
|
+
show(...args) {
|
|
9683
|
+
let event = args[0];
|
|
9684
|
+
let eventType = event instanceof MouseEvent ? "MouseEvent" : "TouchEvent";
|
|
9685
|
+
this.clearCloseTimeoutId(eventType);
|
|
9642
9686
|
if (typeof this.$data.config.showBeforeCallBack === "function") {
|
|
9643
9687
|
let result = this.$data.config.showBeforeCallBack(this.$el.$toolTip);
|
|
9644
9688
|
if (typeof result === "boolean" && !result) {
|
|
9645
9689
|
return;
|
|
9646
9690
|
}
|
|
9647
9691
|
}
|
|
9648
|
-
for (let index = 0; index < this.$data.timeId_close.length; index++) {
|
|
9649
|
-
let timeId = this.$data.timeId_close[index];
|
|
9650
|
-
clearTimeout(timeId);
|
|
9651
|
-
this.$data.timeId_close.splice(index, 1);
|
|
9652
|
-
index--;
|
|
9653
|
-
}
|
|
9654
9692
|
if (!popsUtils.contains(this.$el.$shadowRoot, this.$el.$toolTip)) {
|
|
9655
9693
|
// 不在容器中,添加
|
|
9656
9694
|
this.init();
|
|
@@ -9690,7 +9728,10 @@ var pops = (function () {
|
|
|
9690
9728
|
*/
|
|
9691
9729
|
close(...args) {
|
|
9692
9730
|
let event = args[0];
|
|
9693
|
-
|
|
9731
|
+
let eventType = event instanceof MouseEvent ? "MouseEvent" : "TouchEvent";
|
|
9732
|
+
// 只判断鼠标事件
|
|
9733
|
+
// 其它的如Touch事件不做处理
|
|
9734
|
+
if (event && event instanceof MouseEvent) {
|
|
9694
9735
|
let $target = event.composedPath()[0];
|
|
9695
9736
|
// 如果是子元素触发的话,忽视
|
|
9696
9737
|
if ($target != this.$data.config.target) {
|
|
@@ -9709,11 +9750,13 @@ var pops = (function () {
|
|
|
9709
9750
|
this.$data.config.delayCloseTime = 100;
|
|
9710
9751
|
}
|
|
9711
9752
|
let timeId = setTimeout(() => {
|
|
9753
|
+
// 设置属性触发关闭动画
|
|
9754
|
+
this.clearCloseTimeoutId(eventType, timeId);
|
|
9712
9755
|
this.$el.$toolTip.setAttribute("data-motion", this.$el.$toolTip
|
|
9713
9756
|
.getAttribute("data-motion")
|
|
9714
9757
|
.replace("fadeIn", "fadeOut"));
|
|
9715
9758
|
}, this.$data.config.delayCloseTime);
|
|
9716
|
-
this
|
|
9759
|
+
this.addCloseTimeoutId(eventType, timeId);
|
|
9717
9760
|
if (typeof this.$data.config.closeAfterCallBack === "function") {
|
|
9718
9761
|
this.$data.config.closeAfterCallBack(this.$el.$toolTip);
|
|
9719
9762
|
}
|
|
@@ -9771,29 +9814,45 @@ var pops = (function () {
|
|
|
9771
9814
|
popsDOMUtils.off(this.$el.$toolTip, popsDOMUtils.getAnimationEndNameList(), this.animationFinishEvent.bind(this));
|
|
9772
9815
|
}
|
|
9773
9816
|
/**
|
|
9774
|
-
*
|
|
9817
|
+
* 鼠标|触摸进入事件
|
|
9818
|
+
*/
|
|
9819
|
+
mouseEnterEvent() {
|
|
9820
|
+
this.$el.$toolTip.style.animationPlayState = "paused";
|
|
9821
|
+
// if (parseInt(getComputedStyle(toolTipElement)) > 0.5) {
|
|
9822
|
+
// toolTipElement.style.animationPlayState = "paused";
|
|
9823
|
+
// }
|
|
9824
|
+
}
|
|
9825
|
+
/**
|
|
9826
|
+
* 监听鼠标|触摸事件
|
|
9775
9827
|
*/
|
|
9776
9828
|
onMouseEnterEvent() {
|
|
9777
|
-
|
|
9778
|
-
|
|
9779
|
-
|
|
9780
|
-
|
|
9781
|
-
|
|
9782
|
-
|
|
9783
|
-
|
|
9784
|
-
|
|
9785
|
-
|
|
9786
|
-
|
|
9787
|
-
|
|
9788
|
-
|
|
9829
|
+
this.clearCloseTimeoutId("MouseEvent");
|
|
9830
|
+
this.clearCloseTimeoutId("TouchEvent");
|
|
9831
|
+
popsDOMUtils.on(this.$el.$toolTip, "mouseenter touchstart", this.mouseEnterEvent.bind(this), this.$data.config.eventOption);
|
|
9832
|
+
}
|
|
9833
|
+
/**
|
|
9834
|
+
* 取消监听鼠标|触摸事件
|
|
9835
|
+
*/
|
|
9836
|
+
offMouseEnterEvent() {
|
|
9837
|
+
popsDOMUtils.off(this.$el.$toolTip, "mouseenter touchstart", this.mouseEnterEvent.bind(this), this.$data.config.eventOption);
|
|
9838
|
+
}
|
|
9839
|
+
/**
|
|
9840
|
+
* 鼠标|触摸离开事件
|
|
9841
|
+
*/
|
|
9842
|
+
mouseLeaveEvent() {
|
|
9843
|
+
this.$el.$toolTip.style.animationPlayState = "running";
|
|
9789
9844
|
}
|
|
9790
9845
|
/**
|
|
9791
|
-
*
|
|
9846
|
+
* 监听鼠标|触摸离开事件
|
|
9792
9847
|
*/
|
|
9793
9848
|
onMouseLeaveEvent() {
|
|
9794
|
-
popsDOMUtils.on(this.$el.$toolTip, "mouseleave touchend", ()
|
|
9795
|
-
|
|
9796
|
-
|
|
9849
|
+
popsDOMUtils.on(this.$el.$toolTip, "mouseleave touchend", this.mouseLeaveEvent.bind(this), this.$data.config.eventOption);
|
|
9850
|
+
}
|
|
9851
|
+
/**
|
|
9852
|
+
* 取消监听鼠标|触摸离开事件
|
|
9853
|
+
*/
|
|
9854
|
+
offMouseLeaveEvent() {
|
|
9855
|
+
popsDOMUtils.off(this.$el.$toolTip, "mouseleave touchend", this.mouseLeaveEvent.bind(this), this.$data.config.eventOption);
|
|
9797
9856
|
}
|
|
9798
9857
|
}
|
|
9799
9858
|
class PopsTooltip {
|