Fixed #942 - Custom target for OverlayPane

pull/1391/head
Cagatay Civici 2021-07-27 11:00:47 +03:00
parent 01b5c0f59c
commit ab17ffa622
2 changed files with 10 additions and 7 deletions

View File

@ -58,6 +58,7 @@ export default {
}, },
selfClick: false, selfClick: false,
target: null, target: null,
eventTarget: null,
outsideClickListener: null, outsideClickListener: null,
scrollHandler: null, scrollHandler: null,
resizeListener: null, resizeListener: null,
@ -94,15 +95,16 @@ export default {
} }
}, },
methods: { methods: {
toggle(event) { toggle(event, target) {
if (this.visible) if (this.visible)
this.hide(); this.hide();
else else
this.show(event); this.show(event, target);
}, },
show(event) { show(event, target) {
this.visible = true; this.visible = true;
this.target = event.currentTarget; this.eventTarget = event.currentTarget;
this.target = target || event.currentTarget;
}, },
hide() { hide() {
this.visible = false; this.visible = false;
@ -211,7 +213,7 @@ export default {
} }
}, },
isTargetClicked(event) { isTargetClicked(event) {
return this.target && (this.target === event.target || this.target.contains(event.target)); return (this.eventTarget && (this.eventTarget === event.target || this.eventTarget.contains(event.target)));
}, },
containerRef(el) { containerRef(el) {
this.container = el; this.container = el;

View File

@ -116,13 +116,14 @@ toggle(event) {
<tbody> <tbody>
<tr> <tr>
<td>toggle</td> <td>toggle</td>
<td>event: Browser event</td> <td>event: Browser event <br />
target: Optional target if event.currentTarget should not be used</td>
<td>Toggles the visibility of the overlay.</td> <td>Toggles the visibility of the overlay.</td>
</tr> </tr>
<tr> <tr>
<td>show</td> <td>show</td>
<td>event: Browser event <br /> <td>event: Browser event <br />
target: Optional target if event.target should not be used</td> target: Optional target if event.currentTarget should not be used</td>
<td>Shows the overlay.</td> <td>Shows the overlay.</td>
</tr> </tr>
<tr> <tr>