b8b8aae82b2709765a30b13bb9a5c5b3.json
5 KB
{"ast":null,"code":"import compute from 'compute-scroll-into-view';\n\nfunction isOptionsObject(options) {\n return options === Object(options) && Object.keys(options).length !== 0;\n}\n\nfunction defaultBehavior(actions, behavior) {\n if (behavior === void 0) {\n behavior = 'auto';\n }\n\n var canSmoothScroll = ('scrollBehavior' in document.body.style);\n actions.forEach(function (_ref) {\n var el = _ref.el,\n top = _ref.top,\n left = _ref.left;\n\n if (el.scroll && canSmoothScroll) {\n el.scroll({\n top: top,\n left: left,\n behavior: behavior\n });\n } else {\n el.scrollTop = top;\n el.scrollLeft = left;\n }\n });\n}\n\nfunction getOptions(options) {\n if (options === false) {\n return {\n block: 'end',\n inline: 'nearest'\n };\n }\n\n if (isOptionsObject(options)) {\n return options;\n }\n\n return {\n block: 'start',\n inline: 'nearest'\n };\n}\n\nfunction scrollIntoView(target, options) {\n var targetIsDetached = !target.ownerDocument.documentElement.contains(target);\n\n if (isOptionsObject(options) && typeof options.behavior === 'function') {\n return options.behavior(targetIsDetached ? [] : compute(target, options));\n }\n\n if (targetIsDetached) {\n return;\n }\n\n var computeOptions = getOptions(options);\n return defaultBehavior(compute(target, computeOptions), computeOptions.behavior);\n}\n\nexport default scrollIntoView;","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/scroll-into-view-if-needed/es/index.js"],"names":["compute","isOptionsObject","options","Object","keys","length","defaultBehavior","actions","behavior","canSmoothScroll","document","body","style","forEach","_ref","el","top","left","scroll","scrollTop","scrollLeft","getOptions","block","inline","scrollIntoView","target","targetIsDetached","ownerDocument","documentElement","contains","computeOptions"],"mappings":"AAAA,OAAOA,OAAP,MAAoB,0BAApB;;AAEA,SAASC,eAAT,CAAyBC,OAAzB,EAAkC;AAChC,SAAOA,OAAO,KAAKC,MAAM,CAACD,OAAD,CAAlB,IAA+BC,MAAM,CAACC,IAAP,CAAYF,OAAZ,EAAqBG,MAArB,KAAgC,CAAtE;AACD;;AAED,S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xB,eAAe,CAACC,OAAD,CAAf,IAA4B,OAAOA,OAAO,CAACM,QAAf,KAA4B,UAA5D,EAAwE;AACtE,WAAON,OAAO,CAACM,QAAR,CAAiBkB,gBAAgB,GAAG,EAAH,GAAQ1B,OAAO,CAACyB,MAAD,EAASvB,OAAT,CAAhD,CAAP;AACD;;AAED,MAAIwB,gBAAJ,EAAsB;AACpB;AACD;;AAED,MAAII,cAAc,GAAGT,UAAU,CAACnB,OAAD,CAA/B;AACA,SAAOI,eAAe,CAACN,OAAO,CAACyB,MAAD,EAASK,cAAT,CAAR,EAAkCA,cAAc,CAACtB,QAAjD,CAAtB;AACD;;AAED,eAAegB,cAAf","sourcesContent":["import compute from 'compute-scroll-into-view';\n\nfunction isOptionsObject(options) {\n return options === Object(options) && Object.keys(options).length !== 0;\n}\n\nfunction defaultBehavior(actions, behavior) {\n if (behavior === void 0) {\n behavior = 'auto';\n }\n\n var canSmoothScroll = ('scrollBehavior' in document.body.style);\n actions.forEach(function (_ref) {\n var el = _ref.el,\n top = _ref.top,\n left = _ref.left;\n\n if (el.scroll && canSmoothScroll) {\n el.scroll({\n top: top,\n left: left,\n behavior: behavior\n });\n } else {\n el.scrollTop = top;\n el.scrollLeft = left;\n }\n });\n}\n\nfunction getOptions(options) {\n if (options === false) {\n return {\n block: 'end',\n inline: 'nearest'\n };\n }\n\n if (isOptionsObject(options)) {\n return options;\n }\n\n return {\n block: 'start',\n inline: 'nearest'\n };\n}\n\nfunction scrollIntoView(target, options) {\n var targetIsDetached = !target.ownerDocument.documentElement.contains(target);\n\n if (isOptionsObject(options) && typeof options.behavior === 'function') {\n return options.behavior(targetIsDetached ? [] : compute(target, options));\n }\n\n if (targetIsDetached) {\n return;\n }\n\n var computeOptions = getOptions(options);\n return defaultBehavior(compute(target, computeOptions), computeOptions.behavior);\n}\n\nexport default scrollIntoView;"]},"metadata":{},"sourceType":"module"}