From fb7a7a1a0f66f8c5bccad284d3c142c9b79cfc09 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Tue, 3 Jan 2023 14:28:08 +0200 Subject: [WGL/HW11] Added offscreen drag barriers --- .../Homework 11 - The graph/Homework.html | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Year 2/Computer Graphics with WebGL/Homework 11 - The graph/Homework.html b/Year 2/Computer Graphics with WebGL/Homework 11 - The graph/Homework.html index 501bd7e..240cea0 100644 --- a/Year 2/Computer Graphics with WebGL/Homework 11 - The graph/Homework.html +++ b/Year 2/Computer Graphics with WebGL/Homework 11 - The graph/Homework.html @@ -97,6 +97,8 @@ slleft.onmousemove = function (e) { if (!inside || clicked != 1) return; var newCurr = current + initialPosition - e.clientX; + if ((newCurr > leftCurrent) && // if we move left + (slright.offsetWidth * 0.4 - leftCurrent < 10)) return; if ((newCurr < leftCurrent) && // if we move right (slleft.offsetWidth * 0.4 - leftCurrent >= slright.offsetWidth * 0.6 - rightCurrent - 50)) return; @@ -105,6 +107,8 @@ slright.onmousemove = function (e) { if (!inside || clicked != 2) return; var newCurr = current + initialPosition - e.clientX; + if ((newCurr < rightCurrent) && // if we move right + (slright.offsetWidth * 0.4 + rightCurrent < 10)) return; if ((newCurr > rightCurrent) && // if we move left (slleft.offsetWidth * 0.4 - leftCurrent >= slright.offsetWidth * 0.6 - rightCurrent - 50)) return; -- cgit v1.3.1-26-gb76a