From 24d7e087fe26364982f5bb9f805abd1a29d55242 Mon Sep 17 00:00:00 2001 From: Niko Date: Mon, 14 Feb 2022 17:08:53 +0100 Subject: [PATCH] Support fadeOut on drag animation --- web/src/app/js/base.js | 15 +++++++++++---- web/src/app/js/pages/meet.js | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/web/src/app/js/base.js b/web/src/app/js/base.js index edfaa27..85be25c 100644 --- a/web/src/app/js/base.js +++ b/web/src/app/js/base.js @@ -11,8 +11,8 @@ function dragElement(elmnt, options, onStopDrag) { e = e || window.event; e.preventDefault(); const isMobile = e.touches !== undefined; - const cx = !isMobile ? e.clientX : e.touches[0].clientX * 2; - const cy = !isMobile ? e.clientY : e.touches[0].clientY * 2; + const cx = !isMobile ? e.clientX : e.touches[0].clientX * 1.3; + const cy = !isMobile ? e.clientY : e.touches[0].clientY * 1.3; // get the mouse cursor position at startup: if (options.x === undefined || options.x === true) pos3 = cx; @@ -31,8 +31,8 @@ function dragElement(elmnt, options, onStopDrag) { e = e || window.event; e.preventDefault(); const isMobile = e.touches !== undefined; - const cx = !isMobile ? e.clientX : e.touches[0].clientX * 2; - const cy = !isMobile ? e.clientY : e.touches[0].clientY * 2; + const cx = !isMobile ? e.clientX : e.touches[0].clientX * 1.3; + const cy = !isMobile ? e.clientY : e.touches[0].clientY * 1.3; if (options.x === undefined || options.x === true) pos1 = pos3 - cx; if (options.y === undefined || options.y === true) @@ -53,6 +53,13 @@ function dragElement(elmnt, options, onStopDrag) { const mu = !isMobile ? 8 : 4; elmnt.style.top = parseInt(Math.abs(n)*mu) + "px" } + if (options.fadeOut) { + const d = (ipos3 - pos3); + var n = d < 0 ? Math.abs(d) : Math.abs(d) - Math.abs(d)*2; + n = parseInt(Math.abs(n / 7)) / 100; + if (n > 1) n = 1; n = 1 - n; + elmnt.style.opacity = n; + } } function closeDragElement() { diff --git a/web/src/app/js/pages/meet.js b/web/src/app/js/pages/meet.js index cec8151..6fae4d0 100644 --- a/web/src/app/js/pages/meet.js +++ b/web/src/app/js/pages/meet.js @@ -57,7 +57,7 @@ app.pages.meet = { setDragEvent: function() { const current = app.pages.meet.carousel._elements()[ app.pages.meet.carousel._current]; - var options = { y: false, return2start: true }; + var options = { y: false, return2start: true, fadeOut: true }; if (!app.carousel.hasPrev(app.pages.meet.carousel)) options.right = false; if (!app.carousel.hasNext(app.pages.meet.carousel))