1 line
76 KiB
Plaintext
1 line
76 KiB
Plaintext
|
{"version":3,"file":"perfect-scrollbar.min.js","sources":["../src/handlers/mouse-wheel.js","../src/update-geometry.js","../src/lib/css.js","../src/lib/dom.js","../src/lib/class-names.js","../src/process-scroll-diff.js","../src/lib/util.js","../src/handlers/drag-thumb.js","../src/lib/event-manager.js","../src/index.js","../src/handlers/click-rail.js","../src/handlers/keyboard.js","../src/handlers/touch.js"],"sourcesContent":["import * as CSS from '../lib/css';\nimport cls from '../lib/class-names';\nimport updateGeometry from '../update-geometry';\nimport { env } from '../lib/util';\n\nexport default function(i) {\n const element = i.element;\n\n let shouldPrevent = false;\n\n function shouldPreventDefault(deltaX, deltaY) {\n const roundedScrollTop = Math.floor(element.scrollTop);\n const isTop = element.scrollTop === 0;\n const isBottom =\n roundedScrollTop + element.offsetHeight === element.scrollHeight;\n const isLeft = element.scrollLeft === 0;\n const isRight =\n element.scrollLeft + element.offsetWidth === element.scrollWidth;\n\n let hitsBound;\n\n // pick axis with primary direction\n if (Math.abs(deltaY) > Math.abs(deltaX)) {\n hitsBound = isTop || isBottom;\n } else {\n hitsBound = isLeft || isRight;\n }\n\n return hitsBound ? !i.settings.wheelPropagation : true;\n }\n\n function getDeltaFromEvent(e) {\n let deltaX = e.deltaX;\n let deltaY = -1 * e.deltaY;\n\n if (typeof deltaX === 'undefined' || typeof deltaY === 'undefined') {\n // OS X Safari\n deltaX = (-1 * e.wheelDeltaX) / 6;\n deltaY = e.wheelDeltaY / 6;\n }\n\n if (e.deltaMode && e.deltaMode === 1) {\n // Firefox in deltaMode 1: Line scrolling\n deltaX *= 10;\n deltaY *= 10;\n }\n\n if (deltaX !== deltaX && deltaY !== deltaY /* NaN checks */) {\n // IE in some mouse drivers\n deltaX = 0;\n deltaY = e.wheelDelta;\n }\n\n if (e.shiftKey) {\n // reverse axis with shift key\n return [-deltaY, -deltaX];\n }\n return [deltaX, deltaY];\n }\n\n function shouldBeConsumedByChild(target, deltaX, deltaY) {\n // FIXME: this is a workaround for <select> issue in FF and IE #571\n if (!env.isWebKit && element.querySelector('select:focus')) {\n return true;\n }\n\n if (!element.contains(target)) {\n return false;\n }\n\n let cursor = target;\n\n while (cursor && cursor !== element) {\n if (cursor.classList.contains(cls.element.consuming)) {\n return true;\n }\n\n const style = CSS.get(cursor);\n\n // if deltaY && vertical scrollable\n if (deltaY && style.overflowY.match(/(scroll|auto)/)) {\n const maxScrollTop = cursor.scrollHeight - cursor.clientHeight;\n if (maxScrollTop > 0) {\n if (\n (cursor.scrollTop > 0 && deltaY < 0) ||\n (cursor.scrollTop < maxScrollTop && deltaY > 0)\n ) {\n return true;\n }\n }\n }\n // if deltaX && horizontal scrollable\n if (deltaX && style.overflowX.match(/(scroll|auto)/)) {\n const maxScrollLeft = cursor.scrollWidth - cursor.clientWidth;\n if (maxScrollLeft > 0) {\n if (\n (cursor.scrollLeft > 0 && deltaX < 0) ||\n (cursor.scrollLeft < maxScrollLeft && deltaX > 0)\n ) {\n return true;\n }\n }\n }\n\n cursor = cursor.parentNode;\n }\n\n return false;\n }\n\n function mousewheelHandler(e) {\n const [deltaX, deltaY] = getDeltaFromEvent(e);\n\n if (shouldBeConsumedByChild(e.target, deltaX, deltaY)) {\n return;\n }\n\n let shouldPrevent = false;\n if (!i.settings.useBothWheelAxes) {\n // deltaX will only be used for horizontal scrolling and deltaY will\n // only be used for vertical scrolling - this is the default\n element.scrollTop -= deltaY * i.settings.wheelSpeed;\n element.scrollLeft += deltaX * i.settings.wheelSpeed;\n } else if (i.scrollbarYActive && !i.scrollbarXActive) {\n // only vertical
|