@vvfx/sdk 0.2.9 → 0.2.10

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.mjs CHANGED
@@ -3,7 +3,7 @@
3
3
  * Description: TODO
4
4
  * Author: Ant Group CO., Ltd.
5
5
  * Contributors: 赤芍,何即,不择,意绮
6
- * Version: v0.2.9
6
+ * Version: v0.2.10
7
7
  */
8
8
 
9
9
  import { math, spec, generateGUID, SpriteComponent, TextComponent, assertExist as assertExist$1, version, VFXItem, PrecompositionManager, AssetManager, FrameComponent, glContext, CompositionComponent, Texture as Texture$1, getStandardJSON, EffectComponent, Geometry as Geometry$1, Material, Player, EventEmitter as EventEmitter$1 } from '@galacean/effects';
@@ -70483,6 +70483,7 @@ var CONTENT_INTERACTION_NONE_SELECTOR = [
70483
70483
  var EDITING_VIEWPORT_PADDING = 48;
70484
70484
  var EDITING_VIEWPORT_BOX_SCALE = 1.1;
70485
70485
  var AUTO_HEIGHT_EPSILON = 0.5;
70486
+ var AUTO_HEIGHT_MAX_MULTIPLIER = 32;
70486
70487
  var CARD_RASTERIZE_READY_TIMEOUT = 3000;
70487
70488
  var CARD_HTML_EVENT_MESSAGE_SOURCE = 'vvfx-card-html-event';
70488
70489
  var requestHTMLOverlayFrame = function requestHTMLOverlayFrame(callback) {
@@ -70529,6 +70530,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
70529
70530
  autoHeightModes: new Map(),
70530
70531
  autoHeightCleanups: new Map(),
70531
70532
  autoHeightFrames: new Map(),
70533
+ autoHeightInitialHeights: new Map(),
70532
70534
  autoHeightStreamPhases: new Map()
70533
70535
  };
70534
70536
  this.handleContainerDoubleClick = function(event) {
@@ -70681,6 +70683,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
70681
70683
  cancelHTMLOverlayFrame(frame);
70682
70684
  });
70683
70685
  this.state.autoHeightFrames.clear();
70686
+ this.state.autoHeightInitialHeights.clear();
70684
70687
  this.state.autoHeightStreamPhases.clear();
70685
70688
  this.eventCleanups.forEach(function(cleanup) {
70686
70689
  cleanup();
@@ -71795,6 +71798,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
71795
71798
  _proto.removeOverlay = function removeOverlay(id) {
71796
71799
  var _this_state_elements_get, _this_state_selectionElements_get;
71797
71800
  this.cleanupOverlayContent(id);
71801
+ this.state.autoHeightInitialHeights.delete(id);
71798
71802
  (_this_state_elements_get = this.state.elements.get(id)) == null ? void 0 : _this_state_elements_get.remove();
71799
71803
  (_this_state_selectionElements_get = this.state.selectionElements.get(id)) == null ? void 0 : _this_state_selectionElements_get.remove();
71800
71804
  this.state.elements.delete(id);
@@ -71989,7 +71993,8 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
71989
71993
  if (!Number.isFinite(height) || height <= 0) {
71990
71994
  return;
71991
71995
  }
71992
- var nextHeight = Math.ceil(this.getAutoHeightItemHeight(item, height));
71996
+ var measuredHeight = Math.ceil(this.getAutoHeightItemHeight(item, height));
71997
+ var nextHeight = Math.min(measuredHeight, this.getAutoHeightLimit(item));
71993
71998
  if (this.isAutoHeightStreamActive(id) && nextHeight < item.property.height) {
71994
71999
  return;
71995
72000
  }
@@ -72030,6 +72035,15 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
72030
72035
  }
72031
72036
  return contentHeight / displayedHeight * item.property.height;
72032
72037
  };
72038
+ _proto.getAutoHeightLimit = function getAutoHeightLimit(item) {
72039
+ var persistedInitialHeight = this.state.autoHeightInitialHeights.get(item.id);
72040
+ if (persistedInitialHeight !== undefined) {
72041
+ return persistedInitialHeight * AUTO_HEIGHT_MAX_MULTIPLIER;
72042
+ }
72043
+ var initialHeight = item.property.height;
72044
+ this.state.autoHeightInitialHeights.set(item.id, initialHeight);
72045
+ return initialHeight * AUTO_HEIGHT_MAX_MULTIPLIER;
72046
+ };
72033
72047
  _proto.isAutoHeightEnabled = function isAutoHeightEnabled(item) {
72034
72048
  var _this_options_resolveCardTypeConfig;
72035
72049
  return isCardItem(item) && ((_this_options_resolveCardTypeConfig = this.options.resolveCardTypeConfig(item)) == null ? void 0 : _this_options_resolveCardTypeConfig.autoHeight) === true;
@@ -72389,6 +72403,15 @@ function withTimeout(promise, timeout) {
72389
72403
  });
72390
72404
  }
72391
72405
 
72406
+ function resolveTopAnchoredCardPosition(param) {
72407
+ var nextHeight = param.nextHeight, position = param.position, previousHeight = param.previousHeight, scaleY = param.scaleY;
72408
+ var normalizedScaleY = Number.isFinite(scaleY) ? scaleY : 1;
72409
+ return [
72410
+ position[0],
72411
+ position[1] + (nextHeight - previousHeight) * normalizedScaleY / 2
72412
+ ];
72413
+ }
72414
+
72392
72415
  function orderSDKCanvasLayers(param) {
72393
72416
  var container = param.container, playerContainer = param.playerContainer, htmlOverlayLayer = param.htmlOverlayLayer, gestureCanvas = param.gestureCanvas;
72394
72417
  [
@@ -72501,6 +72524,8 @@ var SDK = /*#__PURE__*/ function() {
72501
72524
  }, box);
72502
72525
  },
72503
72526
  setCardItemHeight: function setCardItemHeight(id, height, options) {
72527
+ var _ref;
72528
+ var _item_property_scale;
72504
72529
  var item = _this.getSDKItem(id);
72505
72530
  if (!isCardItem(item) || options.anchor === 'center') {
72506
72531
  void _this.setItemProperty({
@@ -72511,17 +72536,18 @@ var SDK = /*#__PURE__*/ function() {
72511
72536
  });
72512
72537
  return;
72513
72538
  }
72514
- var _item_property_position = item.property.position, x = _item_property_position[0], y = _item_property_position[1];
72515
- var deltaY = (height - options.previousHeight) / 2;
72539
+ var position = resolveTopAnchoredCardPosition({
72540
+ nextHeight: height,
72541
+ position: item.property.position,
72542
+ previousHeight: options.previousHeight,
72543
+ scaleY: (_ref = (_item_property_scale = item.property.scale) == null ? void 0 : _item_property_scale[1]) != null ? _ref : 1
72544
+ });
72516
72545
  void _this.setItemProperty({
72517
72546
  itemId: id,
72518
72547
  type: SDKItemType.CARD,
72519
72548
  property: {
72520
72549
  height: height,
72521
- position: [
72522
- x,
72523
- y + deltaY
72524
- ]
72550
+ position: position
72525
72551
  }
72526
72552
  });
72527
72553
  },