diff --git a/docs/dashticzconfiguration.rst b/docs/dashticzconfiguration.rst index 564f4e79..10bd0a6c 100644 --- a/docs/dashticzconfiguration.rst +++ b/docs/dashticzconfiguration.rst @@ -111,16 +111,16 @@ Config parameters | ``0`` = Swipe by touch disabled | ``1`` = Swipe by touch enabled * - auto_swipe_back_to - - | when no activity, swipe back to the selected page - | ``1..100`` = page number + - | when no activity, swipe back to the selected page. Also see :ref:`autoswipe` + | ``1..100`` = page number (default: 1) * - auto_swipe_back_after - - | The amount of seconds after which Dashticz will swipe back to the default page, as defined by ``auto_swipe_back_to`` - | ``0`` = No auto swiping back (default) - | ``1..9999`` = Swipe back after seconds + - | The amount of seconds after which Dashticz will start with auto swipe/auto slide. Also see :ref:`autoswipe` + | ``0`` = No auto swiping (default) + | ``1..9999`` = Start auto swipe back after seconds the last screen touch/mouse activity. * - auto_slide_pages - - | Loop all pages and change page every x (min. 5) seconds, - | set ``config['auto_swipe_back_after'] = 0``. Also see screen parameter ``auto_slide_page`` - | ``false`` = No auto slide (default) + - | Loop all pages and change page every x seconds, + | set ``config['auto_swipe_back_to'] = 0``. Also see :ref:`autoswipe` + | ``0`` = Auto slide is disabled. (=default) | ``1..9999`` = Auto slide to the next page every second * - slide_effect - | Control which Screenslider effect you prefer diff --git a/docs/releasenotes/releasenotes.rst b/docs/releasenotes/releasenotes.rst index 9f513999..2ce6c6f8 100644 --- a/docs/releasenotes/releasenotes.rst +++ b/docs/releasenotes/releasenotes.rst @@ -8,9 +8,21 @@ For Dashticz's **master** version Release Notes go to: https://dashticz.readthed Recent changes --------------- +v3.8.1 Beta (14-4-2021) +----------------------- + +Enhancements +~~~~~~~~~~~~ + +* Change in auto swipe behavior. See :ref:`autoswipe`. + v3.8.0 Beta (10-4-2021) ----------------------- +Enhancements +~~~~~~~~~~~~ + +* Auto slide timer configurable per screen via screen parameter ``auto_slide_page`` v3.8 Master (9-4-2021) @@ -25,10 +37,6 @@ See the upgrade instructions at v3.7.2 below. v3.7.7 Beta (8-4-2021) ------------------------ -Enhancements -~~~~~~~~~~~~ - -* Auto slide timer configurable per screen via screen parameter ``auto_slide_page`` Fixes ~~~~~~ diff --git a/docs/screens.rst b/docs/screens.rst index 5ff38e69..beafd5a9 100644 --- a/docs/screens.rst +++ b/docs/screens.rst @@ -128,6 +128,29 @@ The following config settings are applicable to the standby screen: | Enter the url for adjusting the brightness when exiting stand-by mode +.. _autoswipe: + +Auto swipe, auto slide +~~~~~~~~~~~~~~~~~~~~~~~ + +Two auto swipe modes exist + +1. Auto swipe back to a specific screen (default) +2. Auto slide to the next screen + +The 'swipe back' mode is selected by setting ``config['auto_swipe_back_after']`` to non zero. +The 'next screen' mode is selected by setting ``config['auto_slide_pages']`` to non zero. + +The initial delay before starting 'next screen' mode, can be set via ``config['auto_swipe_back_after']``. + +The default timeout which is used for each screen in 'next screen' mode can be defined by ``config['auto_slide_pages']``. +However, you can overrule this for each screen by adding the ``auto_slide_page`` parameter to the screen block. +In case the screen parameter ``auto_slide_page`` is 0 , then this screen will be skipped during auto slide. + +All timeouts (auto_swipe_back_after, auto_slide_pages, auto_slide_page) are defined in seconds. + +The auto swipe countdown timer will reset after mouse moves and screen touches. + Styling ------- diff --git a/js/main.js b/js/main.js index d421ce7c..a6616290 100644 --- a/js/main.js +++ b/js/main.js @@ -22,6 +22,7 @@ var standby = true; var standbyActive = false; var standbyTime = 0; var swipebackTime = 0; +var autoSwipe = false; //will be true when autoSwipe is active // eslint-disable-next-line no-unused-vars var audio = {}; var screens = {}; @@ -363,10 +364,9 @@ function addDebug() { return $.ajax({ url: 'js/debug.js', dataType: 'script', - }) - .then(function () { - return Debug.init(); - }) + }).then(function () { + return Debug.init(); + }); } function showError(msg) { @@ -392,20 +392,34 @@ function defaultPassiveHandlers() { }; } -function autoSlide(screenId) { - var nextSlide=screenId; - - if (typeof myswiper !== 'undefined') { - nextSlide=nextSlide+1; - toSlide(screenId); +function autoSlide() { + if (typeof myswiper === 'undefined') return; + var nextSlide = myswiper.activeIndex + 1; + var valid = false; + while (!valid) { + if (nextSlide === myswiper.activeIndex) { + console.log( + 'autoswiping but all auto_slide_page paramaters are 0. Disabling auto swipe' + ); + settings.auto_slide_pages = 0; + settings.auto_swipe_back_after = 0; + return; + } if (nextSlide > myswiper.slides.length - 1) { nextSlide = 0; } + valid = true; + if ( + typeof currentScreenSet[nextSlide].auto_slide_page !== 'undefined' && + !currentScreenSet[nextSlide].auto_slide_page + ) { + //auto_slide_page screen parameter is 0, skipping to next screen + nextSlide = nextSlide + 1; + valid = false; + } } - setTimeout(function () { - autoSlide(nextSlide) - }, parseFloat(currentScreenSet[screenId].auto_slide_page || settings['auto_slide_pages']) * 1000); + toSlide(nextSlide); } function onLoad() { @@ -460,19 +474,32 @@ function onLoad() { }, dashticzRefresh * 60 * 1000); } - if ( - typeof settings['auto_swipe_back_to'] !== 'undefined' && - typeof settings['auto_swipe_back_after'] !== 'undefined' - ) { - if (parseFloat(settings['auto_swipe_back_after']) > 0) { - setInterval(function () { - swipebackTime += 1000; + if (settings['auto_swipe_back_after'] > 0 || settings.auto_slide_pages > 0) { + setInterval(function () { + swipebackTime += 1000; + if (settings.auto_slide_pages > 0) { + var currentSlide = myswiper.activeIndex; + var swipeTimeout = autoSwipe + ? currentScreenSet[currentSlide].auto_slide_page || + settings.auto_slide_pages + : settings.auto_swipe_back_after; + if (swipebackTime > swipeTimeout * 1000) { + autoSlide(); + autoSwipe = true; + swipebackTime = 0; + } + return; + } + + if (settings.auto_swipe_back_to > 0) { + //swipe back to specified screen if (swipebackTime >= settings['auto_swipe_back_after'] * 1000) { toSlide(settings['auto_swipe_back_to'] - 1); swipebackTime = 0; } - }, 1000); - } + return; + } + }, 1000); } if ( @@ -496,17 +523,10 @@ function onLoad() { $('body').prepend(googleAnalytics); } - if ( - (settings['auto_swipe_back_after'] == 0 || - typeof settings['auto_swipe_back_after'] == 'undefined') && - parseFloat(settings['auto_slide_pages']) > 0 - ) { - autoSlide(1); - } - if (md.mobile() == null) { $('body').on('mousemove', function () { swipebackTime = 0; + autoSwipe = false; disableStandby(); }); } @@ -514,6 +534,7 @@ function onLoad() { $('body').on('touchend click', function () { setTimeout(function () { swipebackTime = 0; + autoSwipe = false; disableStandby(); }, 100); }); @@ -657,7 +678,7 @@ function buildScreens() { (parseFloat(screens[t]['maxwidth']) >= $(window).width() && parseFloat(screens[t]['maxheight']) >= $(window).height()) ) { - currentScreenSet=[] + currentScreenSet = []; for (var s in screens[t]) { currentScreenSet.push(screens[t][s]); if (s !== 'maxwidth' && s !== 'maxheight') { diff --git a/js/settings.js b/js/settings.js index 9c5f7895..b125fd6d 100644 --- a/js/settings.js +++ b/js/settings.js @@ -813,6 +813,7 @@ var defaultSettings = { slide_effect: 'slide', hide_mediaplayer: 0, auto_swipe_back_to: 1, + auto_slide_pages: 0, start_page: 1, auto_positioning: 1, use_favorites: 0, @@ -822,7 +823,7 @@ var defaultSettings = { vertical_scroll: 2, enable_swiper: 2, swiper_touch_move: 1, - auto_swipe_back_after: 10, + auto_swipe_back_after: 0, standby_after: 0, selector_instead_of_buttons: 0, default_news_url: 'http://www.nu.nl/rss/algemeen', diff --git a/version.txt b/version.txt index 95fcecee..22085844 100644 --- a/version.txt +++ b/version.txt @@ -1,8 +1,9 @@ { -"version": "3.8.0", +"version": "3.8.1", "branch": "beta", -"last_changes": "Auto slide page parameter per screen", +"last_changes": "Improved auto slide behavior", "changelog" : { + "3.8.0": "Auto slide page parameter per screen", "3.8": "Master version" } }