@dataloop-ai/components 0.16.39 → 0.16.41

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@dataloop-ai/components",
3
- "version": "0.16.39",
3
+ "version": "0.16.41",
4
4
  "exports": {
5
5
  ".": "./index.ts",
6
6
  "./models": "./models.ts",
@@ -347,7 +347,7 @@ export default defineComponent({
347
347
  }
348
348
 
349
349
  .dl-button-icon {
350
- margin: var(--dl-button-icon-margin, '0px 7px 0px 0px');
350
+ margin: var(--dl-button-icon-margin, 0px 7px 0px 0px);
351
351
  }
352
352
 
353
353
  .dl-button-container {
@@ -268,9 +268,12 @@ export default defineComponent({
268
268
  })
269
269
  }
270
270
 
271
- registerTick(() => {
272
- updatePosition()
273
- })
271
+ registerTick(
272
+ () => {
273
+ updatePosition()
274
+ },
275
+ { continuous: true }
276
+ )
274
277
 
275
278
  registerTimeout(() => {
276
279
  // required in order to avoid the "double-tap needed" issue
@@ -357,7 +360,7 @@ export default defineComponent({
357
360
  })
358
361
  }
359
362
 
360
- async function updatePosition() {
363
+ const updatePosition = async () => {
361
364
  const el = innerRef.value
362
365
 
363
366
  if (el === null || anchorEl.value === null) {
@@ -367,6 +370,7 @@ export default defineComponent({
367
370
  const isAnchorElVisible = await CheckAnchorElVisiblity(
368
371
  anchorEl.value
369
372
  )
373
+
370
374
  if (!isAnchorElVisible) {
371
375
  hide()
372
376
  return
@@ -1,32 +1,52 @@
1
1
  import { nextTick, onBeforeUnmount } from 'vue-demi'
2
2
 
3
- /*
4
- * Usage:
5
- * registerTick(fn)
6
- * registerTick(fn)
3
+ /**
4
+ * @description a tick hook that allows you to register a function to be called on the next tick or on the next animation frame.
5
+ * @returns {Object} registerTick, removeTick
7
6
  */
8
-
9
7
  export default function () {
10
- let tickFn: Function | undefined
8
+ let tickFn: Function | null = null
9
+ let animationFrameId: number | null = null
11
10
 
12
11
  onBeforeUnmount(() => {
13
- tickFn = void 0
12
+ removeTick()
14
13
  })
15
14
 
16
- return {
17
- registerTick(fn: Function) {
18
- tickFn = fn
15
+ const registerTick = (
16
+ fn: Function,
17
+ options: { continuous?: boolean } = {}
18
+ ) => {
19
+ tickFn = fn
20
+
21
+ const { continuous } = options
19
22
 
23
+ if (continuous) {
24
+ animationFrameId = requestAnimationFrame(() => {
25
+ if (tickFn === fn) {
26
+ tickFn()
27
+ registerTick(fn, { continuous })
28
+ }
29
+ })
30
+ } else {
20
31
  nextTick(() => {
21
32
  if (tickFn === fn) {
22
33
  tickFn()
23
- tickFn = void 0
34
+ tickFn = null
24
35
  }
25
36
  })
26
- },
37
+ }
38
+ }
27
39
 
28
- removeTick() {
29
- tickFn = void 0
40
+ const removeTick = () => {
41
+ tickFn = null
42
+ if (animationFrameId) {
43
+ cancelAnimationFrame(animationFrameId)
30
44
  }
45
+ animationFrameId = null
46
+ }
47
+
48
+ return {
49
+ registerTick,
50
+ removeTick
31
51
  }
32
52
  }