d4756b19cb54456943f5a01e8f4d5327.json
6.04 KB
{"ast":null,"code":"import { useMemo } from 'react';\nvar DEFAULT_SIZE = {\n width: 0,\n height: 0,\n left: 0,\n top: 0,\n right: 0\n};\nexport default function useVisibleRange(tabOffsets, containerSize, tabContentNodeSize, addNodeSize, _ref) {\n var tabs = _ref.tabs,\n tabPosition = _ref.tabPosition,\n rtl = _ref.rtl;\n var unit;\n var position;\n var transformSize;\n\n if (['top', 'bottom'].includes(tabPosition)) {\n unit = 'width';\n position = rtl ? 'right' : 'left';\n transformSize = Math.abs(containerSize.left);\n } else {\n unit = 'height';\n position = 'top';\n transformSize = -containerSize.top;\n }\n\n var basicSize = containerSize[unit];\n var tabContentSize = tabContentNodeSize[unit];\n var addSize = addNodeSize[unit];\n var mergedBasicSize = basicSize;\n\n if (tabContentSize + addSize > basicSize) {\n mergedBasicSize = basicSize - addSize;\n }\n\n return useMemo(function () {\n if (!tabs.length) {\n return [0, 0];\n }\n\n var len = tabs.length;\n var endIndex = len;\n\n for (var i = 0; i < len; i += 1) {\n var offset = tabOffsets.get(tabs[i].key) || DEFAULT_SIZE;\n\n if (offset[position] + offset[unit] > transformSize + mergedBasicSize) {\n endIndex = i - 1;\n break;\n }\n }\n\n var startIndex = 0;\n\n for (var _i = len - 1; _i >= 0; _i -= 1) {\n var _offset = tabOffsets.get(tabs[_i].key) || DEFAULT_SIZE;\n\n if (_offset[position] < transformSize) {\n startIndex = _i + 1;\n break;\n }\n }\n\n return [startIndex, endIndex];\n }, [tabOffsets, transformSize, mergedBasicSize, tabPosition, tabs.map(function (tab) {\n return tab.key;\n }).join('_'), rtl]);\n}","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/rc-tabs/es/hooks/useVisibleRange.js"],"names":["useMemo","DEFAULT_SIZE","width","height","left","top","right","useVisibleRange","tabOffsets","containerSize","tabContentNodeSize","addNodeSize","_ref","tabs","tabPosition","rtl","unit","position","transformSize","includes","Math","abs","basicSize","tabContentSize","addSize","mergedBasicSize","length","len","endIndex","i","offset","get","key","startIndex","_i","_offset","map","tab","join"],"mappings":"AAAA,SAASA,OAAT,QAAwB,OAAxB;AACA,IAAIC,YAAY,GAAG;AACjBC,EAAAA,KAAK,EAAE,CADU;AAEjBC,EAAAA,MAAM,EAAE,CAFS;AAGjBC,EAAAA,IAAI,EAAE,CAHW;AAIjBC,EAAAA,GAAG,EAAE,CAJY;AAKjBC,EAAAA,KAAK,EAAE;AALU,CAAnB;AAOA,eAAe,SAASC,eAAT,CAAyBC,UAAzB,EAAqCC,aAArC,EAAoDC,kBAApD,EAAwEC,WAAxE,EAAqFC,IAArF,EAA2F;AACxG,MAAIC,IAAI,GAAGD,IAAI,CAACC,IAAhB;AAAA,MACIC,WAAW,GAAGF,IAAI,CAACE,WADvB;AAAA,MAEIC,GAAG,GAAGH,IAAI,CAACG,GAFf;AAGA,MAAIC,IAAJ;AACA,MAAIC,QAAJ;AACA,MAAIC,aAAJ;;AAEA,MAAI,CAAC,KAAD,EAAQ,QAAR,EAAkBC,QAAlB,CAA2BL,WAA3B,CAAJ,EAA6C;AAC3CE,IAAAA,IAAI,GAAG,OAAP;AACAC,IAAAA,QAAQ,GAAGF,GAAG,GAAG,OAAH,GAAa,MAA3B;AACAG,IAAAA,aAAa,GAAGE,IAAI,CAACC,GAAL,CAASZ,aAAa,CAACL,IAAvB,CAAhB;AACD,GAJD,MAIO;AACLY,IAAAA,IAAI,GAAG,QAAP;AACAC,IAAAA,QAAQ,GAAG,KAAX;AACAC,IAAAA,aAAa,GAAG,CAACT,aAAa,CAACJ,GAA/B;AACD;;AAED,MAAIiB,SAAS,GAAGb,aAAa,CAACO,IAAD,CAA7B;AACA,MAAIO,cAAc,GAAGb,kBAAkB,CAACM,IAAD,CAAvC;AACA,MAAIQ,OAAO,GAAGb,WAAW,CAACK,IAAD,CAAzB;AACA,MAAIS,eAAe,GAAGH,SAAtB;;AAEA,MAAIC,cAAc,GAAGC,OAAjB,GAA2BF,SAA/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AX;AACD,GAF4D,EAE1DM,IAF0D,CAErD,GAFqD,CAA1D,EAEWvB,GAFX,CA7BW,CAAd;AAgCD","sourcesContent":["import { useMemo } from 'react';\nvar DEFAULT_SIZE = {\n width: 0,\n height: 0,\n left: 0,\n top: 0,\n right: 0\n};\nexport default function useVisibleRange(tabOffsets, containerSize, tabContentNodeSize, addNodeSize, _ref) {\n var tabs = _ref.tabs,\n tabPosition = _ref.tabPosition,\n rtl = _ref.rtl;\n var unit;\n var position;\n var transformSize;\n\n if (['top', 'bottom'].includes(tabPosition)) {\n unit = 'width';\n position = rtl ? 'right' : 'left';\n transformSize = Math.abs(containerSize.left);\n } else {\n unit = 'height';\n position = 'top';\n transformSize = -containerSize.top;\n }\n\n var basicSize = containerSize[unit];\n var tabContentSize = tabContentNodeSize[unit];\n var addSize = addNodeSize[unit];\n var mergedBasicSize = basicSize;\n\n if (tabContentSize + addSize > basicSize) {\n mergedBasicSize = basicSize - addSize;\n }\n\n return useMemo(function () {\n if (!tabs.length) {\n return [0, 0];\n }\n\n var len = tabs.length;\n var endIndex = len;\n\n for (var i = 0; i < len; i += 1) {\n var offset = tabOffsets.get(tabs[i].key) || DEFAULT_SIZE;\n\n if (offset[position] + offset[unit] > transformSize + mergedBasicSize) {\n endIndex = i - 1;\n break;\n }\n }\n\n var startIndex = 0;\n\n for (var _i = len - 1; _i >= 0; _i -= 1) {\n var _offset = tabOffsets.get(tabs[_i].key) || DEFAULT_SIZE;\n\n if (_offset[position] < transformSize) {\n startIndex = _i + 1;\n break;\n }\n }\n\n return [startIndex, endIndex];\n }, [tabOffsets, transformSize, mergedBasicSize, tabPosition, tabs.map(function (tab) {\n return tab.key;\n }).join('_'), rtl]);\n}"]},"metadata":{},"sourceType":"module"}