svoydom/public/assets/plugins/perfect-scrollbar/perfect-scrollbar.js.map

1 line
74 KiB
Plaintext
Raw Permalink Normal View History

2023-05-17 09:57:20 +03:00
{"version":3,"file":"perfect-scrollbar.js","sources":["../src/lib/css.js","../src/lib/dom.js","../src/lib/class-names.js","../src/lib/event-manager.js","../src/process-scroll-diff.js","../src/lib/util.js","../src/update-geometry.js","../src/handlers/click-rail.js","../src/handlers/drag-thumb.js","../src/handlers/keyboard.js","../src/handlers/mouse-wheel.js","../src/handlers/touch.js","../src/index.js"],"sourcesContent":["export function get(element) {\n return getComputedStyle(element);\n}\n\nexport function set(element, obj) {\n for (const key in obj) {\n let val = obj[key];\n if (typeof val === 'number') {\n val = `${val}px`;\n }\n element.style[key] = val;\n }\n return element;\n}\n","export function div(className) {\n const div = document.createElement('div');\n div.className = className;\n return div;\n}\n\nconst elMatches =\n typeof Element !== 'undefined' &&\n (Element.prototype.matches ||\n Element.prototype.webkitMatchesSelector ||\n Element.prototype.mozMatchesSelector ||\n Element.prototype.msMatchesSelector);\n\nexport function matches(element, query) {\n if (!elMatches) {\n throw new Error('No element matching method supported');\n }\n\n return elMatches.call(element, query);\n}\n\nexport function remove(element) {\n if (element.remove) {\n element.remove();\n } else {\n if (element.parentNode) {\n element.parentNode.removeChild(element);\n }\n }\n}\n\nexport function queryChildren(element, selector) {\n return Array.prototype.filter.call(element.children, child =>\n matches(child, selector)\n );\n}\n","const cls = {\n main: 'ps',\n rtl: 'ps__rtl',\n element: {\n thumb: x => `ps__thumb-${x}`,\n rail: x => `ps__rail-${x}`,\n consuming: 'ps__child--consume',\n },\n state: {\n focus: 'ps--focus',\n clicking: 'ps--clicking',\n active: x => `ps--active-${x}`,\n scrolling: x => `ps--scrolling-${x}`,\n },\n};\n\nexport default cls;\n\n/*\n * Helper methods\n */\nconst scrollingClassTimeout = { x: null, y: null };\n\nexport function addScrollingClass(i, x) {\n const classList = i.element.classList;\n const className = cls.state.scrolling(x);\n\n if (classList.contains(className)) {\n clearTimeout(scrollingClassTimeout[x]);\n } else {\n classList.add(className);\n }\n}\n\nexport function removeScrollingClass(i, x) {\n scrollingClassTimeout[x] = setTimeout(\n () => i.isAlive && i.element.classList.remove(cls.state.scrolling(x)),\n i.settings.scrollingThreshold\n );\n}\n\nexport function setScrollingClassInstantly(i, x) {\n addScrollingClass(i, x);\n removeScrollingClass(i, x);\n}\n","class EventElement {\n constructor(element) {\n this.element = element;\n this.handlers = {};\n }\n\n bind(eventName, handler) {\n if (typeof this.handlers[eventName] === 'undefined') {\n this.handlers[eventName] = [];\n }\n this.handlers[eventName].push(handler);\n this.element.addEventListener(eventName, handler, false);\n }\n\n unbind(eventName, target) {\n this.handlers[eventName] = this.handlers[eventName].filter(handler => {\n if (target && handler !== target) {\n return true;\n }\n this.element.removeEventListener(eventName, handler, false);\n return false;\n });\n }\n\n unbindAll() {\n for (const name in this.handlers) {\n this.unbind(name);\n }\n }\n\n get isEmpty() {\n return Object.keys(this.handlers).every(\n key => this.handlers[key].length === 0\n );\n }\n}\n\nexport default class EventManager {\n constructor() {\n this.eventElements = [];\n }\n\n eventElement(element) {\n let ee = this.eventElements.filter(ee => ee.element === element)[0];\n if (!ee) {\n ee = new EventElement(element);\n this.eventElements.push(ee);\n }\n return ee;\n }\n\n bind(element, eventName, handler) {\n this.eventElement(element).bind(eventName, handler);\n }\n\n unbind(element, eventName, handler) {\n const ee = this.eventElement(element);\n ee.unbind(eventName, handler);\n\n if (ee.isEmpty) {\n // remov