-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
.compute()
and types Float
& FloatingUI
- Loading branch information
Showing
4 changed files
with
68 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import { floatingUI } from './floating-ui.svelte.js' | ||
|
||
import { default as floatingUI } from './floating-ui.svelte.js' | ||
export * from './floating-ui.svelte.js' | ||
|
||
export default floatingUI | ||
|
||
export * from './portal.svelte.js' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
let map = new WeakMap<Node, ReturnType<typeof wait>>() | ||
|
||
export const wait = (ms: number) => { | ||
let anchor: Node | undefined | ||
try { | ||
anchor = eval('node') | ||
} catch (error) { | ||
console.error(error) | ||
} | ||
|
||
console.log(anchor) | ||
|
||
if(anchor) { | ||
let wait = map.get(anchor) | ||
if(wait) { | ||
return wait | ||
} | ||
} | ||
|
||
var awaited = $state(false) | ||
let cancelled = $state(false) | ||
let timeoutId: ReturnType<typeof setTimeout> | null = null | ||
|
||
const wait = { | ||
get awaited() { | ||
return awaited | ||
}, | ||
get cancelled() { return cancelled }, | ||
cancel: () => { | ||
cancelled = true | ||
if (timeoutId) { | ||
clearTimeout(timeoutId) | ||
} | ||
}, | ||
promise: new Promise(res => { | ||
timeoutId = setTimeout(() => { | ||
if (cancelled) return | ||
res(true) | ||
console.log('true') | ||
awaited = true | ||
}, ms) | ||
}) | ||
} | ||
|
||
if(anchor) { | ||
map.set(anchor, wait) | ||
} | ||
return wait | ||
} |