From 7a961c901168e4c523052f97f683a2374472aef5 Mon Sep 17 00:00:00 2001 From: Ozzie Isaacs Date: Fri, 1 Sep 2023 07:30:26 +0200 Subject: [PATCH] Fix for click on scrollbar in long strip view Fix for tornado version --- cps/static/js/kthoom.js | 14 ++++++++------ cps/tornado_wsgi.py | 4 ++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/cps/static/js/kthoom.js b/cps/static/js/kthoom.js index 3fbb22d3..b1ba0882 100644 --- a/cps/static/js/kthoom.js +++ b/cps/static/js/kthoom.js @@ -803,7 +803,7 @@ function init(filename) { }); // Scrolling up/down will update current image if a new image is into view (for Long Strip Display) - $("#mainContent").scroll(function (event){ + $("#mainContent").scroll(function (){ var scroll = $("#mainContent").scrollTop(); var viewLength = 0; $(".mainImage").each(function(){ @@ -815,8 +815,11 @@ function init(filename) { //Scroll Down if (currentImage + 1 < imageFiles.length) { if (currentImageOffset(currentImage + 1) <= 1) { - currentImage++; - console.log(Math.round(imageFiles.length / viewLength * scroll, 0)); + currentImage = Math.floor((imageFiles.length) / (viewLength-viewLength/(imageFiles.length)) * scroll, 0); + if ( currentImage >= imageFiles.length) { + currentImage = imageFiles.length - 1; + } + console.log(currentImage); scrollTocToActive(); updateProgress(); } @@ -825,14 +828,13 @@ function init(filename) { //Scroll Up if (currentImage - 1 > -1) { if (currentImageOffset(currentImage - 1) >= 0) { - currentImage--; - console.log(Math.round(imageFiles.length / viewLength * scroll, 0)); + currentImage = Math.floor((imageFiles.length) / (viewLength-viewLength/(imageFiles.length)) * scroll, 0); + console.log(currentImage); scrollTocToActive(); updateProgress(); } } } - // Update scroll position prevScrollPosition = scroll; }); diff --git a/cps/tornado_wsgi.py b/cps/tornado_wsgi.py index 289e0d37..c1571ece 100644 --- a/cps/tornado_wsgi.py +++ b/cps/tornado_wsgi.py @@ -24,7 +24,7 @@ from tornado import httputil from tornado.ioloop import IOLoop from typing import List, Tuple, Optional, Callable, Any, Dict, Text -from types import TracebackType, FunctionType +from types import TracebackType import typing if typing.TYPE_CHECKING: @@ -34,7 +34,7 @@ if typing.TYPE_CHECKING: class MyWSGIContainer(WSGIContainer): def __call__(self, request: httputil.HTTPServerRequest) -> None: - if tornado.version_info < (6, 2, 0, 0): + if tornado.version_info < (6, 3, 0, -99): data = {} # type: Dict[str, Any] response = [] # type: List[bytes]