@leankylin-sheet/react 4.0.16 → 4.0.17

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.esm.js CHANGED
@@ -2,7 +2,7 @@ import { defaultContext, defaultSettings, getSheetIndex, colLocationByIndex, fix
2
2
  import React, { useContext, useRef, useState, useMemo, useCallback, useEffect, useLayoutEffect, useImperativeHandle } from 'react';
3
3
  import produce, { applyPatches, enablePatches, produceWithPatches } from 'immer';
4
4
  import _ from 'lodash';
5
- import { useMemoizedFn, useThrottleFn } from 'ahooks';
5
+ import { useInViewport, useMemoizedFn, useThrottleFn } from 'ahooks';
6
6
  import { createPortal } from 'react-dom';
7
7
 
8
8
  function _iterableToArrayLimit(r, l) {
@@ -1336,13 +1336,17 @@ var ScrollBar = function ScrollBar(_ref) {
1336
1336
  context = _useContext.context,
1337
1337
  refs = _useContext.refs,
1338
1338
  setContext = _useContext.setContext;
1339
+ var ref = axis === "x" ? refs.scrollbarX : refs.scrollbarY;
1340
+ var _useInViewport = useInViewport(ref),
1341
+ _useInViewport2 = _slicedToArray(_useInViewport, 1),
1342
+ inViewport = _useInViewport2[0];
1339
1343
  useEffect(function () {
1340
1344
  if (axis === "x") {
1341
1345
  refs.scrollbarX.current.scrollLeft = context.scrollLeft;
1342
1346
  } else {
1343
1347
  refs.scrollbarY.current.scrollTop = context.scrollTop;
1344
1348
  }
1345
- }, [axis === "x" ? context.scrollLeft : context.scrollTop]);
1349
+ }, [axis === "x" ? context.scrollLeft : context.scrollTop, inViewport]);
1346
1350
  var getHidden = function getHidden() {
1347
1351
  var _refs$scrollbarY$curr;
1348
1352
  if (axis === "x") {
@@ -1352,7 +1356,7 @@ var ScrollBar = function ScrollBar(_ref) {
1352
1356
  };
1353
1357
  var hidden = getHidden();
1354
1358
  return /*#__PURE__*/React.createElement("div", {
1355
- ref: axis === "x" ? refs.scrollbarX : refs.scrollbarY,
1359
+ ref: ref,
1356
1360
  style: axis === "x" ? {
1357
1361
  left: context.rowHeaderWidth,
1358
1362
  width: "calc(100% - ".concat(context.rowHeaderWidth, "px)"),
package/dist/index.js CHANGED
@@ -1346,13 +1346,17 @@ var ScrollBar = function ScrollBar(_ref) {
1346
1346
  context = _useContext.context,
1347
1347
  refs = _useContext.refs,
1348
1348
  setContext = _useContext.setContext;
1349
+ var ref = axis === "x" ? refs.scrollbarX : refs.scrollbarY;
1350
+ var _useInViewport = ahooks.useInViewport(ref),
1351
+ _useInViewport2 = _slicedToArray(_useInViewport, 1),
1352
+ inViewport = _useInViewport2[0];
1349
1353
  React.useEffect(function () {
1350
1354
  if (axis === "x") {
1351
1355
  refs.scrollbarX.current.scrollLeft = context.scrollLeft;
1352
1356
  } else {
1353
1357
  refs.scrollbarY.current.scrollTop = context.scrollTop;
1354
1358
  }
1355
- }, [axis === "x" ? context.scrollLeft : context.scrollTop]);
1359
+ }, [axis === "x" ? context.scrollLeft : context.scrollTop, inViewport]);
1356
1360
  var getHidden = function getHidden() {
1357
1361
  var _refs$scrollbarY$curr;
1358
1362
  if (axis === "x") {
@@ -1362,7 +1366,7 @@ var ScrollBar = function ScrollBar(_ref) {
1362
1366
  };
1363
1367
  var hidden = getHidden();
1364
1368
  return /*#__PURE__*/React__default['default'].createElement("div", {
1365
- ref: axis === "x" ? refs.scrollbarX : refs.scrollbarY,
1369
+ ref: ref,
1366
1370
  style: axis === "x" ? {
1367
1371
  left: context.rowHeaderWidth,
1368
1372
  width: "calc(100% - ".concat(context.rowHeaderWidth, "px)"),