mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 08:46:37 -04:00
Properly dispose of tooltip resources when unmounting
This commit is contained in:
parent
97692e4c28
commit
9a00ef5a81
1 changed files with 10 additions and 1 deletions
|
@ -3,19 +3,28 @@
|
|||
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||
-->
|
||||
<script lang="ts">
|
||||
import { onDestroy } from "svelte";
|
||||
import Tooltip from "bootstrap/js/dist/tooltip";
|
||||
|
||||
export let tooltip: string;
|
||||
|
||||
let tooltipObject: Tooltip;
|
||||
|
||||
function createTooltip(element: HTMLElement): void {
|
||||
element.title = tooltip;
|
||||
new Tooltip(element, {
|
||||
tooltipObject = new Tooltip(element, {
|
||||
placement: "bottom",
|
||||
html: true,
|
||||
offset: [0, 20],
|
||||
delay: { show: 250, hide: 0 },
|
||||
});
|
||||
}
|
||||
|
||||
onDestroy(() => {
|
||||
if (tooltipObject) {
|
||||
tooltipObject.dispose();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<slot {createTooltip} />
|
||||
|
|
Loading…
Reference in a new issue