shineout 3.8.0-beta.13 → 3.8.0-beta.14

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.13'
525
+ version: '3.8.0-beta.14'
526
526
  };
package/dist/shineout.js CHANGED
@@ -12234,7 +12234,7 @@ var handleStyle = function handleStyle(style) {
12234
12234
  };
12235
12235
  /* harmony default export */ var jss_style_handleStyle = (handleStyle);
12236
12236
  ;// CONCATENATED MODULE: ../shineout-style/src/version.ts
12237
- /* harmony default export */ var version = ('3.8.0-beta.13');
12237
+ /* harmony default export */ var version = ('3.8.0-beta.14');
12238
12238
  ;// CONCATENATED MODULE: ../shineout-style/src/jss-style/index.tsx
12239
12239
 
12240
12240
 
@@ -61403,23 +61403,6 @@ var sticky_cssSupport = cssSupport,
61403
61403
  var supportSticky = sticky_cssSupport('position', 'sticky');
61404
61404
  var defaultZIndex = 900;
61405
61405
  var events = ['scroll', 'pageshow', 'load', 'resize'];
61406
-
61407
- // const getFirstScrollParent = (el: HTMLElement) => {
61408
- // let parent = el.parentNode as HTMLElement;
61409
- // while (parent) {
61410
- // if (parent === document.body || parent === document.documentElement) {
61411
- // parent = document.body;
61412
- // break;
61413
- // }
61414
- // const { overflowY } = window.getComputedStyle(parent);
61415
- // if (overflowY === 'scroll' || overflowY === 'auto') {
61416
- // break;
61417
- // }
61418
- // parent = parent.parentNode as HTMLElement;
61419
- // }
61420
- // return parent;
61421
- // };
61422
-
61423
61406
  var Sticky = function Sticky(props) {
61424
61407
  if (props.target) {
61425
61408
  sticky_devUseWarning.deprecated('target', 'scrollContainer', 'Sticky');
@@ -61430,13 +61413,52 @@ var Sticky = function Sticky(props) {
61430
61413
  // 是否使用css sticky
61431
61414
  var css = (props.css || props.target) && supportSticky;
61432
61415
  var forceUpdate = useRender();
61416
+ var elementRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
61433
61417
  var _useRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)({
61434
61418
  target: null,
61435
61419
  div: null,
61436
61420
  position: '',
61437
61421
  targetObserver: null,
61438
61422
  parentObserver: null,
61439
- fixedObserver: null
61423
+ fixedObserver: null,
61424
+ stoped: false,
61425
+ stopStickyFn: function stopStickyFn(e) {
61426
+ var target = e.target;
61427
+ if (!target || typeof target.scrollTop !== 'number') return;
61428
+ var stopStickyPoint = -1;
61429
+ if (typeof props.stickyBoundary === 'number') {
61430
+ stopStickyPoint = props.stickyBoundary;
61431
+ } else if (typeof props.stickyBoundary === 'function') {
61432
+ var stopStickyElement = props.stickyBoundary();
61433
+ if (!stopStickyElement) return;
61434
+ var stopStickyRect = stopStickyElement.getBoundingClientRect();
61435
+ var targetRect = elementRef.current.getBoundingClientRect();
61436
+ stopStickyPoint = stopStickyRect.bottom - targetRect.bottom;
61437
+ }
61438
+ if (stopStickyPoint < 0) return;
61439
+ if (target.scrollTop > stopStickyPoint) {
61440
+ if (context.stoped) return;
61441
+ context.stoped = true;
61442
+
61443
+ // 把 div 移动到 target 内部,使用 absolute 定位跟随滚动
61444
+ if (context.div && context.target) {
61445
+ context.target.insertBefore(context.div, context.target.firstChild);
61446
+ var paddingLeft = Number(window.getComputedStyle(context.target).paddingLeft.replace('px', '')) || 0;
61447
+ var borderLeftWidth = Number(window.getComputedStyle(context.target).borderLeftWidth.replace('px', '')) || 0;
61448
+ var left = paddingLeft + borderLeftWidth;
61449
+ context.div.style.transform = "translate(-".concat(left, "px, ").concat(stopStickyPoint, "px)");
61450
+ }
61451
+ } else {
61452
+ if (!context.stoped) return;
61453
+ context.stoped = false;
61454
+
61455
+ // 恢复正常吸附模式:把 div 移动到 target 外部
61456
+ if (context.div && context.target && context.target.parentNode) {
61457
+ context.target.parentNode.insertBefore(context.div, context.target);
61458
+ }
61459
+ context.div.style.transform = 'none';
61460
+ }
61461
+ }
61440
61462
  }),
61441
61463
  context = _useRef.current;
61442
61464
  var _useState = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)({}),
@@ -61451,7 +61473,6 @@ var Sticky = function Sticky(props) {
61451
61473
  _useState6 = slicedToArray_default()(_useState5, 2),
61452
61474
  parentVisible = _useState6[0],
61453
61475
  setParentVisible = _useState6[1];
61454
- var elementRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
61455
61476
  var getTarget = function getTarget() {
61456
61477
  var scrollContainer = props.scrollContainer;
61457
61478
  if (typeof scrollContainer === 'string') {
@@ -61630,6 +61651,10 @@ var Sticky = function Sticky(props) {
61630
61651
  context.targetObserver.disconnect();
61631
61652
  context.targetObserver = null;
61632
61653
  }
61654
+ if (props.stickyBoundary) {
61655
+ var _context$target;
61656
+ (_context$target = context.target) === null || _context$target === void 0 || _context$target.removeEventListener('scroll', context.stopStickyFn);
61657
+ }
61633
61658
  };
61634
61659
  var createObserver = function createObserver() {
61635
61660
  if (!context.div) {
@@ -61654,6 +61679,9 @@ var Sticky = function Sticky(props) {
61654
61679
  }
61655
61680
  }
61656
61681
  cancelFixedObserver();
61682
+ if (props.stickyBoundary) {
61683
+ context.target.addEventListener('scroll', context.stopStickyFn);
61684
+ }
61657
61685
  if (window.IntersectionObserver) {
61658
61686
  var observer = new IntersectionObserver(handleTargetPosition, {
61659
61687
  root: context.target,
@@ -72008,7 +72036,7 @@ var upload_interface = __webpack_require__(8821);
72008
72036
 
72009
72037
 
72010
72038
  /* harmony default export */ var src_0 = ({
72011
- version: '3.8.0-beta.13'
72039
+ version: '3.8.0-beta.14'
72012
72040
  });
72013
72041
  }();
72014
72042
  /******/ return __webpack_exports__;