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AQ,GAAG,MAAM,CAAC,gBAAP,CAAwB,EAAxB,CAAjB;;AACA,UAAI,QAAQ,IAAI,QAAQ,CAAC,OAAT,KAAqB,QAArC,EAA+C;AAC7C,cAAM,OAAO,GAAI,IAAY,CAAC,SAAb,GAAyB,CAAE,IAAY,CAAC,SAAf,EAA0B,IAAI,CAAC,OAA/B,CAAzB,GAAmE,CAAC,IAAI,CAAC,iBAAN,CAApF;AACA,QAAA,WAAW,CAAC,mDAAD,EAAsD,GAAG,OAAzD,CAAX;AACD;AACF,KANe,CAAhB;AAOD;AACF;;AAED,SAAS,MAAT,CAAiB,EAAjB,EAAgC;AAC9B,SAAO,EAAE,CAAC,OAAV;AACA,EAAA,eAAe,CAAC,EAAD,CAAf;AACD;;AAED,SAAS,MAAT,CAAiB,EAAjB,EAAkC,OAAlC,EAAyD;AACvD,MAAI,OAAO,CAAC,KAAR,KAAkB,OAAO,CAAC,QAA9B,EAAwC;AACtC;AACD;;AAED,QAAM,UAAU,GAAG,eAAe,CAAC,OAAO,CAAC,QAAT,CAAlC;AACA,EAAA,YAAY,CAAC,EAAD,EAAK,OAAL,EAAc,UAAd,CAAZ;AACD;;AAED,OAAO,MAAM,MAAM,GAAG;AACpB,EAAA,IAAI,EAAE,SADc;AAEpB,EAAA,MAFoB;AAGpB,EAAA;AAHoB,CAAf;AAMP,eAAe,MAAf","sourcesContent":["// Styles\nimport './VRipple.sass'\n\nimport { 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 ripples = {\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 element._ripple.isTouch = true\n } else {\n // It's possible for touch events to fire\n // as mouse events on Android/iOS, this\n // will skip the event call if it has\n // already been registered as touch\n if (element._ripple.isTouch) return\n }\n value.center = element._ripple.centered\n if (element._ripple.class) {\n value.class = element._ripple.class\n }\n ripples.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 ripples.hide(element)\n}\n\nfunction updateRipple (el: HTMLElement, binding: VNodeDirective, wasEnabled: boolean) {\n const enabled = isRippleEnabled(binding.value)\n if (!enabled) {\n ripples.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 if (process.env.NODE_ENV === 'development') {\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}\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 const Ripple = {\n bind: directive,\n unbind,\n update,\n}\n\nexport default Ripple\n"],"sourceRoot":"","file":"index.js"} |