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,iBAAa,EAAb,EAAiB,OAAjB,EAA0B,UAA1B;AACD;kBAEc;AACb,UAAM,SADO;AAEb,kBAFa;AAGb;AAHa,C","sourcesContent":["import { VNode, VNodeDirective } from 'vue'\nimport { consoleWarn } from '../util/console'\n\nfunction transform (el: HTMLElement, value: string) {\n el.style['transform'] = value\n el.style['webkitTransform'] = value\n}\n\nfunction opacity (el: HTMLElement, value: number) {\n el.style['opacity'] = value.toString()\n}\n\nexport interface RippleOptions {\n class?: string\n center?: boolean\n circle?: boolean\n}\n\nfunction isTouchEvent (e: MouseEvent | TouchEvent): e is TouchEvent {\n return e.constructor.name === 'TouchEvent'\n}\n\nconst calculate = (e: MouseEvent | TouchEvent, el: HTMLElement, value: RippleOptions = {}) => {\n const offset = el.getBoundingClientRect()\n const target = isTouchEvent(e) ? e.touches[e.touches.length - 1] : e\n const localX = target.clientX - offset.left\n const localY = target.clientY - offset.top\n\n let radius = 0\n let scale = 0.3\n if (el._ripple && el._ripple.circle) {\n scale = 0.15\n radius = el.clientWidth / 2\n radius = value.center ? radius : radius + Math.sqrt((localX - radius) ** 2 + (localY - radius) ** 2) / 4\n } else {\n radius = Math.sqrt(el.clientWidth ** 2 + el.clientHeight ** 2) / 2\n }\n\n const centerX = `${(el.clientWidth - (radius * 2)) / 2}px`\n const centerY = `${(el.clientHeight - (radius * 2)) / 2}px`\n\n const x = value.center ? centerX : `${localX - radius}px`\n const y = value.center ? centerY : `${localY - radius}px`\n\n return { radius, scale, x, y, centerX, centerY }\n}\n\nconst ripple = {\n /* eslint-disable max-statements */\n show (e: MouseEvent | TouchEvent, el: HTMLElement, value: RippleOptions = {}) {\n if (!el._ripple || !el._ripple.enabled) {\n return\n }\n\n const container = document.createElement('span')\n const animation = document.createElement('span')\n\n container.appendChild(animation)\n container.className = 'v-ripple__container'\n\n if (value.class) {\n container.className += ` ${value.class}`\n }\n\n const { radius, scale, x, y, centerX, centerY } = calculate(e, el, value)\n\n const size = `${radius * 2}px`\n animation.className = 'v-ripple__animation'\n animation.style.width = size\n animation.style.height = size\n\n el.appendChild(container)\n\n const computed = window.getComputedStyle(el)\n if (computed && computed.position === 'static') {\n el.style.position = 'relative'\n el.dataset.previousPosition = 'static'\n }\n\n animation.classList.add('v-ripple__animation--enter')\n animation.classList.add('v-ripple__animation--visible')\n transform(animation, `translate(${x}, ${y}) scale3d(${scale},${scale},${scale})`)\n opacity(animation, 0)\n animation.dataset.activated = String(performance.now())\n\n setTimeout(() => {\n animation.classList.remove('v-ripple__animation--enter')\n animation.classList.add('v-ripple__animation--in')\n transform(animation, `translate(${centerX}, ${centerY}) scale3d(1,1,1)`)\n opacity(animation, 0.25)\n }, 0)\n },\n\n hide (el: HTMLElement | null) {\n if (!el || !el._ripple || !el._ripple.enabled) return\n\n const ripples = el.getElementsByClassName('v-ripple__animation')\n\n if (ripples.length === 0) return\n const animation = ripples[ripples.length - 1]\n\n if (animation.dataset.isHiding) return\n else animation.dataset.isHiding = 'true'\n\n const diff = performance.now() - Number(animation.dataset.activated)\n const delay = Math.max(250 - diff, 0)\n\n setTimeout(() => {\n animation.classList.remove('v-ripple__animation--in')\n animation.classList.add('v-ripple__animation--out')\n opacity(animation, 0)\n\n setTimeout(() => {\n const ripples = el.getElementsByClassName('v-ripple__animation')\n if (ripples.length === 1 && el.dataset.previousPosition) {\n el.style.position = el.dataset.previousPosition\n delete el.dataset.previousPosition\n }\n\n animation.parentNode && el.removeChild(animation.parentNode)\n }, 300)\n }, delay)\n }\n}\n\nfunction isRippleEnabled (value: any): value is true {\n return typeof value === 'undefined' || !!value\n}\n\nfunction rippleShow (e: MouseEvent | TouchEvent) {\n const value: RippleOptions = {}\n const element = e.currentTarget as HTMLElement\n if (!element || !element._ripple || element._ripple.touched) return\n if (isTouchEvent(e)) {\n element._ripple.touched = true\n }\n value.center = element._ripple.centered\n if (element._ripple.class) {\n value.class = element._ripple.class\n }\n ripple.show(e, element, value)\n}\n\nfunction rippleHide (e: Event) {\n const element = e.currentTarget as HTMLElement | null\n if (!element) return\n\n window.setTimeout(() => {\n if (element._ripple) {\n element._ripple.touched = false\n }\n })\n ripple.hide(element)\n}\n\nfunction updateRipple (el: HTMLElement, binding: VNodeDirective, wasEnabled: boolean) {\n const enabled = isRippleEnabled(binding.value)\n if (!enabled) {\n ripple.hide(el)\n }\n el._ripple = el._ripple || {}\n el._ripple.enabled = enabled\n const value = binding.value || {}\n if (value.center) {\n el._ripple.centered = true\n }\n if (value.class) {\n el._ripple.class = binding.value.class\n }\n if (value.circle) {\n el._ripple.circle = value.circle\n }\n if (enabled && !wasEnabled) {\n el.addEventListener('touchstart', rippleShow, { passive: true })\n el.addEventListener('touchend', rippleHide, { passive: true })\n el.addEventListener('touchcancel', rippleHide)\n\n el.addEventListener('mousedown', rippleShow)\n el.addEventListener('mouseup', rippleHide)\n el.addEventListener('mouseleave', rippleHide)\n // Anchor tags can be dragged, causes other hides to fail - #1537\n el.addEventListener('dragstart', rippleHide, { passive: true })\n } else if (!enabled && wasEnabled) {\n removeListeners(el)\n }\n}\n\nfunction removeListeners (el: HTMLElement) {\n el.removeEventListener('mousedown', rippleShow)\n el.removeEventListener('touchstart', rippleHide)\n el.removeEventListener('touchend', rippleHide)\n el.removeEventListener('touchcancel', rippleHide)\n el.removeEventListener('mouseup', rippleHide)\n el.removeEventListener('mouseleave', rippleHide)\n el.removeEventListener('dragstart', rippleHide)\n}\n\nfunction directive (el: HTMLElement, binding: VNodeDirective, node: VNode) {\n updateRipple(el, binding, false)\n\n // warn if an inline element is used, waiting for el to be in the DOM first\n node.context && node.context.$nextTick(() => {\n const computed = window.getComputedStyle(el)\n if (computed && computed.display === 'inline') {\n const context = (node as any).fnOptions ? [(node as any).fnOptions, node.context] : [node.componentInstance]\n consoleWarn('v-ripple can only be used on block-level elements', ...context)\n }\n })\n}\n\nfunction unbind (el: HTMLElement) {\n delete el._ripple\n removeListeners(el)\n}\n\nfunction update (el: HTMLElement, binding: VNodeDirective) {\n if (binding.value === binding.oldValue) {\n return\n }\n\n const wasEnabled = isRippleEnabled(binding.oldValue)\n updateRipple(el, binding, wasEnabled)\n}\n\nexport default {\n bind: directive,\n unbind,\n update\n}\n"],"sourceRoot":""}