|
1 | 1 | "use strict";
|
2 | 2 |
|
3 | 3 | import "../css/tree_view.css";
|
| 4 | +import { throttle } from "./throttle.js"; |
4 | 5 |
|
5 | 6 | const downCaret = makeDownCaret();
|
6 | 7 | const rightCaret = makeRightCaret();
|
@@ -82,21 +83,34 @@ export class TreeView {
|
82 | 83 | li.appendChild(element);
|
83 | 84 | }
|
84 | 85 |
|
85 |
| - li.addEventListener("mouseover", (event) => { |
86 |
| - event.preventDefault(); |
87 |
| - event.stopPropagation(); |
88 |
| - |
89 |
| - li.classList.add("hover"); |
90 |
| - this.onmouseover(event, element, node); |
| 86 | + const onmouseover = throttle((event, element, data) => { |
| 87 | + this.onmouseover(event, element, data); |
91 | 88 | });
|
92 |
| - li.addEventListener("mouseout", (event) => { |
93 |
| - event.preventDefault(); |
94 |
| - event.stopPropagation(); |
95 |
| - |
96 |
| - li.classList.remove("hover"); |
97 |
| - this.onmouseout(event, element, node); |
| 89 | + const onmouseout = throttle((event, element, data) => { |
| 90 | + this.onmouseout(event, element, data); |
98 | 91 | });
|
99 | 92 |
|
| 93 | + li.addEventListener( |
| 94 | + "mouseover", |
| 95 | + (event) => { |
| 96 | + event.stopPropagation(); |
| 97 | + |
| 98 | + li.classList.add("hover"); |
| 99 | + onmouseover(event, element, node); |
| 100 | + }, |
| 101 | + { capture: false, once: false, passive: false } |
| 102 | + ); |
| 103 | + li.addEventListener( |
| 104 | + "mouseout", |
| 105 | + (event) => { |
| 106 | + event.stopPropagation(); |
| 107 | + |
| 108 | + li.classList.remove("hover"); |
| 109 | + onmouseout(event, element, node); |
| 110 | + }, |
| 111 | + { capture: false, once: false, passive: false } |
| 112 | + ); |
| 113 | + |
100 | 114 | ul.appendChild(li);
|
101 | 115 | return ul;
|
102 | 116 | }
|
|
0 commit comments