@bagelink/vue 0.0.927 → 0.0.929

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bagelink/vue",
3
3
  "type": "module",
4
- "version": "0.0.927",
4
+ "version": "0.0.929",
5
5
  "description": "Bagel core sdk packages",
6
6
  "author": {
7
7
  "name": "Neveh Allon",
@@ -27,6 +27,7 @@ const is = $computed(() => (props.to ? 'router-link' : 'div'))
27
27
  <template>
28
28
  <component
29
29
  :is="is"
30
+ v-ripple="!!to"
30
31
  :to="to"
31
32
  class="bgl_card"
32
33
  :class="{
@@ -1,12 +1,7 @@
1
- import type { Directive } from 'vue'
2
-
3
- const ripple: Directive<HTMLElement> = {
4
- mounted(el: HTMLElement) {
5
- if (getComputedStyle(el).position === 'static') {
6
- el.style.position = 'relative'
7
- }
8
- el.style.overflow = 'hidden'
1
+ import type { Directive, DirectiveBinding } from 'vue'
9
2
 
3
+ const ripple: Directive<HTMLElement, boolean> = {
4
+ mounted(el: HTMLElement, binding: DirectiveBinding<boolean>) {
10
5
  const clickHandler = (e: MouseEvent) => {
11
6
  const rect = el.getBoundingClientRect()
12
7
  const size = Math.max(rect.width, rect.height)
@@ -27,11 +22,30 @@ const ripple: Directive<HTMLElement> = {
27
22
  })
28
23
 
29
24
  el.appendChild(ripple)
30
- // setTimeout(() => { ripple.remove() }, 600)
25
+ setTimeout(() => { ripple.remove() }, 600)
31
26
  };
32
27
 
33
28
  (el as any).__rippleClickHandler = clickHandler
34
- el.addEventListener('mousedown', clickHandler)
29
+
30
+ if (binding.value !== false) {
31
+ if (getComputedStyle(el).position === 'static') {
32
+ el.style.position = 'relative'
33
+ }
34
+ el.style.overflow = 'hidden'
35
+ el.addEventListener('mousedown', clickHandler)
36
+ }
37
+ },
38
+ updated(el: HTMLElement, binding: DirectiveBinding<boolean>) {
39
+ const clickHandler = (el as any).__rippleClickHandler
40
+ if (binding.value === false) {
41
+ el.removeEventListener('mousedown', clickHandler)
42
+ } else {
43
+ if (getComputedStyle(el).position === 'static') {
44
+ el.style.position = 'relative'
45
+ }
46
+ el.style.overflow = 'hidden'
47
+ el.addEventListener('mousedown', clickHandler)
48
+ }
35
49
  },
36
50
  unmounted(el: HTMLElement) {
37
51
  const clickHandler = (el as any).__rippleClickHandler