Compare commits
7 commits
13b1924360
...
50b43cdc2f
| Author | SHA1 | Date | |
|---|---|---|---|
| 50b43cdc2f | |||
| a18b42bb2a | |||
| 53897754e2 | |||
| 3dc836656a | |||
| aa5d095e64 | |||
| 0f561d360a | |||
| 667485fce1 |
5 changed files with 175 additions and 57 deletions
15
.jshintrc
15
.jshintrc
|
|
@ -88,9 +88,16 @@
|
||||||
|
|
||||||
// Custom globals
|
// Custom globals
|
||||||
"globals" : { // additional predefined global variables
|
"globals" : { // additional predefined global variables
|
||||||
"debugOn": true,
|
"debugOn": true,
|
||||||
"hippie": true,
|
"hippie": true,
|
||||||
"viewHover": true,
|
"viewHover": true,
|
||||||
"basicEase": true
|
"basicEase": true,
|
||||||
|
"TimeDisplay": true,
|
||||||
|
"DateDisplay": true,
|
||||||
|
"checkButtonAndTarget": true,
|
||||||
|
"getClosestEdge": true,
|
||||||
|
"centerElementUnderCursor": true,
|
||||||
|
"setAttributesAccordingToPosition": true,
|
||||||
|
"HippieTaskBar": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -339,6 +339,49 @@ class DateDisplay {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function checkButtonAndTarget(event, element, button = 0) {
|
||||||
|
return (
|
||||||
|
event.button === button &&
|
||||||
|
event.target === element
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getClosestEdge(element) {
|
||||||
|
const rect = element.getBoundingClientRect();
|
||||||
|
const windowWidth = window.innerWidth;
|
||||||
|
const windowHeight = window.innerHeight;
|
||||||
|
const distances = {
|
||||||
|
top: rect.top,
|
||||||
|
right: windowWidth - rect.right,
|
||||||
|
bottom: windowHeight - rect.bottom,
|
||||||
|
left: rect.left
|
||||||
|
};
|
||||||
|
|
||||||
|
return Object.keys(distances).reduce((a, b) => distances[a] < distances[b] ? a : b);
|
||||||
|
}
|
||||||
|
|
||||||
|
function centerElementUnderCursor(event, element) {
|
||||||
|
const offsetX = element.getBoundingClientRect().width / 2;
|
||||||
|
const offsetY = element.getBoundingClientRect().height / 2;
|
||||||
|
const x = event.clientX - offsetX;
|
||||||
|
const y = event.clientY - offsetY;
|
||||||
|
|
||||||
|
element.style.left = `${x}px`;
|
||||||
|
element.style.top = `${y}px`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function setAttributesAccordingToPosition(element, position, attributes) {
|
||||||
|
element.classList.remove(...Object.values(attributes).map(pos => pos.className));
|
||||||
|
Object.keys(attributes[position].styles).forEach(key => {
|
||||||
|
element.style[key] = '';
|
||||||
|
});
|
||||||
|
|
||||||
|
element.classList.add(attributes[position].className);
|
||||||
|
Object.entries(attributes[position].styles).forEach(([key, value]) => {
|
||||||
|
element.style[key] = value;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// CONCEPTS
|
// CONCEPTS
|
||||||
|
|
||||||
// NOTE: Benutzt private Zuweisungen
|
// NOTE: Benutzt private Zuweisungen
|
||||||
|
|
@ -524,10 +567,3 @@ function gigabytes(percent, total, round) {
|
||||||
|
|
||||||
return g;
|
return g;
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkButtonAndTarget(event, element, button = 0) {
|
|
||||||
return (
|
|
||||||
event.button === button &&
|
|
||||||
event.target === element
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -3,10 +3,8 @@ class HippieTaskBar {
|
||||||
this.element = element;
|
this.element = element;
|
||||||
this.placeholder = placeholder;
|
this.placeholder = placeholder;
|
||||||
this.date = null;
|
this.date = null;
|
||||||
this.offsetX = 0;
|
|
||||||
this.offsetY = 0;
|
|
||||||
this.isDragging = false;
|
this.isDragging = false;
|
||||||
this.barSize = '64px';
|
this.barSize = '';
|
||||||
// TODO: Erweitern auf allgemeine Möglichkeiten und dann aus JSON-Datei laden
|
// TODO: Erweitern auf allgemeine Möglichkeiten und dann aus JSON-Datei laden
|
||||||
this.options = options || {
|
this.options = options || {
|
||||||
direction: 0,
|
direction: 0,
|
||||||
|
|
@ -41,17 +39,9 @@ class HippieTaskBar {
|
||||||
|
|
||||||
this.isDragging = true;
|
this.isDragging = true;
|
||||||
|
|
||||||
// TODO: Platzhalter anpassen je nach Ziel
|
|
||||||
this.showPlaceholder();
|
this.showPlaceholder();
|
||||||
|
|
||||||
this.offsetX = this.placeholder.getBoundingClientRect().width / 2;
|
centerElementUnderCursor(event, this.placeholder);
|
||||||
this.offsetY = this.placeholder.getBoundingClientRect().height / 2;
|
|
||||||
|
|
||||||
let x = event.clientX - this.offsetX;
|
|
||||||
let y = event.clientY - this.offsetY;
|
|
||||||
|
|
||||||
this.placeholder.style.left = `${x}px`;
|
|
||||||
this.placeholder.style.top = `${y}px`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
@ -61,13 +51,69 @@ class HippieTaskBar {
|
||||||
if (this.isDragging) {
|
if (this.isDragging) {
|
||||||
if (!this.isDragging) return;
|
if (!this.isDragging) return;
|
||||||
|
|
||||||
let x = event.clientX - this.offsetX;
|
const closestEdge = getClosestEdge(this.placeholder);
|
||||||
let y = event.clientY - this.offsetY;
|
const borderRadius = '4px';
|
||||||
|
const attributes = {
|
||||||
|
top: {
|
||||||
|
className: 'top',
|
||||||
|
styles: {
|
||||||
|
flexDirection: 'row',
|
||||||
|
borderStyle: '',
|
||||||
|
borderColor: '',
|
||||||
|
borderTopStyle: 'solid',
|
||||||
|
borderTopColor: 'white',
|
||||||
|
borderTopRightRadius: '',
|
||||||
|
borderBottomRightRadius: borderRadius,
|
||||||
|
borderBottomLeftRadius: borderRadius,
|
||||||
|
borderTopLeftRadius: ''
|
||||||
|
}
|
||||||
|
},
|
||||||
|
right: {
|
||||||
|
className: 'right',
|
||||||
|
styles: {
|
||||||
|
flexDirection: 'column',
|
||||||
|
borderStyle: '',
|
||||||
|
borderColor: '',
|
||||||
|
borderRightStyle: 'solid',
|
||||||
|
borderRightColor: 'white',
|
||||||
|
borderTopRightRadius: '',
|
||||||
|
borderBottomRightRadius: '',
|
||||||
|
borderBottomLeftRadius: borderRadius,
|
||||||
|
borderTopLeftRadius: borderRadius
|
||||||
|
}
|
||||||
|
},
|
||||||
|
bottom: {
|
||||||
|
className: 'bottom',
|
||||||
|
styles: {
|
||||||
|
flexDirection: 'row',
|
||||||
|
borderStyle: '',
|
||||||
|
borderColor: '',
|
||||||
|
borderBottomStyle: 'solid',
|
||||||
|
borderBottomColor: 'white',
|
||||||
|
borderTopRightRadius: borderRadius,
|
||||||
|
borderBottomRightRadius: '',
|
||||||
|
borderBottomLeftRadius: '',
|
||||||
|
borderTopLeftRadius: borderRadius
|
||||||
|
}
|
||||||
|
},
|
||||||
|
left: {
|
||||||
|
className: 'left',
|
||||||
|
styles: {
|
||||||
|
flexDirection: 'column',
|
||||||
|
borderStyle: '',
|
||||||
|
borderColor: '',
|
||||||
|
borderLeftStyle: 'solid',
|
||||||
|
borderLeftColor: 'white',
|
||||||
|
borderTopRightRadius: borderRadius,
|
||||||
|
borderBottomRightRadius: borderRadius,
|
||||||
|
borderBottomLeftRadius: '',
|
||||||
|
borderTopLeftRadius: ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
console.debug('Position: ', x, y);
|
setAttributesAccordingToPosition(this.placeholder, closestEdge, attributes);
|
||||||
|
centerElementUnderCursor(event, this.placeholder);
|
||||||
this.placeholder.style.left = `${x}px`;
|
|
||||||
this.placeholder.style.top = `${y}px`;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -85,7 +131,7 @@ class HippieTaskBar {
|
||||||
|
|
||||||
showPlaceholder() {
|
showPlaceholder() {
|
||||||
this.element.style.display = 'none';
|
this.element.style.display = 'none';
|
||||||
this.placeholder.style.display = 'block';
|
this.placeholder.style.display = 'flex';
|
||||||
}
|
}
|
||||||
|
|
||||||
hidePlaceholder() {
|
hidePlaceholder() {
|
||||||
|
|
@ -95,16 +141,7 @@ class HippieTaskBar {
|
||||||
|
|
||||||
// TODO: Prüfung auf Ziel auslagern und schon bei Mausbewegung verfügbar machen
|
// TODO: Prüfung auf Ziel auslagern und schon bei Mausbewegung verfügbar machen
|
||||||
snapToEdges() {
|
snapToEdges() {
|
||||||
const rect = this.placeholder.getBoundingClientRect();
|
const closestEdge = getClosestEdge(this.placeholder);
|
||||||
const windowWidth = window.innerWidth;
|
|
||||||
const windowHeight = window.innerHeight;
|
|
||||||
const distances = {
|
|
||||||
top: rect.top,
|
|
||||||
right: windowWidth - rect.right,
|
|
||||||
bottom: windowHeight - rect.bottom,
|
|
||||||
left: rect.left
|
|
||||||
};
|
|
||||||
const closestEdge = Object.keys(distances).reduce((a, b) => distances[a] < distances[b] ? a : b);
|
|
||||||
|
|
||||||
this.setOptions(closestEdge);
|
this.setOptions(closestEdge);
|
||||||
this.date.changeFormat(this.options.date, this.options.direction);
|
this.date.changeFormat(this.options.date, this.options.direction);
|
||||||
|
|
@ -150,15 +187,7 @@ class HippieTaskBar {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.element.classList.remove(...Object.values(attributes).map(pos => pos.className));
|
setAttributesAccordingToPosition(this.element, position, attributes);
|
||||||
Object.keys(attributes[position].styles).forEach(key => {
|
|
||||||
this.element.style[key] = '';
|
|
||||||
});
|
|
||||||
|
|
||||||
this.element.classList.add(attributes[position].className);
|
|
||||||
Object.entries(attributes[position].styles).forEach(([key, value]) => {
|
|
||||||
this.element.style[key] = value;
|
|
||||||
});
|
|
||||||
|
|
||||||
switch (position) {
|
switch (position) {
|
||||||
case 'right':
|
case 'right':
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,14 @@ tags:
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="screen-space"></div>
|
<div id="screen-space"></div>
|
||||||
<div id="placeholder"></div>
|
<div id="placeholder">
|
||||||
|
<div class="box"></div>
|
||||||
|
<div class="box_brd"></div>
|
||||||
|
<div>
|
||||||
|
<span>task bar</span>
|
||||||
|
<div class="box_brd"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{%- block script %}
|
{%- block script %}
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,7 @@ $padding_half: calc(#{hippie.$space_half} - 3px) hippie.$space_half;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
align-items: stretch;
|
align-items: center;
|
||||||
align-content: center;
|
|
||||||
justify-content: flex-start;
|
justify-content: flex-start;
|
||||||
gap: hippie.$space_half hippie.$space_basic;
|
gap: hippie.$space_half hippie.$space_basic;
|
||||||
}
|
}
|
||||||
|
|
@ -115,11 +114,51 @@ $padding_half: calc(#{hippie.$space_half} - 3px) hippie.$space_half;
|
||||||
}
|
}
|
||||||
|
|
||||||
#placeholder {
|
#placeholder {
|
||||||
|
@extend %flex-bar;
|
||||||
display: none;
|
display: none;
|
||||||
z-index: map.get(hippie.$z-indexes, "content-top");
|
z-index: map.get(hippie.$z-indexes, "toast");
|
||||||
position: fixed;
|
position: fixed;
|
||||||
width: 100px;
|
border: 1px dashed black;
|
||||||
height: 100px;
|
border-radius: 2px;
|
||||||
border: 2px dashed deeppink;
|
background-color: rgba(0, 0, 0, .4);
|
||||||
background-color: hotpink;
|
padding: 16px;
|
||||||
|
|
||||||
|
&.top,
|
||||||
|
&.bottom {
|
||||||
|
span {
|
||||||
|
writing-mode: unset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&.right,
|
||||||
|
&.left {
|
||||||
|
span {
|
||||||
|
writing-mode: vertical-rl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
* {
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
& > div {
|
||||||
|
@extend %flex-bar;
|
||||||
|
flex-direction: inherit;
|
||||||
|
flex-wrap: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.box,
|
||||||
|
.box_brd {
|
||||||
|
width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.box {
|
||||||
|
background-color: black;
|
||||||
|
}
|
||||||
|
|
||||||
|
.box_brd {
|
||||||
|
border: 2px solid black;
|
||||||
|
background-color: transparent;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue