feat(hide-columns): better positioning of hiders
This commit is contained in:
parent
e655bc6e70
commit
761c6d39a8
@ -79,27 +79,14 @@ export class HideColumns {
|
|||||||
}
|
}
|
||||||
|
|
||||||
hideHiderBehindHeader(hider) {
|
hideHiderBehindHeader(hider) {
|
||||||
const th = this.hiderToHeader.get(hider);
|
|
||||||
// move hider right before table (inside any scrolltable element)
|
// move hider right before table (inside any scrolltable element)
|
||||||
this._tableHiderContainer.appendChild(hider);
|
this._tableHiderContainer.appendChild(hider);
|
||||||
// reposition hider
|
// reposition hider
|
||||||
const posTH = th.getBoundingClientRect();
|
const thR = this.hiderToHeader.get(hider).getBoundingClientRect();
|
||||||
const posH = hider.getBoundingClientRect();
|
const hR = hider.getBoundingClientRect();
|
||||||
// TODO move to aux function
|
const pR = this._tableHiderContainer.getBoundingClientRect();
|
||||||
let p = {
|
hider.style.left = (thR.left + thR.width/2 - hR.width/2 - pR.left) + 'px';
|
||||||
top: posTH.top,
|
hider.style.top = (thR.top - pR.top + 5) + 'px';
|
||||||
left: posTH.left,
|
|
||||||
width: th.offsetWidth || 0,
|
|
||||||
height: th.offsetHeight || 0,
|
|
||||||
};
|
|
||||||
const hiderCompStyle = window.getComputedStyle(hider);
|
|
||||||
const x = parseInt(hiderCompStyle.marginLeft) + parseInt(hiderCompStyle.marginRight);
|
|
||||||
const y = parseInt(hiderCompStyle.marginTop) + parseInt(hiderCompStyle.marginBottom);
|
|
||||||
const posHParent = hider.parentElement.getBoundingClientRect();
|
|
||||||
p.top += -posHParent.top + hider.parentElement.scrollTop + hider.parentElement.offsetTop;
|
|
||||||
p.left += -posHParent.left - hider.parentElement.scrollLeft + hider.parentElement.offsetLeft;
|
|
||||||
hider.style.left = (p.left + (p.width/2) - (posH.width/2 + x)) + 'px';
|
|
||||||
hider.style.top = (p.top - (hider.offsetHeight + y)) + 'px';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setupHideButton(th, prevHidden) {
|
setupHideButton(th, prevHidden) {
|
||||||
|
|||||||
@ -1,8 +1,6 @@
|
|||||||
[table-utils] {
|
.table-hiders {
|
||||||
margin-bottom: 20px;
|
position: relative;
|
||||||
line-height: 1.4;
|
max-height: 0px;
|
||||||
max-width: 85vw;
|
|
||||||
}
|
|
||||||
|
|
||||||
.table-hider {
|
.table-hider {
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
@ -10,13 +8,18 @@
|
|||||||
padding: 10px;
|
padding: 10px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
box-shadow: 0 0 2px 0 rgba(0,0,0,0.6);
|
box-shadow: 0 0 2px 0 rgba(0,0,0,0.6);
|
||||||
margin: 10px 10px 0 0;
|
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
|
||||||
.table-hider__label {
|
.table-hider__label {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[table-utils] {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
line-height: 1.4;
|
||||||
|
max-width: 85vw;
|
||||||
|
|
||||||
.table-pill {
|
.table-pill {
|
||||||
background-color: var(--color-dark);
|
background-color: var(--color-dark);
|
||||||
@ -40,6 +43,7 @@
|
|||||||
/* animation: fadeout 0.5s linear forwards; */
|
/* animation: fadeout 0.5s linear forwards; */
|
||||||
/* animation-delay: 2s; */
|
/* animation-delay: 2s; */
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.hide-columns--hidden-cell {
|
.hide-columns--hidden-cell {
|
||||||
display: none;
|
display: none;
|
||||||
|
|||||||
Reference in New Issue
Block a user