mirror of
https://github.com/Hopiu/vue-material.git
synced 2026-04-25 00:54:53 +00:00
Fix parent detection on tooltips
This commit is contained in:
parent
a41291ddaf
commit
bea0da29f5
5 changed files with 13 additions and 12 deletions
|
|
@ -12,6 +12,7 @@ $tooltip-height: 20px;
|
|||
opacity: 0;
|
||||
transform-origin: center top;
|
||||
transition: $swift-ease-out;
|
||||
transition-duration: .3s;
|
||||
transition-delay: 0s;
|
||||
color: #fff;
|
||||
font-family: $font-roboto;
|
||||
|
|
@ -23,6 +24,7 @@ $tooltip-height: 20px;
|
|||
&.md-active {
|
||||
opacity: 1;
|
||||
transition: $swift-ease-in;
|
||||
transition-duration: .3s;
|
||||
}
|
||||
|
||||
&.md-tooltip-top {
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
let targetElement;
|
||||
|
||||
let calculateTooltipPosition = (scope) => {
|
||||
let position = scope.$parent.$el.getBoundingClientRect();
|
||||
let position = scope.targetElement.getBoundingClientRect();
|
||||
|
||||
switch (scope.mdDirection) {
|
||||
case 'top':
|
||||
|
|
@ -85,6 +85,8 @@
|
|||
let tooltipElement = this.$el;
|
||||
let targetElement = tooltipElement.parentNode;
|
||||
|
||||
this.targetElement = targetElement;
|
||||
|
||||
onMouseEnter = () => {
|
||||
document.body.appendChild(tooltipElement);
|
||||
calculateTooltipPosition(this);
|
||||
|
|
@ -105,6 +107,14 @@
|
|||
tooltipElement.addEventListener('transitionend', onTransitionEnd);
|
||||
};
|
||||
|
||||
if (this.$parent.$el.classList === targetElement.classList) {
|
||||
targetElement.classList.forEach((cssClass) => {
|
||||
if (cssClass.indexOf('md-') >= 0 && cssClass !== 'md-active') {
|
||||
tooltipElement.classList.add(cssClass + '-tooltip');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
this.$el.parentNode.removeChild(this.$el);
|
||||
|
||||
targetElement.addEventListener('mouseenter', onMouseEnter);
|
||||
|
|
|
|||
|
|
@ -17,11 +17,3 @@
|
|||
</md-avatar>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
ready() {
|
||||
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -25,8 +25,6 @@
|
|||
<div v-md-theme="'teal'">
|
||||
<md-checkbox id="my-test5" name="my-test5" v-model="checkbox" disabled>Disabled</md-checkbox>
|
||||
</div>
|
||||
|
||||
<span>{{ checkbox }}</span>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
|
|
|
|||
|
|
@ -67,6 +67,5 @@
|
|||
.md-button,
|
||||
.md-avatar {
|
||||
margin: 24px;
|
||||
overflow: visible;
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
Loading…
Reference in a new issue