Plugin Directory

Changeset 1910165


Ignore:
Timestamp:
07/17/2018 06:47:10 AM (8 years ago)
Author:
fbchville
Message:

Fix autoscroll on desktop

File:
1 edited

Legend:

Unmodified
Added
Removed
  • simple-espace-table/trunk/js/functions.js

    r1910163 r1910165  
    2727                        autoScroll( $element, scrollSpeed);
    2828
     29                        let seconds_pause = $element.data('seconds_pause');
     30
     31                        if (seconds_pause === '' || seconds_pause === undefined) {
     32                            seconds_pause = 1000;
     33                        }
     34
     35                        setInterval(function() {
     36                            const last_timeout_id = $element.data('last_timeout_over_id');
     37
     38                            if (in_table) {
     39
     40                                if (last_timeout_id) {
     41                                    clearTimeout(last_timeout_id);
     42                                    $element.data('last_timeout_over_id', -1);
     43                                }
     44                                return;
     45                            }
     46
     47                            if (last_timeout_id !== -1 && last_timeout_id !== undefined) {
     48                                return;
     49                            }
     50
     51                            if ($element.scrollTop() + $element.height() >= $element[0].scrollHeight) {
     52                                const timeout_id = setTimeout(function() {
     53                                    $element.scrollTop(0);
     54
     55                                    $element.stop();
     56
     57   
     58
     59                                    $element.clearQueue();
     60
     61                                    scrollSpeed = $element.find('table').height() + $element.find('table').position().top;
     62
     63                                    autoScroll($element, scrollSpeed);
     64
     65                                    $element.data('last_timeout_over_id', -1);
     66                                }, seconds_pause);
     67
     68                                $element.data('last_timeout_over_id', timeout_id);
     69                            }
     70                        }, 500);
     71
     72
    2973                        $element
    30                             .on('mouseover touchstart', _.debounce(function(event){
     74                            .on('mouseenter touchstart', _.debounce(function(event){
    3175                                const $this_element = $(this);
    3276
     
    3781                                in_table = true;
    3882                            }, 10))
    39                             .on('mouseout touchend', _.debounce(function(event){
     83                            .on('mouseleave touchend', _.debounce(function(event){
    4084                                if (table_scrolled && $win.width() <= 1024 && isMobile) {
    4185                                    return;
     
    61105                                    if (last_timeout_id) {
    62106                                        clearTimeout(last_timeout_id);
     107                                        $element.data('last_timeout_over_id', -1);
    63108                                    }
    64109
     
    77122
    78123                                        autoScroll($this_element, scrollSpeed);
     124
     125                                        $element.data('last_timeout_over_id', -1);
    79126                                    }, seconds_pause);
    80127
     
    105152                                    if (last_timeout_id) {
    106153                                        clearTimeout(last_timeout_id);
     154                                        $element.data('last_timeout_over_id', -1);
    107155                                    }
    108156
     
    117165
    118166                                        autoScroll($this_element, scrollSpeed);
     167
     168                                        $element.data('last_timeout_over_id', -1);
    119169                                    }, seconds_pause);
    120170
Note: See TracChangeset for help on using the changeset viewer.