{"version":3,"file":"v-ripple.mjs","sources":["../../../../../../packages/directives/ripple/src/v-ripple.ts"],"sourcesContent":["import { createContainer } from './utils/create-container-element'\nimport { createrippleElement } from './utils/create-ripple-element'\nimport { getDistanceToFurthestCorner } from './utils/getdistance-tofurthestcorner'\nimport { getRelativePointer } from './utils/getrelative-pointer'\nimport {\n  decrementRippleCount,\n  deleteRippleCount,\n  getRippleCount,\n  incrementRippleCount,\n} from './utils/ripple-count'\nimport type { IRippleDirectiveOptions } from './options'\nconst MULTIPLE_NUMBER = 2.05\nconst ripple = (\n  event: PointerEvent,\n  el: HTMLElement,\n  options: IRippleDirectiveOptions\n): void => {\n  const rect = el.getBoundingClientRect()\n  const computedStyles = window.getComputedStyle(el)\n  const { x, y } = getRelativePointer(event, rect)\n  const size =\n    MULTIPLE_NUMBER * getDistanceToFurthestCorner(Number(x), Number(y), rect)\n\n  const rippleContainer = createContainer(computedStyles)\n  const rippleEl = createrippleElement(Number(x), Number(y), size, options)\n  let originalPositionValue = ''\n  let shouldDissolveripple = false\n  let token: any = null\n  function dissolveripple() {\n    rippleEl.style.transition = 'opacity 150ms linear'\n    rippleEl.style.opacity = '0'\n\n    setTimeout(() => {\n      rippleContainer.remove()\n\n      decrementRippleCount(el)\n\n      if (getRippleCount(el) === 0) {\n        deleteRippleCount(el)\n        el.style.position = originalPositionValue\n      }\n    }, 150)\n  }\n  function releaseripple(e?: PointerEvent) {\n    if (typeof e !== 'undefined') {\n      document.removeEventListener('pointerup', releaseripple)\n      document.removeEventListener('pointercancel', releaseripple)\n    }\n\n    if (shouldDissolveripple) {\n      dissolveripple()\n    } else {\n      shouldDissolveripple = true\n    }\n  }\n\n  function cancelripple() {\n    clearTimeout(token)\n\n    rippleContainer.remove()\n    document.removeEventListener('pointerup', releaseripple)\n    document.removeEventListener('pointercancel', releaseripple)\n    document.removeEventListener('pointercancel', cancelripple)\n  }\n\n  incrementRippleCount(el)\n\n  if (computedStyles.position === 'static') {\n    if (el.style.position) {\n      originalPositionValue = el.style.position\n    }\n    el.style.position = 'relative'\n  }\n\n  rippleContainer.appendChild(rippleEl)\n  el.appendChild(rippleContainer)\n\n  document.addEventListener('pointerup', releaseripple)\n  document.addEventListener('pointercancel', releaseripple)\n\n  token = setTimeout(() => {\n    document.removeEventListener('pointercancel', cancelripple)\n\n    requestAnimationFrame(() => {\n      rippleEl.style.transform = `translate(-50%,-50%) scale(1)`\n      rippleEl.style.opacity = `${options.finalOpacity}`\n\n      setTimeout(() => releaseripple(), options.duration)\n    })\n  }, options.delay)\n  document.addEventListener('pointercancel', cancelripple)\n}\n\nexport { ripple }\n"],"names":[],"mappings":";;;;;;AAUA,MAAM,eAAe,GAAG,IAAI,CAAC;AACxB,MAAC,MAAM,GAAG,CAAC,KAAK,EAAE,EAAE,EAAE,OAAO,KAAK;AACvC,EAAE,MAAM,IAAI,GAAG,EAAE,CAAC,qBAAqB,EAAE,CAAC;AAC1C,EAAE,MAAM,cAAc,GAAG,MAAM,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC;AACrD,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,kBAAkB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AACnD,EAAE,MAAM,IAAI,GAAG,eAAe,GAAG,2BAA2B,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;AACzF,EAAE,MAAM,eAAe,GAAG,eAAe,CAAC,cAAc,CAAC,CAAC;AAC1D,EAAE,MAAM,QAAQ,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;AAC5E,EAAE,IAAI,qBAAqB,GAAG,EAAE,CAAC;AACjC,EAAE,IAAI,oBAAoB,GAAG,KAAK,CAAC;AACnC,EAAE,IAAI,KAAK,GAAG,IAAI,CAAC;AACnB,EAAE,SAAS,cAAc,GAAG;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