@vvfx/sdk 0.2.10 → 0.2.12
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/html-overlay/manager.d.ts +1 -0
- package/dist/html-overlay/manager.js +21 -0
- package/dist/index.cjs +24 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +24 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -4
|
@@ -133,6 +133,7 @@ export declare class HTMLOverlayManager {
|
|
|
133
133
|
private getChildrenNaturalHeight;
|
|
134
134
|
private cleanupAutoHeight;
|
|
135
135
|
private applyAutoHeight;
|
|
136
|
+
private isAutoHeightFeedbackLoop;
|
|
136
137
|
private setAutoHeightStreamPhase;
|
|
137
138
|
private isAutoHeightStreamActive;
|
|
138
139
|
private getAutoHeightAnchor;
|
|
@@ -35,6 +35,7 @@ const EDITING_VIEWPORT_PADDING = 48;
|
|
|
35
35
|
const EDITING_VIEWPORT_BOX_SCALE = 1.1;
|
|
36
36
|
const AUTO_HEIGHT_EPSILON = 0.5;
|
|
37
37
|
const AUTO_HEIGHT_MAX_MULTIPLIER = 32;
|
|
38
|
+
const AUTO_HEIGHT_FEEDBACK_STEP_LIMIT = 2;
|
|
38
39
|
const CARD_RASTERIZE_READY_TIMEOUT = 3000;
|
|
39
40
|
const CARD_HTML_EVENT_MESSAGE_SOURCE = 'vvfx-card-html-event';
|
|
40
41
|
const requestHTMLOverlayFrame = (callback) => {
|
|
@@ -84,6 +85,7 @@ export class HTMLOverlayManager {
|
|
|
84
85
|
autoHeightCleanups: new Map(),
|
|
85
86
|
autoHeightFrames: new Map(),
|
|
86
87
|
autoHeightInitialHeights: new Map(),
|
|
88
|
+
autoHeightFeedback: new Map(),
|
|
87
89
|
autoHeightStreamPhases: new Map(),
|
|
88
90
|
};
|
|
89
91
|
constructor(options) {
|
|
@@ -148,6 +150,7 @@ export class HTMLOverlayManager {
|
|
|
148
150
|
});
|
|
149
151
|
this.state.autoHeightFrames.clear();
|
|
150
152
|
this.state.autoHeightInitialHeights.clear();
|
|
153
|
+
this.state.autoHeightFeedback.clear();
|
|
151
154
|
this.state.autoHeightStreamPhases.clear();
|
|
152
155
|
this.eventCleanups.forEach(cleanup => {
|
|
153
156
|
cleanup();
|
|
@@ -1421,6 +1424,7 @@ export class HTMLOverlayManager {
|
|
|
1421
1424
|
cancelHTMLOverlayFrame(frame);
|
|
1422
1425
|
this.state.autoHeightFrames.delete(id);
|
|
1423
1426
|
}
|
|
1427
|
+
this.state.autoHeightFeedback.delete(id);
|
|
1424
1428
|
}
|
|
1425
1429
|
applyAutoHeight(id, height) {
|
|
1426
1430
|
const item = this.options.getItems().find(candidate => candidate.id === id);
|
|
@@ -1438,11 +1442,28 @@ export class HTMLOverlayManager {
|
|
|
1438
1442
|
if (Math.abs(nextHeight - item.property.height) <= AUTO_HEIGHT_EPSILON) {
|
|
1439
1443
|
return;
|
|
1440
1444
|
}
|
|
1445
|
+
if (this.isAutoHeightFeedbackLoop(id, item.property.height, nextHeight)) {
|
|
1446
|
+
return;
|
|
1447
|
+
}
|
|
1441
1448
|
this.options.setCardItemHeight(id, nextHeight, {
|
|
1442
1449
|
anchor: this.getAutoHeightAnchor(item),
|
|
1443
1450
|
previousHeight: item.property.height,
|
|
1444
1451
|
});
|
|
1445
1452
|
}
|
|
1453
|
+
isAutoHeightFeedbackLoop(id, currentHeight, nextHeight) {
|
|
1454
|
+
if (nextHeight <= currentHeight) {
|
|
1455
|
+
this.state.autoHeightFeedback.delete(id);
|
|
1456
|
+
return false;
|
|
1457
|
+
}
|
|
1458
|
+
const offset = nextHeight - currentHeight;
|
|
1459
|
+
const previous = this.state.autoHeightFeedback.get(id);
|
|
1460
|
+
const continues = previous !== undefined &&
|
|
1461
|
+
Math.abs(previous.nextHeight - currentHeight) <= AUTO_HEIGHT_EPSILON &&
|
|
1462
|
+
Math.abs(previous.offset - offset) <= AUTO_HEIGHT_EPSILON;
|
|
1463
|
+
const steps = continues ? previous.steps + 1 : 0;
|
|
1464
|
+
this.state.autoHeightFeedback.set(id, { nextHeight, offset, steps });
|
|
1465
|
+
return steps >= AUTO_HEIGHT_FEEDBACK_STEP_LIMIT;
|
|
1466
|
+
}
|
|
1446
1467
|
setAutoHeightStreamPhase(id, phase) {
|
|
1447
1468
|
if (phase === 'parsing' || phase === 'draining' || phase === 'finalizing') {
|
|
1448
1469
|
this.state.autoHeightStreamPhases.set(id, phase);
|
package/dist/index.cjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Description: TODO
|
|
4
4
|
* Author: Ant Group CO., Ltd.
|
|
5
5
|
* Contributors: 赤芍,何即,不择,意绮
|
|
6
|
-
* Version: v0.2.
|
|
6
|
+
* Version: v0.2.12
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
'use strict';
|
|
@@ -70485,6 +70485,7 @@ var EDITING_VIEWPORT_PADDING = 48;
|
|
|
70485
70485
|
var EDITING_VIEWPORT_BOX_SCALE = 1.1;
|
|
70486
70486
|
var AUTO_HEIGHT_EPSILON = 0.5;
|
|
70487
70487
|
var AUTO_HEIGHT_MAX_MULTIPLIER = 32;
|
|
70488
|
+
var AUTO_HEIGHT_FEEDBACK_STEP_LIMIT = 2;
|
|
70488
70489
|
var CARD_RASTERIZE_READY_TIMEOUT = 3000;
|
|
70489
70490
|
var CARD_HTML_EVENT_MESSAGE_SOURCE = 'vvfx-card-html-event';
|
|
70490
70491
|
var requestHTMLOverlayFrame = function requestHTMLOverlayFrame(callback) {
|
|
@@ -70532,6 +70533,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
70532
70533
|
autoHeightCleanups: new Map(),
|
|
70533
70534
|
autoHeightFrames: new Map(),
|
|
70534
70535
|
autoHeightInitialHeights: new Map(),
|
|
70536
|
+
autoHeightFeedback: new Map(),
|
|
70535
70537
|
autoHeightStreamPhases: new Map()
|
|
70536
70538
|
};
|
|
70537
70539
|
this.handleContainerDoubleClick = function(event) {
|
|
@@ -70685,6 +70687,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
70685
70687
|
});
|
|
70686
70688
|
this.state.autoHeightFrames.clear();
|
|
70687
70689
|
this.state.autoHeightInitialHeights.clear();
|
|
70690
|
+
this.state.autoHeightFeedback.clear();
|
|
70688
70691
|
this.state.autoHeightStreamPhases.clear();
|
|
70689
70692
|
this.eventCleanups.forEach(function(cleanup) {
|
|
70690
70693
|
cleanup();
|
|
@@ -71983,6 +71986,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
71983
71986
|
cancelHTMLOverlayFrame(frame);
|
|
71984
71987
|
this.state.autoHeightFrames.delete(id);
|
|
71985
71988
|
}
|
|
71989
|
+
this.state.autoHeightFeedback.delete(id);
|
|
71986
71990
|
};
|
|
71987
71991
|
_proto.applyAutoHeight = function applyAutoHeight(id, height) {
|
|
71988
71992
|
var item = this.options.getItems().find(function(candidate) {
|
|
@@ -72002,11 +72006,30 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
72002
72006
|
if (Math.abs(nextHeight - item.property.height) <= AUTO_HEIGHT_EPSILON) {
|
|
72003
72007
|
return;
|
|
72004
72008
|
}
|
|
72009
|
+
if (this.isAutoHeightFeedbackLoop(id, item.property.height, nextHeight)) {
|
|
72010
|
+
return;
|
|
72011
|
+
}
|
|
72005
72012
|
this.options.setCardItemHeight(id, nextHeight, {
|
|
72006
72013
|
anchor: this.getAutoHeightAnchor(item),
|
|
72007
72014
|
previousHeight: item.property.height
|
|
72008
72015
|
});
|
|
72009
72016
|
};
|
|
72017
|
+
_proto.isAutoHeightFeedbackLoop = function isAutoHeightFeedbackLoop(id, currentHeight, nextHeight) {
|
|
72018
|
+
if (nextHeight <= currentHeight) {
|
|
72019
|
+
this.state.autoHeightFeedback.delete(id);
|
|
72020
|
+
return false;
|
|
72021
|
+
}
|
|
72022
|
+
var offset = nextHeight - currentHeight;
|
|
72023
|
+
var previous = this.state.autoHeightFeedback.get(id);
|
|
72024
|
+
var continues = previous !== undefined && Math.abs(previous.nextHeight - currentHeight) <= AUTO_HEIGHT_EPSILON && Math.abs(previous.offset - offset) <= AUTO_HEIGHT_EPSILON;
|
|
72025
|
+
var steps = continues ? previous.steps + 1 : 0;
|
|
72026
|
+
this.state.autoHeightFeedback.set(id, {
|
|
72027
|
+
nextHeight: nextHeight,
|
|
72028
|
+
offset: offset,
|
|
72029
|
+
steps: steps
|
|
72030
|
+
});
|
|
72031
|
+
return steps >= AUTO_HEIGHT_FEEDBACK_STEP_LIMIT;
|
|
72032
|
+
};
|
|
72010
72033
|
_proto.setAutoHeightStreamPhase = function setAutoHeightStreamPhase(id, phase) {
|
|
72011
72034
|
if (phase === 'parsing' || phase === 'draining' || phase === 'finalizing') {
|
|
72012
72035
|
this.state.autoHeightStreamPhases.set(id, phase);
|