mirror of
https://github.com/webrecorder/pywb.git
synced 2025-03-24 06:59:52 +01:00
vueui: made period hover-over tooltips better positioned so they never go outside screen
This commit is contained in:
parent
bea303d8f2
commit
337383eb45
@ -1,5 +1,19 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="timeline">
|
<div class="timeline">
|
||||||
|
<div class="period-tooltip" v-show="periodToShowInTooltip" :style="{left: periodToShowInTooltipPos.x+'px', top: periodToShowInTooltipPos.y+'px'}">
|
||||||
|
<template v-if="periodToShowInTooltip">
|
||||||
|
<div v-if="periodToShowInTooltip.snapshot">View capture from
|
||||||
|
{{ periodToShowInTooltip.snapshot.getTimeDateFormatted() }}
|
||||||
|
</div>
|
||||||
|
<div v-else-if="periodToShowInTooltip.snapshotPeriod">View capture from
|
||||||
|
{{ periodToShowInTooltip.snapshotPeriod.snapshot.getTimeDateFormatted() }}
|
||||||
|
</div>
|
||||||
|
<div v-else-if="periodToShowInTooltip.snapshotCount">
|
||||||
|
{{ periodToShowInTooltip.snapshotCount }} captures from
|
||||||
|
{{ periodToShowInTooltip.getFullReadableId() }}
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
<div v-html="'◀'" class="arrow previous" :class="{disabled: isScrollZero && !previousPeriod}" @click="scrollPrev" @dblclick.stop.prevent></div>
|
<div v-html="'◀'" class="arrow previous" :class="{disabled: isScrollZero && !previousPeriod}" @click="scrollPrev" @dblclick.stop.prevent></div>
|
||||||
<div class="scroll" ref="periodScroll" :class="{highlight: highlight}">
|
<div class="scroll" ref="periodScroll" :class="{highlight: highlight}">
|
||||||
<div class="periods" ref="periods">
|
<div class="periods" ref="periods">
|
||||||
@ -7,16 +21,20 @@
|
|||||||
:key="subPeriod.id"
|
:key="subPeriod.id"
|
||||||
class="period"
|
class="period"
|
||||||
:class="{empty: !subPeriod.snapshotCount, highlight: highlightPeriod === subPeriod, 'last-level': isLastZoomLevel}"
|
:class="{empty: !subPeriod.snapshotCount, highlight: highlightPeriod === subPeriod, 'last-level': isLastZoomLevel}"
|
||||||
v-on:click="changePeriod(subPeriod, $event)">
|
@click="changePeriod(subPeriod, $event)"
|
||||||
|
@mouseover="setPeriodToShowInTooltip(subPeriod, $event)"
|
||||||
|
@mouseout="setPeriodToShowInTooltip(null, $event)"
|
||||||
|
>
|
||||||
<div class="histo">
|
<div class="histo">
|
||||||
<div class="line"
|
<div class="line"
|
||||||
v-for="histoPeriod in subPeriod.children"
|
v-for="histoPeriod in subPeriod.children"
|
||||||
:key="histoPeriod.id"
|
:key="histoPeriod.id"
|
||||||
:style="{height: getHistoLineHeight(histoPeriod.snapshotCount)}"
|
:style="{height: getHistoLineHeight(histoPeriod.snapshotCount)}"
|
||||||
:class="{'has-single-snap': !!histoPeriod.snapshotPeriod}"
|
:class="{'has-single-snap': !!histoPeriod.snapshotPeriod}"
|
||||||
v-on:click="changePeriod(histoPeriod, $event)"
|
@click="changePeriod(histoPeriod, $event)"
|
||||||
|
@mouseover="setPeriodToShowInTooltip(histoPeriod, $event)"
|
||||||
|
@mouseout="setPeriodToShowInTooltip(null, $event)"
|
||||||
>
|
>
|
||||||
<div class="snap-info" v-if="histoPeriod.snapshot">View capture from {{histoPeriod.snapshot.getTimeDateFormatted()}}</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="inner">
|
<div class="inner">
|
||||||
@ -43,7 +61,9 @@ export default{
|
|||||||
previousPeriod: null,
|
previousPeriod: null,
|
||||||
nextPeriod: null,
|
nextPeriod: null,
|
||||||
isScrollZero: true,
|
isScrollZero: true,
|
||||||
isScrollMax: true
|
isScrollMax: true,
|
||||||
|
periodToShowInTooltip: null,
|
||||||
|
periodToShowInTooltipPos: {x:0,y:0}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
created: function() {
|
created: function() {
|
||||||
@ -153,6 +173,33 @@ export default{
|
|||||||
this.restoreScroll();
|
this.restoreScroll();
|
||||||
this.updateScrollArrows();
|
this.updateScrollArrows();
|
||||||
}).bind(this), 1);
|
}).bind(this), 1);
|
||||||
|
},
|
||||||
|
setPeriodToShowInTooltip(period, event) {
|
||||||
|
if (!period || !period.snapshotCount) {
|
||||||
|
this.periodToShowInTooltip = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.periodToShowInTooltip = period;
|
||||||
|
|
||||||
|
this.$nextTick(function() {
|
||||||
|
const tooltipContentsEl = document.querySelector('.period-tooltip div');
|
||||||
|
if (!tooltipContentsEl) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const periodTooltipStyle = window.getComputedStyle(tooltipContentsEl);
|
||||||
|
const tooltipWidth = parseInt(periodTooltipStyle.width);
|
||||||
|
const tooltipHeight = parseInt(periodTooltipStyle.height);
|
||||||
|
const spacing = 10;
|
||||||
|
if (window.innerWidth < event.x + (spacing*2) + tooltipWidth) {
|
||||||
|
this.periodToShowInTooltipPos.x = event.x - (tooltipWidth + spacing);
|
||||||
|
} else {
|
||||||
|
this.periodToShowInTooltipPos.x = event.x + spacing;
|
||||||
|
}
|
||||||
|
this.periodToShowInTooltipPos.y = event.y - (spacing + tooltipHeight);
|
||||||
|
});
|
||||||
|
event.stopPropagation();
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -331,19 +378,18 @@ export default{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Period that contains ONE snapshot only will show snapshot info*/
|
/* Period that contains ONE snapshot only will show snapshot info*/
|
||||||
.timeline .period .histo .line .snap-info {
|
.timeline .period-tooltip {
|
||||||
position: absolute;
|
position: fixed;
|
||||||
z-index: 10;
|
z-index: 100;
|
||||||
top: 30%;
|
/*left or right set programmatically*/
|
||||||
left: 120%;
|
display: block;
|
||||||
display: none;
|
|
||||||
background-color: white;
|
background-color: white;
|
||||||
border: 1px solid gray;
|
border: 1px solid gray;
|
||||||
padding: 2px;
|
padding: 2px;
|
||||||
white-space: nowrap; /*no wrapping allowed*/
|
white-space: nowrap; /*no wrapping allowed*/
|
||||||
}
|
}
|
||||||
/*show on hover*/
|
/*show on hover*/
|
||||||
.timeline .period .histo .line.has-single-snap:hover .snap-info {
|
.timeline .period-tooltip.show {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user