-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
5909db6
commit e49b427
Showing
19 changed files
with
520 additions
and
219 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
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
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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<template> | ||
<transition name="tooltip"> | ||
<div | ||
v-show="show" | ||
class="house-tooltip-wrap" | ||
:style="{ | ||
left: x + 'px', | ||
top: y + 'px', | ||
}" | ||
> | ||
<slot v-bind="house" /> | ||
</div> | ||
</transition> | ||
</template> | ||
|
||
<script> | ||
/** | ||
* 房屋tooltip | ||
*/ | ||
export default { | ||
name: "HouseTooltip", | ||
data() { | ||
return { | ||
house: {}, | ||
show: false, | ||
x: 0, | ||
y: 0, | ||
}; | ||
}, | ||
created() { | ||
this.$parent.$on("house-over", this.handleHouseOver); | ||
this.$parent.$on("house-out", this.handleHouseOut); | ||
}, | ||
beforeDestroy() { | ||
this.$parent.$off("house-over", this.handleHouseOver); | ||
this.$parent.$off("house-out", this.handleHouseOut); | ||
}, | ||
methods: { | ||
handleHouseOver({ house, event }) { | ||
const rect = this.$parent.$el.getBoundingClientRect(); | ||
this.x = event.clientX - rect.left + 8; | ||
this.y = event.clientY - rect.top + 8; | ||
this.house = house; | ||
this.show = true; | ||
this.$nextTick(() => this.adjustEdge()); | ||
}, | ||
handleHouseOut() { | ||
this.show = false; | ||
}, | ||
// 如果tooltip超出视图范围,调整边界 | ||
adjustEdge() { | ||
const houseWrap = this.$parent.$el.querySelector(".house-display-wrap"); | ||
const { width, height } = houseWrap.getBoundingClientRect(); | ||
const { clientWidth, clientHeight } = this.$el; | ||
if (this.x + clientWidth > width - 10) { | ||
this.x = this.x - clientWidth - 8; | ||
} | ||
if (this.y + clientHeight > height - 10) { | ||
this.y = this.y - clientHeight - 8; | ||
} | ||
}, | ||
}, | ||
}; | ||
</script> |
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
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
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
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 |
---|---|---|
|
@@ -7,4 +7,5 @@ | |
@import "./unit.scss"; | ||
@import "./house.scss"; | ||
@import "./legend.scss"; | ||
@import "./tooltip.scss"; | ||
|
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 |
---|---|---|
@@ -1,4 +1,7 @@ | ||
.building-table-wrap { | ||
position: relative; | ||
overflow: visible; | ||
|
||
.building-table__content { | ||
position: relative; | ||
|
||
|
Oops, something went wrong.