From 92b3a3c7bebe425b8b55b4b304515d3c788a34aa Mon Sep 17 00:00:00 2001 From: Terry Geng Date: Fri, 5 Jun 2020 14:07:48 +0800 Subject: [PATCH] fix: wrong play bar behavior when dragging or clicking, #166. --- interface.py | 2 +- static/js/custom.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/interface.py b/interface.py index 964c4e6..230d50a 100644 --- a/interface.py +++ b/interface.py @@ -64,7 +64,7 @@ class ReverseProxied(object): web = Flask(__name__) -web.config['TEMPLATES_AUTO_RELOAD'] = True +#web.config['TEMPLATES_AUTO_RELOAD'] = True log = logging.getLogger("bot") user = 'Remote Control' diff --git a/static/js/custom.js b/static/js/custom.js index dbbbb7b..1c29fd6 100644 --- a/static/js/custom.js +++ b/static/js/custom.js @@ -1072,13 +1072,13 @@ playerBarBox.addEventListener('mousedown', function () { }); playerBarBox.addEventListener('mouseup', function (event) { playerBarBox.removeEventListener('mousemove', playheadDragged); - let percent = event.offsetX / playerBarBox.clientWidth; + let percent = (event.clientX - playerBarBox.getBoundingClientRect().x) / playerBarBox.clientWidth; request('post', {move_playhead: percent * currentPlayingItem.duration}); playhead_dragging = false; }); function playheadDragged(event){ - let percent = event.offsetX / playerBarBox.clientWidth; + let percent = (event.clientX - playerBarBox.getBoundingClientRect().x) / playerBarBox.clientWidth; setProgressBar(playerBar, percent, secondsToStr(percent * currentPlayingItem.duration)); }