feat: Change edge detection for HippieTaskBar
- Add position to options - New function for edge detection according to mouse position - set and use options.position
This commit is contained in:
parent
9696442a91
commit
7912b002a2
3 changed files with 29 additions and 13 deletions
|
|
@ -8,6 +8,7 @@ class HippieTaskBar {
|
|||
// TODO: Erweitern auf allgemeine Möglichkeiten und dann aus JSON-Datei laden
|
||||
this.options = options || {
|
||||
direction: 0,
|
||||
position: 'bottom',
|
||||
date: {
|
||||
year: 'numeric',
|
||||
month: '2-digit',
|
||||
|
|
@ -30,7 +31,7 @@ class HippieTaskBar {
|
|||
this.element.querySelector('.clock').appendChild(dateElement);
|
||||
this.date = new DateDisplay(dateElement, this.options.date);
|
||||
|
||||
this.setOptions('bottom');
|
||||
this.setOptions(this.options.position);
|
||||
}
|
||||
|
||||
onMouseDown(event) {
|
||||
|
|
@ -49,7 +50,7 @@ class HippieTaskBar {
|
|||
|
||||
onMouseMove(event) {
|
||||
if (this.isDragging) {
|
||||
const closestEdge = getClosestEdge(this.placeholder);
|
||||
this.options.position = getClosestEdgeToMouse(event);
|
||||
const borderRadius = '4px';
|
||||
const attributes = {
|
||||
top: {
|
||||
|
|
@ -110,7 +111,7 @@ class HippieTaskBar {
|
|||
}
|
||||
};
|
||||
|
||||
setAttributesAccordingToPosition(this.placeholder, closestEdge, attributes);
|
||||
setAttributesAccordingToPosition(this.placeholder, this.options.position, attributes);
|
||||
centerElementUnderCursor(event, this.placeholder);
|
||||
}
|
||||
}
|
||||
|
|
@ -136,11 +137,8 @@ class HippieTaskBar {
|
|||
this.element.style.display = '';
|
||||
}
|
||||
|
||||
// TODO: Prüfung auf Ziel auslagern und schon bei Mausbewegung verfügbar machen
|
||||
snapToEdges() {
|
||||
const closestEdge = getClosestEdge(this.placeholder);
|
||||
|
||||
this.setOptions(closestEdge);
|
||||
this.setOptions(this.options.position);
|
||||
this.date.changeFormat(this.options.date, this.options.direction);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue