0979d98bfe62be7af6845f3e6b3edcc5.json 30.9 KB
{"ast":null,"code":"import _extends from \"@babel/runtime/helpers/extends\";\nimport _defineProperty from \"@babel/runtime/helpers/defineProperty\";\nimport _classCallCheck from \"@babel/runtime/helpers/classCallCheck\";\nimport _createClass from \"@babel/runtime/helpers/createClass\";\nimport _inherits from \"@babel/runtime/helpers/inherits\";\nimport _createSuper from \"@babel/runtime/helpers/createSuper\";\nimport _typeof from \"@babel/runtime/helpers/typeof\";\n\nvar __decorate = this && this.__decorate || function (decorators, target, key, desc) {\n  var c = arguments.length,\n      r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,\n      d;\n  if ((typeof Reflect === \"undefined\" ? \"undefined\" : _typeof(Reflect)) === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) {\n    if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n  }\n  return c > 3 && r && Object.defineProperty(target, key, r), r;\n};\n\nimport * as React from 'react';\nimport classNames from 'classnames';\nimport omit from 'omit.js';\nimport ResizeObserver from 'rc-resize-observer';\nimport { ConfigContext } from '../config-provider';\nimport { throttleByAnimationFrameDecorator } from '../_util/throttleByAnimationFrame';\nimport { addObserveTarget, removeObserveTarget, getTargetRect, getFixedTop, getFixedBottom } from './utils';\n\nfunction getDefaultTarget() {\n  return typeof window !== 'undefined' ? window : null;\n}\n\nvar AffixStatus;\n\n(function (AffixStatus) {\n  AffixStatus[AffixStatus[\"None\"] = 0] = \"None\";\n  AffixStatus[AffixStatus[\"Prepare\"] = 1] = \"Prepare\";\n})(AffixStatus || (AffixStatus = {}));\n\nvar Affix = /*#__PURE__*/function (_React$Component) {\n  _inherits(Affix, _React$Component);\n\n  var _super = _createSuper(Affix);\n\n  function Affix() {\n    var _this;\n\n    _classCallCheck(this, Affix);\n\n    _this = _super.apply(this, arguments);\n    _this.state = {\n      status: AffixStatus.None,\n      lastAffix: false,\n      prevTarget: null\n    };\n\n    _this.getOffsetTop = function () {\n      var offsetBottom = _this.props.offsetBottom;\n      var offsetTop = _this.props.offsetTop;\n\n      if (offsetBottom === undefined && offsetTop === undefined) {\n        offsetTop = 0;\n      }\n\n      return offsetTop;\n    };\n\n    _this.getOffsetBottom = function () {\n      return _this.props.offsetBottom;\n    };\n\n    _this.savePlaceholderNode = function (node) {\n      _this.placeholderNode = node;\n    };\n\n    _this.saveFixedNode = function (node) {\n      _this.fixedNode = node;\n    }; // =================== Measure ===================\n\n\n    _this.measure = function () {\n      var _this$state = _this.state,\n          status = _this$state.status,\n          lastAffix = _this$state.lastAffix;\n      var onChange = _this.props.onChange;\n\n      var targetFunc = _this.getTargetFunc();\n\n      if (status !== AffixStatus.Prepare || !_this.fixedNode || !_this.placeholderNode || !targetFunc) {\n        return;\n      }\n\n      var offsetTop = _this.getOffsetTop();\n\n      var offsetBottom = _this.getOffsetBottom();\n\n      var targetNode = targetFunc();\n\n      if (!targetNode) {\n        return;\n      }\n\n      var newState = {\n        status: AffixStatus.None\n      };\n      var targetRect = getTargetRect(targetNode);\n      var placeholderReact = getTargetRect(_this.placeholderNode);\n      var fixedTop = getFixedTop(placeholderReact, targetRect, offsetTop);\n      var fixedBottom = getFixedBottom(placeholderReact, targetRect, offsetBottom);\n\n      if (fixedTop !== undefined) {\n        newState.affixStyle = {\n          position: 'fixed',\n          top: fixedTop,\n          width: placeholderReact.width,\n          height: placeholderReact.height\n        };\n        newState.placeholderStyle = {\n          width: placeholderReact.width,\n          height: placeholderReact.height\n        };\n      } else if (fixedBottom !== undefined) {\n        newState.affixStyle = {\n          position: 'fixed',\n          bottom: fixedBottom,\n          width: placeholderReact.width,\n          height: placeholderReact.height\n        };\n        newState.placeholderStyle = {\n          width: placeholderReact.width,\n          height: placeholderReact.height\n        };\n      }\n\n      newState.lastAffix = !!newState.affixStyle;\n\n      if (onChange && lastAffix !== newState.lastAffix) {\n        onChange(newState.lastAffix);\n      }\n\n      _this.setState(newState);\n    }; // @ts-ignore TS6133\n\n\n    _this.prepareMeasure = function () {\n      // event param is used before. Keep compatible ts define here.\n      _this.setState({\n        status: AffixStatus.Prepare,\n        affixStyle: undefined,\n        placeholderStyle: undefined\n      }); // Test if `updatePosition` called\n\n\n      if (process.env.NODE_ENV === 'test') {\n        var onTestUpdatePosition = _this.props.onTestUpdatePosition;\n\n        if (onTestUpdatePosition) {\n          onTestUpdatePosition();\n        }\n      }\n    }; // =================== Render ===================\n\n\n    _this.render = function () {\n      var getPrefixCls = _this.context.getPrefixCls;\n      var _this$state2 = _this.state,\n          affixStyle = _this$state2.affixStyle,\n          placeholderStyle = _this$state2.placeholderStyle;\n      var _this$props = _this.props,\n          prefixCls = _this$props.prefixCls,\n          children = _this$props.children;\n      var className = classNames(_defineProperty({}, getPrefixCls('affix', prefixCls), affixStyle));\n      var props = omit(_this.props, ['prefixCls', 'offsetTop', 'offsetBottom', 'target', 'onChange']); // Omit this since `onTestUpdatePosition` only works on test.\n\n      if (process.env.NODE_ENV === 'test') {\n        props = omit(props, ['onTestUpdatePosition']);\n      }\n\n      return /*#__PURE__*/React.createElement(ResizeObserver, {\n        onResize: function onResize() {\n          _this.updatePosition();\n        }\n      }, /*#__PURE__*/React.createElement(\"div\", _extends({}, props, {\n        ref: _this.savePlaceholderNode\n      }), affixStyle && /*#__PURE__*/React.createElement(\"div\", {\n        style: placeholderStyle,\n        \"aria-hidden\": \"true\"\n      }), /*#__PURE__*/React.createElement(\"div\", {\n        className: className,\n        ref: _this.saveFixedNode,\n        style: affixStyle\n      }, /*#__PURE__*/React.createElement(ResizeObserver, {\n        onResize: function onResize() {\n          _this.updatePosition();\n        }\n      }, children))));\n    };\n\n    return _this;\n  }\n\n  _createClass(Affix, [{\n    key: \"getTargetFunc\",\n    value: function getTargetFunc() {\n      var getTargetContainer = this.context.getTargetContainer;\n      var target = this.props.target;\n\n      if (target !== undefined) {\n        return target;\n      }\n\n      return getTargetContainer || getDefaultTarget;\n    } // Event handler\n\n  }, {\n    key: \"componentDidMount\",\n    value: function componentDidMount() {\n      var _this2 = this;\n\n      var targetFunc = this.getTargetFunc();\n\n      if (targetFunc) {\n        // [Legacy] Wait for parent component ref has its value.\n        // We should use target as directly element instead of function which makes element check hard.\n        this.timeout = setTimeout(function () {\n          addObserveTarget(targetFunc(), _this2); // Mock Event object.\n\n          _this2.updatePosition();\n        });\n      }\n    }\n  }, {\n    key: \"componentDidUpdate\",\n    value: function componentDidUpdate(prevProps) {\n      var prevTarget = this.state.prevTarget;\n      var targetFunc = this.getTargetFunc();\n      var newTarget = null;\n\n      if (targetFunc) {\n        newTarget = targetFunc() || null;\n      }\n\n      if (prevTarget !== newTarget) {\n        removeObserveTarget(this);\n\n        if (newTarget) {\n          addObserveTarget(newTarget, this); // Mock Event object.\n\n          this.updatePosition();\n        } // eslint-disable-next-line react/no-did-update-set-state\n\n\n        this.setState({\n          prevTarget: newTarget\n        });\n      }\n\n      if (prevProps.offsetTop !== this.props.offsetTop || prevProps.offsetBottom !== this.props.offsetBottom) {\n        this.updatePosition();\n      }\n\n      this.measure();\n    }\n  }, {\n    key: \"componentWillUnmount\",\n    value: function componentWillUnmount() {\n      clearTimeout(this.timeout);\n      removeObserveTarget(this);\n      this.updatePosition.cancel(); // https://github.com/ant-design/ant-design/issues/22683\n\n      this.lazyUpdatePosition.cancel();\n    } // Handle realign logic\n\n  }, {\n    key: \"updatePosition\",\n    value: function updatePosition() {\n      this.prepareMeasure();\n    }\n  }, {\n    key: \"lazyUpdatePosition\",\n    value: function lazyUpdatePosition() {\n      var targetFunc = this.getTargetFunc();\n      var affixStyle = this.state.affixStyle; // Check position change before measure to make Safari smooth\n\n      if (targetFunc && affixStyle) {\n        var offsetTop = this.getOffsetTop();\n        var offsetBottom = this.getOffsetBottom();\n        var targetNode = targetFunc();\n\n        if (targetNode && this.placeholderNode) {\n          var targetRect = getTargetRect(targetNode);\n          var placeholderReact = getTargetRect(this.placeholderNode);\n          var fixedTop = getFixedTop(placeholderReact, targetRect, offsetTop);\n          var fixedBottom = getFixedBottom(placeholderReact, targetRect, offsetBottom);\n\n          if (fixedTop !== undefined && affixStyle.top === fixedTop || fixedBottom !== undefined && affixStyle.bottom === fixedBottom) {\n            return;\n          }\n        }\n      } // Directly call prepare measure since it's already throttled.\n\n\n      this.prepareMeasure();\n    }\n  }]);\n\n  return Affix;\n}(React.Component);\n\nAffix.contextType = ConfigContext;\n\n__decorate([throttleByAnimationFrameDecorator()], Affix.prototype, \"updatePosition\", null);\n\n__decorate([throttleByAnimationFrameDecorator()], Affix.prototype, \"lazyUpdatePosition\", null);\n\nexport default Affix;","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/antd/es/affix/index.js"],"names":["_extends","_defineProperty","_classCallCheck","_createClass","_inherits","_createSuper","_typeof","__decorate","decorators","target","key","desc","c","arguments","length","r","Object","getOwnPropertyDescriptor","d","Reflect","decorate","i","defineProperty","React","classNames","omit","ResizeObserver","ConfigContext","throttleByAnimationFrameDecorator","addObserveTarget","removeObserveTarget","getTargetRect","getFixedTop","getFixedBottom","getDefaultTarget","window","AffixStatus","Affix","_React$Component","_super","_this","apply","state","status","None","lastAffix","prevTarget","getOffsetTop","offsetBottom","props","offsetTop","undefined","getOffsetBottom","savePlaceholderNode","node","placeholderNode","saveFixedNode","fixedNode","measure","_this$state","onChange","targetFunc","getTargetFunc","Prepare","targetNode","newState","targetRect","placeholderReact","fixedTop","fixedBottom","affixStyle","position","top","width","height","placeholderStyle","bottom","setState","prepareMeasure","process","env","NODE_ENV","onTestUpdatePosition","render","getPrefixCls","context","_this$state2","_this$props","prefixCls","children","className","createElement","onResize","updatePosition","ref","style","value","getTargetContainer","componentDidMount","_this2","timeout","setTimeout","componentDidUpdate","prevProps","newTarget","componentWillUnmount","clearTimeout","cancel","lazyUpdatePosition","Component","contextType","prototype"],"mappings":"AAAA,OAAOA,QAAP,MAAqB,gCAArB;AACA,OAAOC,eAAP,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AIpB,SAAS,GAAG,KAAKH,YAAL,EAAhB;AACA,YAAIC,YAAY,GAAG,KAAKI,eAAL,EAAnB;AACA,YAAIY,UAAU,GAAGH,UAAU,EAA3B;;AAEA,YAAIG,UAAU,IAAI,KAAKT,eAAvB,EAAwC;AACtC,cAAIW,UAAU,GAAGnC,aAAa,CAACiC,UAAD,CAA9B;AACA,cAAIG,gBAAgB,GAAGpC,aAAa,CAAC,KAAKwB,eAAN,CAApC;AACA,cAAIa,QAAQ,GAAGpC,WAAW,CAACmC,gBAAD,EAAmBD,UAAnB,EAA+BhB,SAA/B,CAA1B;AACA,cAAImB,WAAW,GAAGpC,cAAc,CAACkC,gBAAD,EAAmBD,UAAnB,EAA+BlB,YAA/B,CAAhC;;AAEA,cAAIoB,QAAQ,KAAKjB,SAAb,IAA0BmB,UAAU,CAACE,GAAX,KAAmBJ,QAA7C,IAAyDC,WAAW,KAAKlB,SAAhB,IAA6BmB,UAAU,CAACM,MAAX,KAAsBP,WAAhH,EAA6H;AAC3H;AACD;AACF;AACF,OAnBkC,CAmBjC;;;AAGF,WAAKS,cAAL;AACD;AAzBA,GA7EiB,CAAR,CAAZ;;AAyGA,SAAOzC,KAAP;AACD,CA5QwB,CA4QvBd,KAAK,CAACsF,SA5QiB,CAAzB;;AA8QAxE,KAAK,CAACyE,WAAN,GAAoBnF,aAApB;;AAEApB,UAAU,CAAC,CAACqB,iCAAiC,EAAlC,CAAD,EAAwCS,KAAK,CAAC0E,SAA9C,EAAyD,gBAAzD,EAA2E,IAA3E,CAAV;;AAEAxG,UAAU,CAAC,CAACqB,iCAAiC,EAAlC,CAAD,EAAwCS,KAAK,CAAC0E,SAA9C,EAAyD,oBAAzD,EAA+E,IAA/E,CAAV;;AAEA,eAAe1E,KAAf","sourcesContent":["import _extends from \"@babel/runtime/helpers/extends\";\nimport _defineProperty from \"@babel/runtime/helpers/defineProperty\";\nimport _classCallCheck from \"@babel/runtime/helpers/classCallCheck\";\nimport _createClass from \"@babel/runtime/helpers/createClass\";\nimport _inherits from \"@babel/runtime/helpers/inherits\";\nimport _createSuper from \"@babel/runtime/helpers/createSuper\";\nimport _typeof from \"@babel/runtime/helpers/typeof\";\n\nvar __decorate = this && this.__decorate || function (decorators, target, key, desc) {\n  var c = arguments.length,\n      r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,\n      d;\n  if ((typeof Reflect === \"undefined\" ? \"undefined\" : _typeof(Reflect)) === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) {\n    if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n  }\n  return c > 3 && r && Object.defineProperty(target, key, r), r;\n};\n\nimport * as React from 'react';\nimport classNames from 'classnames';\nimport omit from 'omit.js';\nimport ResizeObserver from 'rc-resize-observer';\nimport { ConfigContext } from '../config-provider';\nimport { throttleByAnimationFrameDecorator } from '../_util/throttleByAnimationFrame';\nimport { addObserveTarget, removeObserveTarget, getTargetRect, getFixedTop, getFixedBottom } from './utils';\n\nfunction getDefaultTarget() {\n  return typeof window !== 'undefined' ? window : null;\n}\n\nvar AffixStatus;\n\n(function (AffixStatus) {\n  AffixStatus[AffixStatus[\"None\"] = 0] = \"None\";\n  AffixStatus[AffixStatus[\"Prepare\"] = 1] = \"Prepare\";\n})(AffixStatus || (AffixStatus = {}));\n\nvar Affix = /*#__PURE__*/function (_React$Component) {\n  _inherits(Affix, _React$Component);\n\n  var _super = _createSuper(Affix);\n\n  function Affix() {\n    var _this;\n\n    _classCallCheck(this, Affix);\n\n    _this = _super.apply(this, arguments);\n    _this.state = {\n      status: AffixStatus.None,\n      lastAffix: false,\n      prevTarget: null\n    };\n\n    _this.getOffsetTop = function () {\n      var offsetBottom = _this.props.offsetBottom;\n      var offsetTop = _this.props.offsetTop;\n\n      if (offsetBottom === undefined && offsetTop === undefined) {\n        offsetTop = 0;\n      }\n\n      return offsetTop;\n    };\n\n    _this.getOffsetBottom = function () {\n      return _this.props.offsetBottom;\n    };\n\n    _this.savePlaceholderNode = function (node) {\n      _this.placeholderNode = node;\n    };\n\n    _this.saveFixedNode = function (node) {\n      _this.fixedNode = node;\n    }; // =================== Measure ===================\n\n\n    _this.measure = function () {\n      var _this$state = _this.state,\n          status = _this$state.status,\n          lastAffix = _this$state.lastAffix;\n      var onChange = _this.props.onChange;\n\n      var targetFunc = _this.getTargetFunc();\n\n      if (status !== AffixStatus.Prepare || !_this.fixedNode || !_this.placeholderNode || !targetFunc) {\n        return;\n      }\n\n      var offsetTop = _this.getOffsetTop();\n\n      var offsetBottom = _this.getOffsetBottom();\n\n      var targetNode = targetFunc();\n\n      if (!targetNode) {\n        return;\n      }\n\n      var newState = {\n        status: AffixStatus.None\n      };\n      var targetRect = getTargetRect(targetNode);\n      var placeholderReact = getTargetRect(_this.placeholderNode);\n      var fixedTop = getFixedTop(placeholderReact, targetRect, offsetTop);\n      var fixedBottom = getFixedBottom(placeholderReact, targetRect, offsetBottom);\n\n      if (fixedTop !== undefined) {\n        newState.affixStyle = {\n          position: 'fixed',\n          top: fixedTop,\n          width: placeholderReact.width,\n          height: placeholderReact.height\n        };\n        newState.placeholderStyle = {\n          width: placeholderReact.width,\n          height: placeholderReact.height\n        };\n      } else if (fixedBottom !== undefined) {\n        newState.affixStyle = {\n          position: 'fixed',\n          bottom: fixedBottom,\n          width: placeholderReact.width,\n          height: placeholderReact.height\n        };\n        newState.placeholderStyle = {\n          width: placeholderReact.width,\n          height: placeholderReact.height\n        };\n      }\n\n      newState.lastAffix = !!newState.affixStyle;\n\n      if (onChange && lastAffix !== newState.lastAffix) {\n        onChange(newState.lastAffix);\n      }\n\n      _this.setState(newState);\n    }; // @ts-ignore TS6133\n\n\n    _this.prepareMeasure = function () {\n      // event param is used before. Keep compatible ts define here.\n      _this.setState({\n        status: AffixStatus.Prepare,\n        affixStyle: undefined,\n        placeholderStyle: undefined\n      }); // Test if `updatePosition` called\n\n\n      if (process.env.NODE_ENV === 'test') {\n        var onTestUpdatePosition = _this.props.onTestUpdatePosition;\n\n        if (onTestUpdatePosition) {\n          onTestUpdatePosition();\n        }\n      }\n    }; // =================== Render ===================\n\n\n    _this.render = function () {\n      var getPrefixCls = _this.context.getPrefixCls;\n      var _this$state2 = _this.state,\n          affixStyle = _this$state2.affixStyle,\n          placeholderStyle = _this$state2.placeholderStyle;\n      var _this$props = _this.props,\n          prefixCls = _this$props.prefixCls,\n          children = _this$props.children;\n      var className = classNames(_defineProperty({}, getPrefixCls('affix', prefixCls), affixStyle));\n      var props = omit(_this.props, ['prefixCls', 'offsetTop', 'offsetBottom', 'target', 'onChange']); // Omit this since `onTestUpdatePosition` only works on test.\n\n      if (process.env.NODE_ENV === 'test') {\n        props = omit(props, ['onTestUpdatePosition']);\n      }\n\n      return /*#__PURE__*/React.createElement(ResizeObserver, {\n        onResize: function onResize() {\n          _this.updatePosition();\n        }\n      }, /*#__PURE__*/React.createElement(\"div\", _extends({}, props, {\n        ref: _this.savePlaceholderNode\n      }), affixStyle && /*#__PURE__*/React.createElement(\"div\", {\n        style: placeholderStyle,\n        \"aria-hidden\": \"true\"\n      }), /*#__PURE__*/React.createElement(\"div\", {\n        className: className,\n        ref: _this.saveFixedNode,\n        style: affixStyle\n      }, /*#__PURE__*/React.createElement(ResizeObserver, {\n        onResize: function onResize() {\n          _this.updatePosition();\n        }\n      }, children))));\n    };\n\n    return _this;\n  }\n\n  _createClass(Affix, [{\n    key: \"getTargetFunc\",\n    value: function getTargetFunc() {\n      var getTargetContainer = this.context.getTargetContainer;\n      var target = this.props.target;\n\n      if (target !== undefined) {\n        return target;\n      }\n\n      return getTargetContainer || getDefaultTarget;\n    } // Event handler\n\n  }, {\n    key: \"componentDidMount\",\n    value: function componentDidMount() {\n      var _this2 = this;\n\n      var targetFunc = this.getTargetFunc();\n\n      if (targetFunc) {\n        // [Legacy] Wait for parent component ref has its value.\n        // We should use target as directly element instead of function which makes element check hard.\n        this.timeout = setTimeout(function () {\n          addObserveTarget(targetFunc(), _this2); // Mock Event object.\n\n          _this2.updatePosition();\n        });\n      }\n    }\n  }, {\n    key: \"componentDidUpdate\",\n    value: function componentDidUpdate(prevProps) {\n      var prevTarget = this.state.prevTarget;\n      var targetFunc = this.getTargetFunc();\n      var newTarget = null;\n\n      if (targetFunc) {\n        newTarget = targetFunc() || null;\n      }\n\n      if (prevTarget !== newTarget) {\n        removeObserveTarget(this);\n\n        if (newTarget) {\n          addObserveTarget(newTarget, this); // Mock Event object.\n\n          this.updatePosition();\n        } // eslint-disable-next-line react/no-did-update-set-state\n\n\n        this.setState({\n          prevTarget: newTarget\n        });\n      }\n\n      if (prevProps.offsetTop !== this.props.offsetTop || prevProps.offsetBottom !== this.props.offsetBottom) {\n        this.updatePosition();\n      }\n\n      this.measure();\n    }\n  }, {\n    key: \"componentWillUnmount\",\n    value: function componentWillUnmount() {\n      clearTimeout(this.timeout);\n      removeObserveTarget(this);\n      this.updatePosition.cancel(); // https://github.com/ant-design/ant-design/issues/22683\n\n      this.lazyUpdatePosition.cancel();\n    } // Handle realign logic\n\n  }, {\n    key: \"updatePosition\",\n    value: function updatePosition() {\n      this.prepareMeasure();\n    }\n  }, {\n    key: \"lazyUpdatePosition\",\n    value: function lazyUpdatePosition() {\n      var targetFunc = this.getTargetFunc();\n      var affixStyle = this.state.affixStyle; // Check position change before measure to make Safari smooth\n\n      if (targetFunc && affixStyle) {\n        var offsetTop = this.getOffsetTop();\n        var offsetBottom = this.getOffsetBottom();\n        var targetNode = targetFunc();\n\n        if (targetNode && this.placeholderNode) {\n          var targetRect = getTargetRect(targetNode);\n          var placeholderReact = getTargetRect(this.placeholderNode);\n          var fixedTop = getFixedTop(placeholderReact, targetRect, offsetTop);\n          var fixedBottom = getFixedBottom(placeholderReact, targetRect, offsetBottom);\n\n          if (fixedTop !== undefined && affixStyle.top === fixedTop || fixedBottom !== undefined && affixStyle.bottom === fixedBottom) {\n            return;\n          }\n        }\n      } // Directly call prepare measure since it's already throttled.\n\n\n      this.prepareMeasure();\n    }\n  }]);\n\n  return Affix;\n}(React.Component);\n\nAffix.contextType = ConfigContext;\n\n__decorate([throttleByAnimationFrameDecorator()], Affix.prototype, \"updatePosition\", null);\n\n__decorate([throttleByAnimationFrameDecorator()], Affix.prototype, \"lazyUpdatePosition\", null);\n\nexport default Affix;"]},"metadata":{},"sourceType":"module"}