shineout 3.8.0-beta.23 → 3.8.0-beta.24

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/cjs/index.js CHANGED
@@ -522,5 +522,5 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
522
522
  // 此文件由脚本自动生成,请勿直接修改。
523
523
  // This file was generated automatically by a script. Please do not modify it directly.
524
524
  var _default = exports.default = {
525
- version: '3.8.0-beta.23'
525
+ version: '3.8.0-beta.24'
526
526
  };
package/dist/shineout.js CHANGED
@@ -12386,7 +12386,7 @@ var handleStyle = function handleStyle(style) {
12386
12386
  };
12387
12387
  /* harmony default export */ var jss_style_handleStyle = (handleStyle);
12388
12388
  ;// CONCATENATED MODULE: ../shineout-style/src/version.ts
12389
- /* harmony default export */ var version = ('3.8.0-beta.23');
12389
+ /* harmony default export */ var version = ('3.8.0-beta.24');
12390
12390
  ;// CONCATENATED MODULE: ../shineout-style/src/jss-style/index.tsx
12391
12391
 
12392
12392
 
@@ -35500,6 +35500,34 @@ function removeStack(id, removeListener) {
35500
35500
  }
35501
35501
  delete components[id];
35502
35502
  }
35503
+
35504
+ // 检测容器是否高度受限
35505
+ var isRootHeightConstrained = function isRootHeightConstrained(root, targetElement) {
35506
+ if (!root || root === document.body) {
35507
+ var bodyRect = document.body.getBoundingClientRect();
35508
+ var _targetRect = targetElement.getBoundingClientRect();
35509
+ // body的底部和targetElement的顶部永远不可能有相交,则是受限的
35510
+ if (bodyRect.bottom < _targetRect.top) {
35511
+ return true;
35512
+ } else {
35513
+ return false;
35514
+ }
35515
+ }
35516
+
35517
+ // 当root的overflow是auto或hidden,则认为不是受限的
35518
+ var rootStyle = window.getComputedStyle(root);
35519
+ if (rootStyle.overflow === 'auto' || rootStyle.overflow === 'hidden') {
35520
+ return false;
35521
+ }
35522
+
35523
+ // 当root的底部与targetElement的顶部永远不可能有相交,则是受限的
35524
+ var rootRect = root.getBoundingClientRect();
35525
+ var targetRect = targetElement.getBoundingClientRect();
35526
+ if (rootRect.top > targetRect.bottom || rootRect.bottom < targetRect.top) {
35527
+ return true;
35528
+ }
35529
+ return false;
35530
+ };
35503
35531
  function getObserver(obj, id) {
35504
35532
  var _obj$container = obj.container,
35505
35533
  container = _obj$container === void 0 ? null : _obj$container,
@@ -35509,6 +35537,10 @@ function getObserver(obj, id) {
35509
35537
  offscreen = obj.offscreen,
35510
35538
  noRemove = obj.noRemove;
35511
35539
  var fixedContainer = getClosestPositionedContainer(element, ['fixed', 'absolute']);
35540
+
35541
+ // 获取最优的观察器配置
35542
+ var candidateRoot = fixedContainer || container;
35543
+ var observerRoot = isRootHeightConstrained(candidateRoot, element) ? null : candidateRoot;
35512
35544
  var observer = new IntersectionObserver(function (entries) {
35513
35545
  entries.forEach(function (en) {
35514
35546
  if (en.isIntersecting || en.intersectionRatio > 0) {
@@ -35520,7 +35552,7 @@ function getObserver(obj, id) {
35520
35552
  }
35521
35553
  });
35522
35554
  }, {
35523
- root: fixedContainer || container,
35555
+ root: observerRoot,
35524
35556
  rootMargin: "".concat(offset, "px")
35525
35557
  });
35526
35558
  obj.observer = observer;
@@ -72659,7 +72691,7 @@ var upload_interface = __webpack_require__(8821);
72659
72691
 
72660
72692
 
72661
72693
  /* harmony default export */ var src_0 = ({
72662
- version: '3.8.0-beta.23'
72694
+ version: '3.8.0-beta.24'
72663
72695
  });
72664
72696
  }();
72665
72697
  /******/ return __webpack_exports__;