mirror of
https://github.com/EDCD/coriolis.git
synced 2025-12-09 14:45:35 +00:00
Facet drag improvements
This commit is contained in:
@@ -219,9 +219,10 @@ export default class ComparisonPage extends Page {
|
|||||||
* @param {Event} e Drag Event
|
* @param {Event} e Drag Event
|
||||||
*/
|
*/
|
||||||
_facetDrag(e) {
|
_facetDrag(e) {
|
||||||
|
this.nodeAfter = false;
|
||||||
this.dragged = e.currentTarget;
|
this.dragged = e.currentTarget;
|
||||||
let placeholder = this.placeholder = document.createElement('li');
|
let placeholder = this.placeholder = document.createElement('li');
|
||||||
placeholder.style.width = this.dragged.offsetWidth + 'px';
|
placeholder.style.width = Math.round(this.dragged.offsetWidth) + 'px';
|
||||||
placeholder.className = 'facet-placeholder';
|
placeholder.className = 'facet-placeholder';
|
||||||
e.dataTransfer.effectAllowed = 'move';
|
e.dataTransfer.effectAllowed = 'move';
|
||||||
e.dataTransfer.setData('text/html', e.currentTarget);
|
e.dataTransfer.setData('text/html', e.currentTarget);
|
||||||
@@ -258,21 +259,21 @@ export default class ComparisonPage extends Page {
|
|||||||
|
|
||||||
if(e.target.className == 'facet-placeholder') {
|
if(e.target.className == 'facet-placeholder') {
|
||||||
return;
|
return;
|
||||||
}
|
} else if (e.target != e.currentTarget) {
|
||||||
|
this.over = e.target;
|
||||||
|
this.dragged.style.display = 'none';
|
||||||
|
let relX = e.clientX - this.over.getBoundingClientRect().left;
|
||||||
|
let width = this.over.offsetWidth / 2;
|
||||||
|
let parent = e.target.parentNode;
|
||||||
|
|
||||||
this.over = e.target;
|
if (parent == e.currentTarget) {
|
||||||
this.dragged.style.display = 'none';
|
if(relX > width && this.dragged != e.target) {
|
||||||
let relX = e.clientX - this.over.getBoundingClientRect().left;
|
this.nodeAfter = true;
|
||||||
let width = this.over.offsetWidth / 2;
|
parent.insertBefore(this.placeholder, e.target.nextElementSibling);
|
||||||
let parent = e.target.parentNode;
|
} else {
|
||||||
|
this.nodeAfter = false;
|
||||||
if (parent == e.currentTarget) {
|
parent.insertBefore(this.placeholder, e.target);
|
||||||
if(relX > width) {
|
}
|
||||||
this.nodeAfter = true;
|
|
||||||
parent.insertBefore(this.placeholder, e.target.nextElementSibling);
|
|
||||||
} else {
|
|
||||||
this.nodeAfter = false;
|
|
||||||
parent.insertBefore(this.placeholder, e.target);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,7 +69,6 @@
|
|||||||
|
|
||||||
.facet-placeholder {
|
.facet-placeholder {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
padding: 0.5em 0.5em;
|
|
||||||
background-color: @primary-bg;
|
background-color: @primary-bg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user