Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure that offset works correctly in contained FloatPanel #4711

Merged
merged 1 commit into from
Apr 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions examples/reference/layouts/FloatPanel.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
"* **`config`** (dict): Additional [jsPanel configuration](https://jspanel.de/#options/overview) with precedence over parameter values.\n",
"* **`objects`** (list): The list of objects to display in the Column, should not generally be modified directly except when replaced in its entirety.\n",
"* **`position`**: The initial position if the container is free-floating.\n",
"* **`offsetx`** (int): \"Horizontal offset in pixels.\n",
"* **`offsety`** (int): \"Vertical offset in pixels.\n",
"* **`offsetx`** (int): Horizontal offset in pixels.\n",
"* **`offsety`** (int): Vertical offset in pixels.\n",
"* **`theme`** (str): The theme can be one of:\n",
" - Built-ins: 'default', 'primary', 'secondary', 'info',\n",
" 'success', 'warning', 'danger', 'light', 'dark' and 'none'\n",
Expand Down Expand Up @@ -108,7 +108,7 @@
},
"outputs": [],
"source": [
"config={\"headerControls\": {\"close\": \"remove\"}}\n",
"config = {\"headerControls\": {\"close\": \"remove\"}}\n",
"\n",
"pn.Column(\n",
" \"Example: `FloatPanel` without *close button*\",\n",
Expand Down
13 changes: 10 additions & 3 deletions panel/layout/float.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,19 @@ class FloatPanel(ListLike, ReactiveHTML):
offsetY: data.offsety,
}
""",
"reposition": """
if (data.contained) {
view.run_script('contained')
return
}
state.panel.reposition(view.run_script('get_position'));
""",
"contained": "delete state.panel; view.invalidate_render();",
"theme": "state.panel.setTheme(data.theme)",
"remove": "view.run_script('close'); state.panel = undefined;",
"offsetx": "state.panel.reposition(view.run_script('get_position'))",
"offsety": "state.panel.reposition(view.run_script('get_position'))",
"position": "state.panel.reposition(view.run_script('get_position'))",
"offsetx": "view.run_script('reposition')",
"offsety": "view.run_script('reposition')",
"position": "if (!data.contained) { view.run_script('reposition') }",
}

__css_raw__ = [f"{pn_config.npm_cdn}/jspanel4@4.12.0/dist/jspanel.css"]
Expand Down