@whitesev/pops 2.0.3 → 2.0.4
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 +138 -112
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +138 -112
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +138 -112
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +138 -112
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +138 -112
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +138 -112
- package/dist/index.umd.js.map +1 -1
- package/dist/types/src/Pops.d.ts +3 -3
- package/dist/types/src/components/searchSuggestion/indexType.d.ts +1 -1
- package/dist/types/src/types/event.d.ts +3 -3
- package/dist/types/src/types/mask.d.ts +1 -1
- package/dist/types/src/utils/PopsInstanceUtils.d.ts +3 -3
- package/package.json +1 -1
- package/src/Pops.ts +1 -1
- package/src/components/loading/index.ts +3 -0
- package/src/components/searchSuggestion/indexType.ts +1 -1
- package/src/handler/PopsHandler.ts +9 -11
- package/src/types/event.d.ts +3 -3
- package/src/types/mask.d.ts +1 -1
- package/src/utils/PopsDOMUtils.ts +21 -19
- package/src/utils/PopsInstanceUtils.ts +120 -96
package/dist/types/src/Pops.d.ts
CHANGED
|
@@ -158,9 +158,9 @@ declare class Pops {
|
|
|
158
158
|
getMaxZIndex(deviation?: number): number;
|
|
159
159
|
getKeyFrames(sheet: CSSStyleSheet): {};
|
|
160
160
|
removeInstance(moreLayerConfigList: PopsLayerCommonConfig[][], guid: string, isAll?: boolean): PopsLayerCommonConfig[][];
|
|
161
|
-
hide(popsType: PopsLayerMode, layerConfigList: PopsLayerCommonConfig[], guid: string, config: PopsAlertDetails | PopsDrawerDetails | PopsPromptDetails | PopsConfirmDetails | PopsIframeDetails | PopsLoadingDetails | PopsPanelDetails | PopsFolderDetails, animElement: HTMLElement, maskElement: HTMLElement): void
|
|
162
|
-
show(popsType: PopsLayerMode, layerConfigList: PopsLayerCommonConfig[], guid: string, config: PopsAlertDetails | PopsDrawerDetails | PopsPromptDetails | PopsConfirmDetails | PopsIframeDetails | PopsLoadingDetails | PopsPanelDetails | PopsFolderDetails, animElement: HTMLElement, maskElement
|
|
163
|
-
close(popsType: string, layerConfigList: PopsLayerCommonConfig[], guid: string, config: PopsAlertDetails | PopsDrawerDetails | PopsPromptDetails | PopsConfirmDetails | PopsIframeDetails | PopsLoadingDetails | PopsPanelDetails | PopsFolderDetails, animElement: HTMLElement): void
|
|
161
|
+
hide(popsType: PopsLayerMode, layerConfigList: PopsLayerCommonConfig[], guid: string, config: PopsAlertDetails | PopsDrawerDetails | PopsPromptDetails | PopsConfirmDetails | PopsIframeDetails | PopsLoadingDetails | PopsPanelDetails | PopsFolderDetails, animElement: HTMLElement, maskElement: HTMLElement): Promise<void>;
|
|
162
|
+
show(popsType: PopsLayerMode, layerConfigList: PopsLayerCommonConfig[], guid: string, config: PopsAlertDetails | PopsDrawerDetails | PopsPromptDetails | PopsConfirmDetails | PopsIframeDetails | PopsLoadingDetails | PopsPanelDetails | PopsFolderDetails, animElement: HTMLElement, maskElement?: HTMLElement): Promise<void>;
|
|
163
|
+
close(popsType: string, layerConfigList: PopsLayerCommonConfig[], guid: string, config: PopsAlertDetails | PopsDrawerDetails | PopsPromptDetails | PopsConfirmDetails | PopsIframeDetails | PopsLoadingDetails | PopsPanelDetails | PopsFolderDetails, animElement: HTMLElement): Promise<void>;
|
|
164
164
|
drag(moveElement: HTMLElement, options: {
|
|
165
165
|
dragElement: HTMLElement;
|
|
166
166
|
limit: boolean;
|
|
@@ -48,9 +48,9 @@ export interface PopsEventDetails {
|
|
|
48
48
|
/** 当前弹窗类型 */
|
|
49
49
|
mode: mode;
|
|
50
50
|
guid: guid;
|
|
51
|
-
close: () => void
|
|
52
|
-
hide: () => void
|
|
53
|
-
show: () => void
|
|
51
|
+
close: () => Promise<void>;
|
|
52
|
+
hide: () => Promise<void>;
|
|
53
|
+
show: () => Promise<void>;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
/**
|
|
@@ -64,7 +64,7 @@ export declare const PopsInstanceUtils: {
|
|
|
64
64
|
* @param animElement
|
|
65
65
|
* @param maskElement
|
|
66
66
|
*/
|
|
67
|
-
hide(popsType: PopsLayerMode, layerConfigList: PopsLayerCommonConfig[], guid: string, config: PopsAlertDetails | PopsDrawerDetails | PopsPromptDetails | PopsConfirmDetails | PopsIframeDetails | PopsLoadingDetails | PopsPanelDetails | PopsFolderDetails, animElement: HTMLElement, maskElement: HTMLElement): void
|
|
67
|
+
hide(popsType: PopsLayerMode, layerConfigList: PopsLayerCommonConfig[], guid: string, config: PopsAlertDetails | PopsDrawerDetails | PopsPromptDetails | PopsConfirmDetails | PopsIframeDetails | PopsLoadingDetails | PopsPanelDetails | PopsFolderDetails, animElement: HTMLElement, maskElement: HTMLElement): Promise<void>;
|
|
68
68
|
/**
|
|
69
69
|
* 显示
|
|
70
70
|
* @param popsType
|
|
@@ -74,7 +74,7 @@ export declare const PopsInstanceUtils: {
|
|
|
74
74
|
* @param animElement
|
|
75
75
|
* @param maskElement
|
|
76
76
|
*/
|
|
77
|
-
show(popsType: PopsLayerMode, layerConfigList: PopsLayerCommonConfig[], guid: string, config: PopsAlertDetails | PopsDrawerDetails | PopsPromptDetails | PopsConfirmDetails | PopsIframeDetails | PopsLoadingDetails | PopsPanelDetails | PopsFolderDetails, animElement: HTMLElement, maskElement
|
|
77
|
+
show(popsType: PopsLayerMode, layerConfigList: PopsLayerCommonConfig[], guid: string, config: PopsAlertDetails | PopsDrawerDetails | PopsPromptDetails | PopsConfirmDetails | PopsIframeDetails | PopsLoadingDetails | PopsPanelDetails | PopsFolderDetails, animElement: HTMLElement, maskElement?: HTMLElement): Promise<void>;
|
|
78
78
|
/**
|
|
79
79
|
* 关闭
|
|
80
80
|
* @param popsType
|
|
@@ -83,7 +83,7 @@ export declare const PopsInstanceUtils: {
|
|
|
83
83
|
* @param config
|
|
84
84
|
* @param animElement
|
|
85
85
|
*/
|
|
86
|
-
close(popsType: string, layerConfigList: PopsLayerCommonConfig[], guid: string, config: PopsAlertDetails | PopsDrawerDetails | PopsPromptDetails | PopsConfirmDetails | PopsIframeDetails | PopsLoadingDetails | PopsPanelDetails | PopsFolderDetails, animElement: HTMLElement): void
|
|
86
|
+
close(popsType: string, layerConfigList: PopsLayerCommonConfig[], guid: string, config: PopsAlertDetails | PopsDrawerDetails | PopsPromptDetails | PopsConfirmDetails | PopsIframeDetails | PopsLoadingDetails | PopsPanelDetails | PopsFolderDetails, animElement: HTMLElement): Promise<void>;
|
|
87
87
|
/**
|
|
88
88
|
* 拖拽元素
|
|
89
89
|
* 说明:
|
package/package.json
CHANGED
package/src/Pops.ts
CHANGED
|
@@ -79,6 +79,9 @@ export class PopsLoading {
|
|
|
79
79
|
maskHTML: maskHTML,
|
|
80
80
|
});
|
|
81
81
|
$mask = _handleMask_.maskElement;
|
|
82
|
+
// 遮罩层必须是跟随主内容
|
|
83
|
+
// 即设置主内容position: relative,mask:position: absolute
|
|
84
|
+
popsDOMUtils.css($mask, "position", "absolute !important");
|
|
82
85
|
elementList.push($mask);
|
|
83
86
|
}
|
|
84
87
|
let eventDetails = PopsHandler.handleLoadingEventDetails(
|
|
@@ -99,9 +99,7 @@ export const PopsHandler = {
|
|
|
99
99
|
animElement: HTMLElement;
|
|
100
100
|
maskHTML: string;
|
|
101
101
|
}
|
|
102
|
-
)
|
|
103
|
-
maskElement: HTMLDivElement;
|
|
104
|
-
} {
|
|
102
|
+
) {
|
|
105
103
|
let result = {
|
|
106
104
|
maskElement: popsUtils.parseTextToDOM<HTMLDivElement>(details.maskHTML),
|
|
107
105
|
};
|
|
@@ -117,7 +115,7 @@ export const PopsHandler = {
|
|
|
117
115
|
function originalRun() {
|
|
118
116
|
if (details.config.mask!.clickEvent!.toClose) {
|
|
119
117
|
/* 关闭 */
|
|
120
|
-
PopsInstanceUtils.close(
|
|
118
|
+
return PopsInstanceUtils.close(
|
|
121
119
|
details.type,
|
|
122
120
|
targetLayer,
|
|
123
121
|
details.guid,
|
|
@@ -126,7 +124,7 @@ export const PopsHandler = {
|
|
|
126
124
|
);
|
|
127
125
|
} else if (details.config.mask!.clickEvent!.toHide) {
|
|
128
126
|
/* 隐藏 */
|
|
129
|
-
PopsInstanceUtils.hide(
|
|
127
|
+
return PopsInstanceUtils.hide(
|
|
130
128
|
details.type,
|
|
131
129
|
targetLayer,
|
|
132
130
|
details.guid,
|
|
@@ -400,7 +398,7 @@ export const PopsHandler = {
|
|
|
400
398
|
mode: mode,
|
|
401
399
|
guid: guid,
|
|
402
400
|
close() {
|
|
403
|
-
PopsInstanceUtils.close(
|
|
401
|
+
return PopsInstanceUtils.close(
|
|
404
402
|
mode,
|
|
405
403
|
pops.config.layer[mode],
|
|
406
404
|
guid,
|
|
@@ -409,7 +407,7 @@ export const PopsHandler = {
|
|
|
409
407
|
);
|
|
410
408
|
},
|
|
411
409
|
hide() {
|
|
412
|
-
PopsInstanceUtils.hide(
|
|
410
|
+
return PopsInstanceUtils.hide(
|
|
413
411
|
mode,
|
|
414
412
|
pops.config.layer[mode],
|
|
415
413
|
guid,
|
|
@@ -419,7 +417,7 @@ export const PopsHandler = {
|
|
|
419
417
|
);
|
|
420
418
|
},
|
|
421
419
|
show() {
|
|
422
|
-
PopsInstanceUtils.show(
|
|
420
|
+
return PopsInstanceUtils.show(
|
|
423
421
|
mode,
|
|
424
422
|
pops.config.layer[mode],
|
|
425
423
|
guid,
|
|
@@ -463,7 +461,7 @@ export const PopsHandler = {
|
|
|
463
461
|
mode: mode,
|
|
464
462
|
guid: guid,
|
|
465
463
|
close() {
|
|
466
|
-
PopsInstanceUtils.close(
|
|
464
|
+
return PopsInstanceUtils.close(
|
|
467
465
|
mode,
|
|
468
466
|
pops.config.layer[mode],
|
|
469
467
|
guid,
|
|
@@ -472,7 +470,7 @@ export const PopsHandler = {
|
|
|
472
470
|
);
|
|
473
471
|
},
|
|
474
472
|
hide() {
|
|
475
|
-
PopsInstanceUtils.hide(
|
|
473
|
+
return PopsInstanceUtils.hide(
|
|
476
474
|
mode,
|
|
477
475
|
pops.config.layer[mode],
|
|
478
476
|
guid,
|
|
@@ -482,7 +480,7 @@ export const PopsHandler = {
|
|
|
482
480
|
);
|
|
483
481
|
},
|
|
484
482
|
show() {
|
|
485
|
-
PopsInstanceUtils.show(
|
|
483
|
+
return PopsInstanceUtils.show(
|
|
486
484
|
mode,
|
|
487
485
|
pops.config.layer[mode],
|
|
488
486
|
guid,
|
package/src/types/event.d.ts
CHANGED
|
@@ -48,9 +48,9 @@ export interface PopsEventDetails {
|
|
|
48
48
|
/** 当前弹窗类型 */
|
|
49
49
|
mode: mode;
|
|
50
50
|
guid: guid;
|
|
51
|
-
close: () => void
|
|
52
|
-
hide: () => void
|
|
53
|
-
show: () => void
|
|
51
|
+
close: () => Promise<void>;
|
|
52
|
+
hide: () => Promise<void>;
|
|
53
|
+
show: () => Promise<void>;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
/**
|
package/src/types/mask.d.ts
CHANGED
|
@@ -1569,32 +1569,34 @@ class PopsDOMUtils extends PopsDOMUtilsEvent {
|
|
|
1569
1569
|
if (element == null) {
|
|
1570
1570
|
return;
|
|
1571
1571
|
}
|
|
1572
|
+
let setStyleProperty = (
|
|
1573
|
+
propertyName: string,
|
|
1574
|
+
propertyValue: string | number
|
|
1575
|
+
) => {
|
|
1576
|
+
if (
|
|
1577
|
+
typeof propertyValue === "string" &&
|
|
1578
|
+
propertyValue.trim().endsWith("!important")
|
|
1579
|
+
) {
|
|
1580
|
+
propertyValue = propertyValue
|
|
1581
|
+
.trim()
|
|
1582
|
+
.replace(/!important$/gi, "")
|
|
1583
|
+
.trim();
|
|
1584
|
+
element.style.setProperty(propertyName, propertyValue, "important");
|
|
1585
|
+
} else {
|
|
1586
|
+
propertyValue = handlePixe(propertyName, propertyValue);
|
|
1587
|
+
element.style.setProperty(propertyName, propertyValue);
|
|
1588
|
+
}
|
|
1589
|
+
};
|
|
1572
1590
|
if (typeof property === "string") {
|
|
1573
1591
|
if (value == null) {
|
|
1574
1592
|
return getComputedStyle(element).getPropertyValue(property);
|
|
1575
1593
|
} else {
|
|
1576
|
-
|
|
1577
|
-
element.style.setProperty(property, value, "important");
|
|
1578
|
-
} else {
|
|
1579
|
-
value = handlePixe(property, value);
|
|
1580
|
-
element.style.setProperty(property, value);
|
|
1581
|
-
}
|
|
1594
|
+
setStyleProperty(property, value);
|
|
1582
1595
|
}
|
|
1583
1596
|
} else if (typeof property === "object") {
|
|
1584
1597
|
for (let prop in property) {
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
(property[prop] as string).includes("!important")
|
|
1588
|
-
) {
|
|
1589
|
-
element.style.setProperty(
|
|
1590
|
-
prop,
|
|
1591
|
-
property[prop] as string,
|
|
1592
|
-
"important"
|
|
1593
|
-
);
|
|
1594
|
-
} else {
|
|
1595
|
-
property[prop] = handlePixe(prop, property[prop] as string);
|
|
1596
|
-
element.style.setProperty(prop, property[prop] as string);
|
|
1597
|
-
}
|
|
1598
|
+
let value = property[prop];
|
|
1599
|
+
setStyleProperty(prop, value!);
|
|
1598
1600
|
}
|
|
1599
1601
|
}
|
|
1600
1602
|
}
|
|
@@ -268,24 +268,29 @@ export const PopsInstanceUtils = {
|
|
|
268
268
|
animElement: HTMLElement,
|
|
269
269
|
maskElement: HTMLElement
|
|
270
270
|
) {
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
271
|
+
return new Promise<void>((resolve) => {
|
|
272
|
+
let popsElement =
|
|
273
|
+
animElement.querySelector<HTMLDivElement>(".pops[type-value]")!;
|
|
274
|
+
if (popsType === "drawer") {
|
|
275
|
+
let drawerConfig = config as Required<PopsDrawerDetails>;
|
|
276
|
+
setTimeout(() => {
|
|
277
|
+
maskElement.style.setProperty("display", "none");
|
|
278
|
+
if (["top", "bottom"].includes(drawerConfig.direction)) {
|
|
279
|
+
popsElement.style.setProperty("height", "0");
|
|
280
|
+
} else if (["left", "right"].includes(drawerConfig.direction)) {
|
|
281
|
+
popsElement.style.setProperty("width", "0");
|
|
282
|
+
} else {
|
|
283
|
+
console.error("未知direction:", drawerConfig.direction);
|
|
284
|
+
}
|
|
285
|
+
resolve();
|
|
286
|
+
}, drawerConfig.closeDelay);
|
|
287
|
+
} else {
|
|
288
|
+
let findLayerIns = layerConfigList.find(
|
|
289
|
+
(layerConfigItem) => layerConfigItem.guid === guid
|
|
290
|
+
);
|
|
291
|
+
if (findLayerIns) {
|
|
288
292
|
/* 存在动画 */
|
|
293
|
+
let layerConfigItem = findLayerIns;
|
|
289
294
|
layerConfigItem.animElement.style.width = "100%";
|
|
290
295
|
layerConfigItem.animElement.style.height = "100%";
|
|
291
296
|
(layerConfigItem.animElement.style as any)["animation-name"] =
|
|
@@ -295,6 +300,9 @@ export const PopsInstanceUtils = {
|
|
|
295
300
|
(layerConfigItem.animElement.style as any)["animation-name"]
|
|
296
301
|
)
|
|
297
302
|
) {
|
|
303
|
+
/**
|
|
304
|
+
* 动画结束的回调
|
|
305
|
+
*/
|
|
298
306
|
function animationendCallBack() {
|
|
299
307
|
layerConfigItem.animElement.style.display = "none";
|
|
300
308
|
if (layerConfigItem.maskElement) {
|
|
@@ -308,6 +316,7 @@ export const PopsInstanceUtils = {
|
|
|
308
316
|
capture: true,
|
|
309
317
|
}
|
|
310
318
|
);
|
|
319
|
+
resolve();
|
|
311
320
|
}
|
|
312
321
|
popsDOMUtils.on(
|
|
313
322
|
layerConfigItem.animElement,
|
|
@@ -322,14 +331,13 @@ export const PopsInstanceUtils = {
|
|
|
322
331
|
if (layerConfigItem.maskElement) {
|
|
323
332
|
layerConfigItem.maskElement.style.display = "none";
|
|
324
333
|
}
|
|
325
|
-
}
|
|
326
334
|
|
|
327
|
-
|
|
335
|
+
resolve();
|
|
336
|
+
}
|
|
328
337
|
}
|
|
329
|
-
}
|
|
330
|
-
}
|
|
338
|
+
}
|
|
339
|
+
});
|
|
331
340
|
},
|
|
332
|
-
|
|
333
341
|
/**
|
|
334
342
|
* 显示
|
|
335
343
|
* @param popsType
|
|
@@ -353,27 +361,32 @@ export const PopsInstanceUtils = {
|
|
|
353
361
|
| PopsPanelDetails
|
|
354
362
|
| PopsFolderDetails,
|
|
355
363
|
animElement: HTMLElement,
|
|
356
|
-
maskElement
|
|
364
|
+
maskElement?: HTMLElement
|
|
357
365
|
) {
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
366
|
+
return new Promise<void>((resolve) => {
|
|
367
|
+
let popsElement =
|
|
368
|
+
animElement.querySelector<HTMLDivElement>(".pops[type-value]")!;
|
|
369
|
+
if (popsType === "drawer") {
|
|
370
|
+
let drawerConfig = config as PopsDrawerDetails;
|
|
371
|
+
setTimeout(() => {
|
|
372
|
+
popsDOMUtils.css(maskElement!, "display", "");
|
|
373
|
+
let direction = drawerConfig.direction!;
|
|
374
|
+
let size = drawerConfig.size!.toString();
|
|
375
|
+
if (["top", "bottom"].includes(direction)) {
|
|
376
|
+
popsElement.style.setProperty("height", size);
|
|
377
|
+
} else if (["left", "right"].includes(direction)) {
|
|
378
|
+
popsElement.style.setProperty("width", size);
|
|
379
|
+
} else {
|
|
380
|
+
console.error("未知direction:", direction);
|
|
381
|
+
}
|
|
382
|
+
resolve();
|
|
383
|
+
}, drawerConfig.openDelay);
|
|
384
|
+
} else {
|
|
385
|
+
let findLayerIns = layerConfigList.find(
|
|
386
|
+
(layerConfigItem) => layerConfigItem.guid === guid
|
|
387
|
+
);
|
|
388
|
+
if (findLayerIns) {
|
|
389
|
+
let layerConfigItem = findLayerIns;
|
|
377
390
|
layerConfigItem.animElement.style.width = "";
|
|
378
391
|
layerConfigItem.animElement.style.height = "";
|
|
379
392
|
(layerConfigItem.animElement.style as any)["animation-name"] =
|
|
@@ -385,10 +398,9 @@ export const PopsInstanceUtils = {
|
|
|
385
398
|
(layerConfigItem.animElement.style as any)["animation-name"]
|
|
386
399
|
)
|
|
387
400
|
) {
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
}
|
|
401
|
+
/**
|
|
402
|
+
* 动画结束的回调
|
|
403
|
+
*/
|
|
392
404
|
function animationendCallBack() {
|
|
393
405
|
popsDOMUtils.off(
|
|
394
406
|
layerConfigItem.animElement,
|
|
@@ -398,6 +410,11 @@ export const PopsInstanceUtils = {
|
|
|
398
410
|
capture: true,
|
|
399
411
|
}
|
|
400
412
|
);
|
|
413
|
+
resolve();
|
|
414
|
+
}
|
|
415
|
+
layerConfigItem.animElement.style.display = "";
|
|
416
|
+
if (layerConfigItem.maskElement) {
|
|
417
|
+
layerConfigItem.maskElement.style.display = "";
|
|
401
418
|
}
|
|
402
419
|
popsDOMUtils.on(
|
|
403
420
|
layerConfigItem.animElement,
|
|
@@ -412,11 +429,11 @@ export const PopsInstanceUtils = {
|
|
|
412
429
|
if (layerConfigItem.maskElement) {
|
|
413
430
|
layerConfigItem.maskElement.style.display = "";
|
|
414
431
|
}
|
|
432
|
+
resolve();
|
|
415
433
|
}
|
|
416
434
|
}
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
}
|
|
435
|
+
}
|
|
436
|
+
});
|
|
420
437
|
},
|
|
421
438
|
/**
|
|
422
439
|
* 关闭
|
|
@@ -441,61 +458,68 @@ export const PopsInstanceUtils = {
|
|
|
441
458
|
| PopsFolderDetails,
|
|
442
459
|
animElement: HTMLElement
|
|
443
460
|
) {
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
function
|
|
452
|
-
|
|
453
|
-
|
|
461
|
+
return new Promise<void>((resolve) => {
|
|
462
|
+
let popsElement =
|
|
463
|
+
animElement.querySelector<HTMLDivElement>(".pops[type-value]")!;
|
|
464
|
+
let drawerConfig = config as Required<PopsDrawerDetails>;
|
|
465
|
+
/**
|
|
466
|
+
* 动画结束事件
|
|
467
|
+
*/
|
|
468
|
+
function transitionendEvent() {
|
|
469
|
+
/**
|
|
470
|
+
* 弹窗已关闭的回调
|
|
471
|
+
*/
|
|
472
|
+
function closeCallBack(event: Event) {
|
|
473
|
+
if ((event as TransitionEvent).propertyName !== "transform") {
|
|
474
|
+
return;
|
|
475
|
+
}
|
|
476
|
+
popsDOMUtils.off(
|
|
477
|
+
popsElement,
|
|
478
|
+
popsDOMUtils.getTransitionEndNameList(),
|
|
479
|
+
void 0,
|
|
480
|
+
closeCallBack
|
|
481
|
+
);
|
|
482
|
+
PopsInstanceUtils.removeInstance([layerConfigList], guid);
|
|
483
|
+
resolve();
|
|
454
484
|
}
|
|
455
|
-
|
|
485
|
+
/* 监听过渡结束 */
|
|
486
|
+
popsDOMUtils.on(
|
|
456
487
|
popsElement,
|
|
457
488
|
popsDOMUtils.getTransitionEndNameList(),
|
|
458
|
-
void 0,
|
|
459
489
|
closeCallBack
|
|
460
490
|
);
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
popsElement,
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
491
|
+
let popsTransForm = getComputedStyle(popsElement).transform;
|
|
492
|
+
if (popsTransForm !== "none") {
|
|
493
|
+
popsDOMUtils.trigger(
|
|
494
|
+
popsElement,
|
|
495
|
+
popsDOMUtils.getTransitionEndNameList(),
|
|
496
|
+
void 0,
|
|
497
|
+
true
|
|
498
|
+
);
|
|
499
|
+
return;
|
|
500
|
+
}
|
|
501
|
+
if (["top"].includes(drawerConfig.direction)) {
|
|
502
|
+
popsElement.style.setProperty("transform", "translateY(-100%)");
|
|
503
|
+
} else if (["bottom"].includes(drawerConfig.direction)) {
|
|
504
|
+
popsElement.style.setProperty("transform", "translateY(100%)");
|
|
505
|
+
} else if (["left"].includes(drawerConfig.direction)) {
|
|
506
|
+
popsElement.style.setProperty("transform", "translateX(-100%)");
|
|
507
|
+
} else if (["right"].includes(drawerConfig.direction)) {
|
|
508
|
+
popsElement.style.setProperty("transform", "translateX(100%)");
|
|
509
|
+
} else {
|
|
510
|
+
console.error("未知direction:", drawerConfig.direction);
|
|
511
|
+
}
|
|
478
512
|
}
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
popsElement.style.setProperty("transform", "translateX(-100%)");
|
|
485
|
-
} else if (["right"].includes(drawerConfig.direction)) {
|
|
486
|
-
popsElement.style.setProperty("transform", "translateX(100%)");
|
|
513
|
+
|
|
514
|
+
if (popsType === "drawer") {
|
|
515
|
+
setTimeout(() => {
|
|
516
|
+
transitionendEvent();
|
|
517
|
+
}, drawerConfig.closeDelay);
|
|
487
518
|
} else {
|
|
488
|
-
|
|
519
|
+
PopsInstanceUtils.removeInstance([layerConfigList], guid);
|
|
520
|
+
resolve();
|
|
489
521
|
}
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
if (popsType === "drawer") {
|
|
493
|
-
setTimeout(() => {
|
|
494
|
-
transitionendEvent();
|
|
495
|
-
}, drawerConfig.closeDelay);
|
|
496
|
-
} else {
|
|
497
|
-
PopsInstanceUtils.removeInstance([layerConfigList], guid);
|
|
498
|
-
}
|
|
522
|
+
});
|
|
499
523
|
},
|
|
500
524
|
/**
|
|
501
525
|
* 拖拽元素
|