8794eb137fe403e1964257df9b82e40b.json
6.16 KB
{"ast":null,"code":"import _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport ResizeObserver from 'resize-observer-polyfill';\nimport contains from \"rc-util/es/Dom/contains\";\nexport function isSamePoint(prev, next) {\n if (prev === next) return true;\n if (!prev || !next) return false;\n\n if ('pageX' in next && 'pageY' in next) {\n return prev.pageX === next.pageX && prev.pageY === next.pageY;\n }\n\n if ('clientX' in next && 'clientY' in next) {\n return prev.clientX === next.clientX && prev.clientY === next.clientY;\n }\n\n return false;\n}\nexport function restoreFocus(activeElement, container) {\n // Focus back if is in the container\n if (activeElement !== document.activeElement && contains(container, activeElement) && typeof activeElement.focus === 'function') {\n activeElement.focus();\n }\n}\nexport function monitorResize(element, callback) {\n var prevWidth = null;\n var prevHeight = null;\n\n function onResize(_ref) {\n var _ref2 = _slicedToArray(_ref, 1),\n target = _ref2[0].target;\n\n if (!document.documentElement.contains(target)) return;\n\n var _target$getBoundingCl = target.getBoundingClientRect(),\n width = _target$getBoundingCl.width,\n height = _target$getBoundingCl.height;\n\n var fixedWidth = Math.floor(width);\n var fixedHeight = Math.floor(height);\n\n if (prevWidth !== fixedWidth || prevHeight !== fixedHeight) {\n // https://webkit.org/blog/9997/resizeobserver-in-webkit/\n Promise.resolve().then(function () {\n callback({\n width: fixedWidth,\n height: fixedHeight\n });\n });\n }\n\n prevWidth = fixedWidth;\n prevHeight = fixedHeight;\n }\n\n var resizeObserver = new ResizeObserver(onResize);\n\n if (element) {\n resizeObserver.observe(element);\n }\n\n return function () {\n resizeObserver.disconnect();\n };\n}","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/rc-align/es/util.js"],"names":["_slicedToArray","ResizeObserver","contains","isSamePoint","prev","next","pageX","pageY","clientX","clientY","restoreFocus","activeElement","container","document","focus","monitorResize","element","callback","prevWidth","prevHeight","onResize","_ref","_ref2","target","documentElement","_target$getBoundingCl","getBoundingClientRect","width","height","fixedWidth","Math","floor","fixedHeight","Promise","resolve","then","resizeObserver","observe","disconnect"],"mappings":"AAAA,OAAOA,cAAP,MAA2B,0CAA3B;AACA,OAAOC,cAAP,MAA2B,0BAA3B;AACA,OAAOC,QAAP,MAAqB,yBAArB;AACA,OAAO,SAASC,WAAT,CAAqBC,IAArB,EAA2BC,IAA3B,EAAiC;AACtC,MAAID,IAAI,KAAKC,IAAb,EAAmB,OAAO,IAAP;AACnB,MAAI,CAACD,IAAD,IAAS,CAACC,IAAd,EAAoB,OAAO,KAAP;;AAEpB,MAAI,WAAWA,IAAX,IAAmB,WAAWA,IAAlC,EAAwC;AACtC,WAAOD,IAAI,CAACE,KAAL,KAAeD,IAAI,CAACC,KAApB,IAA6BF,IAAI,CAACG,KAAL,KAAeF,IAAI,CAACE,KAAxD;AACD;;AAED,MAAI,aAAaF,IAAb,IAAqB,aAAaA,IAAtC,EAA4C;AAC1C,WAAOD,IAAI,CAACI,OAAL,KAAiBH,IAAI,CAACG,OAAtB,IAAiCJ,IAAI,CAACK,OAAL,KAAiBJ,IAAI,CAACI,OAA9D;AACD;;AAED,SAAO,KAAP;AACD;AACD,OAAO,SAASC,YAAT,CAAsBC,aAAtB,EAAqCC,SAArC,EAAgD;AACrD;AACA,MAAID,aAAa,KAAKE,QAAQ,CAACF,aAA3B,IAA4CT,QAAQ,CAACU,SAAD,EAAYD,aAAZ,CAApD,IAAkF,OAAOA,aAAa,CAACG,KAArB,KAA+B,UAArH,EAAiI;AAC/HH,IAAAA,aAAa,CAACG,KAAd;AACD;AACF;AACD,OAAO,SAASC,aAAT,CAAuBC,OAAvB,EAAgCC,QAAhC,EAA0C;AAC/C,MAAIC,SAAS,GAAG,IAAhB;AACA,MAAIC,UAAU,GAAG,IAAjB;;AAEA,WAASC,QAAT,CAAkBC,IAAlB,EAAwB;AACtB,QAAIC,KAAK,GAAGtB,cAAc,CAACqB,IAAD,EAAO,CAAP,CAA1B;AAAA,QACIE,MAAM,GAAGD,KAAK,CAAC,CAAD,CAAL,CAASC,MADtB;;AAGA,QAAI,CAACV,QAAQ,CAACW,eAAT,CAAyBtB,QAAzB,CAAkCqB,MAAlC,CAAL,EAAgD;;AAEhD,QAAIE,qBAAqB,GAAGF,MAAM,CAACG,qBAAP,EAA5B;AAAA,QACIC,KAAK,GAAGF,qBAAqB,CAACE,KADlC;AAAA,QAEIC,MAAM,GAAGH,qBAAqB,CAACG,MAFnC;;AAIA,QAAIC,UAAU,GAAGC,IAAI,CAACC,KAAL,CAAWJ,KAAX,CAAjB;AACA,QAAIK,WAAW,GAAGF,IAAI,CAACC,KAAL,CAAWH,MAAX,CAAlB;;AAEA,QAAIV,SAAS,KAAKW,UAAd,IAA4BV,UAAU,KAAKa,WAA/C,EAA4D;AAC1D;AACAC,MAAAA,OAAO,CAACC,OAAR,GAAkBC,IAAlB,CAAuB,YAAY;AACjClB,QAAAA,QAAQ,CAAC;AACPU,UAAAA,KAAK,EAAEE,UADA;AAEPD,UAAAA,MAAM,EAAEI;AAFD,SAAD,CAAR;AAID,OALD;AAMD;;AAEDd,IAAAA,SAAS,GAAGW,UAAZ;AACAV,IAAAA,UAAU,GAAGa,WAAb;AACD;;AAED,MAAII,cAAc,GAAG,IAAInC,cAAJ,CAAmBmB,QAAnB,CAArB;;AAEA,MAAIJ,OAAJ,EAAa;AACXoB,IAAAA,cAAc,CAACC,OAAf,CAAuBrB,OAAvB;AACD;;AAED,SAAO,YAAY;AACjBoB,IAAAA,cAAc,CAACE,UAAf;AACD,GAFD;AAGD","sourcesContent":["import _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport ResizeObserver from 'resize-observer-polyfill';\nimport contains from \"rc-util/es/Dom/contains\";\nexport function isSamePoint(prev, next) {\n if (prev === next) return true;\n if (!prev || !next) return false;\n\n if ('pageX' in next && 'pageY' in next) {\n return prev.pageX === next.pageX && prev.pageY === next.pageY;\n }\n\n if ('clientX' in next && 'clientY' in next) {\n return prev.clientX === next.clientX && prev.clientY === next.clientY;\n }\n\n return false;\n}\nexport function restoreFocus(activeElement, container) {\n // Focus back if is in the container\n if (activeElement !== document.activeElement && contains(container, activeElement) && typeof activeElement.focus === 'function') {\n activeElement.focus();\n }\n}\nexport function monitorResize(element, callback) {\n var prevWidth = null;\n var prevHeight = null;\n\n function onResize(_ref) {\n var _ref2 = _slicedToArray(_ref, 1),\n target = _ref2[0].target;\n\n if (!document.documentElement.contains(target)) return;\n\n var _target$getBoundingCl = target.getBoundingClientRect(),\n width = _target$getBoundingCl.width,\n height = _target$getBoundingCl.height;\n\n var fixedWidth = Math.floor(width);\n var fixedHeight = Math.floor(height);\n\n if (prevWidth !== fixedWidth || prevHeight !== fixedHeight) {\n // https://webkit.org/blog/9997/resizeobserver-in-webkit/\n Promise.resolve().then(function () {\n callback({\n width: fixedWidth,\n height: fixedHeight\n });\n });\n }\n\n prevWidth = fixedWidth;\n prevHeight = fixedHeight;\n }\n\n var resizeObserver = new ResizeObserver(onResize);\n\n if (element) {\n resizeObserver.observe(element);\n }\n\n return function () {\n resizeObserver.disconnect();\n };\n}"]},"metadata":{},"sourceType":"module"}