Skip to content

Commit 9c9928a

Browse files
committed
beta dragSelector funzionante completo con js
1 parent 1e2ae9a commit 9c9928a

File tree

3 files changed

+87
-5
lines changed

3 files changed

+87
-5
lines changed

index.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@
199199
<div>coming soon...</div>
200200
</section>
201201
<div class="extra">
202-
<video autoplay muted loop id="myVideo">
202+
<video autoplay muted id="myVideo">
203203
<source src="./images/video-1dark.mp4" type="video/mp4">
204204
</video>
205205
<section id="not-mobile-friendly">Dispositivo NON Sopportato.</section>
@@ -234,6 +234,9 @@
234234
</div>
235235
</div>
236236
</div>
237+
238+
<!-- new code in beta -->
239+
<div id="div"></div>
237240
</body>
238241

239242

script.js

Lines changed: 71 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@ let notifContainer = document.querySelector("#notification-section");
3636
var vh = window.innerHeight / 100;
3737
var vw = window.innerWidth / 100;
3838

39+
let isTopBarClicked = false;
40+
41+
let div = document.querySelector("#div");
42+
43+
let firstPositionX;
44+
let firstPositionY;
45+
46+
let lastPositionX;
47+
let lastPositionY;
48+
3949
/* from bottom to top WINDOWS START animation */
4050
startBtn.addEventListener("click", function() {
4151
searchContainer.style.display = "none";
@@ -74,6 +84,8 @@ searchBtn.addEventListener("click", function() {
7484

7585
/* windows moving tab */
7686
topPartTab.addEventListener("mousedown", function() {
87+
88+
isTopBarClicked = true;
7789
console.log("mousedown");
7890
document.onmousemove = function(e) {
7991
var x = e.clientX;
@@ -91,17 +103,17 @@ topPartTab.addEventListener("mousedown", function() {
91103
windowsTab.style.left = x + "px";
92104
windowsTab.style.top = y + "px";
93105
if (windowsTab.offsetHeight > 90 * vh) {
94-
/* alert("la finestra è troppo grande, \nla sua dimensione è: " + windowsTab.offsetHeight + "px" + "\nla dimensione massima è: " + (90 * vh) + "px"); */
95-
windowsTab.style.height = "50vh";
106+
windowsTab.style.height = "70vh";
96107
}
97108
windowsTab.style.removeProperty("transform");
98109
}
99-
/* console.log("onmousemove\n" + "x:" + x + " y:" + y + "\n" + "MaxX:" + MaxX); */
100110
}
111+
101112
});
102113

103114
document.addEventListener("mouseup", function() {
104115
document.onmousemove = null;
116+
105117
});
106118

107119
for (let i = 0; i < appIcon.length; i++) {
@@ -182,4 +194,59 @@ function openOneWinCloseOther() {
182194
} else {
183195
startContainer.classList.toggle("on-visible-start");
184196
}
185-
}
197+
}
198+
199+
/* new code in beta */
200+
function dragSelector() {
201+
202+
document.addEventListener("mousedown", function(e1) {
203+
if (windowsTab.style.display == "grid") {
204+
console.log("yessss risolto il bug!!!")
205+
} else {
206+
div.style.display = "block";
207+
208+
div.style.width = 0 + "px";
209+
div.style.height = 0 + "px";
210+
211+
firstPositionX = e1.clientX;
212+
firstPositionY = e1.clientY;
213+
214+
div.style.top = firstPositionY + "px";
215+
div.style.left = firstPositionX + "px";
216+
217+
div.style.transition = "none";
218+
219+
document.addEventListener("mousemove", function(e2) {
220+
lastPositionX = e2.clientX;
221+
lastPositionY = e2.clientY;
222+
223+
if ((firstPositionX - lastPositionX) < 0) {
224+
div.style.width = Math.round(lastPositionX - firstPositionX) + "px";
225+
} else {
226+
div.style.width = Math.round(firstPositionX - lastPositionX) + "px";
227+
div.style.left = lastPositionX + "px";
228+
}
229+
230+
if ((firstPositionY - lastPositionY) < 0) {
231+
div.style.height = Math.round(lastPositionY - firstPositionY) + "px";
232+
} else {
233+
div.style.height = Math.round(firstPositionY - lastPositionY) + "px";
234+
div.style.top = lastPositionY + "px";
235+
}
236+
237+
});
238+
239+
document.addEventListener("mouseup", function() {
240+
div.style.width = "0px";
241+
div.style.height = "0px";
242+
div.style.transition = "all 0.3s";
243+
244+
setTimeout(function() {
245+
div.style.display = "none";
246+
}, 300);
247+
});
248+
}
249+
});
250+
}
251+
252+
dragSelector();

style.css

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -828,4 +828,16 @@ label input {
828828
#not-mobile-friendly {
829829
display: grid;
830830
}
831+
}
832+
833+
834+
/* new code in beta */
835+
836+
#div {
837+
border: 1px solid var(--bottom-border-color-search);
838+
background: #9dcae33c;
839+
display: none;
840+
position: absolute;
841+
border-radius: 0.2em;
842+
/* box-shadow: 0 0 1rem #9dcae33c; */
831843
}

0 commit comments

Comments
 (0)