-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
41 additions
and
84 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,13 +6,18 @@ | |
# This software is published at https://github.com/anvilistas/anvil-extras | ||
|
||
from anvil.js import import_from | ||
from anvil.js.window import window | ||
from anvil.js.window import window as _W | ||
|
||
# https://floating-ui.com/ | ||
# can't import from cdn, load js file in assets and import from there | ||
__version__ = "2.7.1" | ||
|
||
fui = import_from("https://cdn.jsdelivr.net/npm/@floating-ui/[email protected]/+esm") | ||
try: | ||
# support preloaded FloatingUIDOM | ||
FloatingUIDOM = _W.FloatingUIDOM | ||
except AttributeError: | ||
# https://floating-ui.com/ | ||
FloatingUIDOM = import_from( | ||
"https://cdn.jsdelivr.net/npm/@floating-ui/[email protected]/+esm" | ||
) | ||
|
||
_static_arrow_position = { | ||
"top": "bottom", | ||
|
@@ -50,17 +55,17 @@ def auto_update( | |
|
||
def update(*args): | ||
middleware = [ | ||
fui.offset(offset), | ||
fui.flip(), | ||
fui.shift(shift), | ||
fui.hide(hide), | ||
fui.size(size_middleware()), | ||
FloatingUIDOM.offset(offset), | ||
FloatingUIDOM.flip(), | ||
FloatingUIDOM.shift(shift), | ||
FloatingUIDOM.hide(hide), | ||
FloatingUIDOM.size(size_middleware()), | ||
] | ||
|
||
if arrow: | ||
middleware.append(fui.arrow({"element": arrow})) | ||
middleware.append(FloatingUIDOM.arrow({"element": arrow})) | ||
|
||
rv = fui.computePosition( | ||
rv = FloatingUIDOM.computePosition( | ||
reference_el, | ||
floating_el, | ||
{ | ||
|
@@ -95,4 +100,4 @@ def update(*args): | |
floating_el.classList.remove("left", "right", "top", "bottom") | ||
floating_el.classList.add(main_axis) | ||
|
||
return fui.autoUpdate(reference_el, floating_el, update) | ||
return FloatingUIDOM.autoUpdate(reference_el, floating_el, update) |
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