Mottie / tablesorter

Github fork of Christian Bach's tablesorter plugin + awesomeness ~
https://mottie.github.io/tablesorter/docs/
2.61k stars 754 forks source link

event "scrollerComplete" fires 4 times #1693

Open MagicMike910 opened 5 years ago

MagicMike910 commented 5 years ago

Hi there,

there is a little issue with my setup.

(function() {
  $("#Liste")
    .on("click", "tbody tr", function() {
      var page = $(this).closest("tr").children().eq(0).text();
      window.location.href = "/stuff.php?act=roll&Page=" + page;
    })
    .tablesorter({
      sortList: [[2, 0]],
      theme: "blue",
      widgets: ["zebra", "scroller", "columnSelector"],
      widgetOptions: {
        scroller_height: 462,
        scroller_barWidth: 10,
        scroller_upAfterSort: true,
        scroller_jumpToHeader: true,
        scroller_fixedColumns: 0,
        scroller_addFixedOverlay: false,
        scroller_rowHighlight: "hover",
        columnSelector_mediaquery: false,
        columnSelector_columns: { 0: false }
      }
    })
    .on("scrollerComplete", function() {
      row = document.getElementById("65").innerHTML - 1;
      position = $(this).find("tbody tr").eq(row).position();
      $(".tablesorter-scroller-table").scrollTop(
        $(".tablesorter-scroller-table").scrollTop() + position.top
      );
    });
});

The event "on( 'scrollerComplete'.... fires 4 times in a row. Because of this issue, the correct position cannot be selected. The scrollTop value reflects "row * 4".

How can i prevent this?

By the way: Removing the "sortList [[2,0]]" Option will solve this problem, but i want to keep this in the config...

Thanks in advance

Michael

Mottie commented 4 years ago

Hi @MagicMike910!

Sorry for taking so long to respond!

Yeah sorry, the scroller widget needs a lot of work, and has a lot of incompatibility issues. I would recommend using debounce in this case.