Bugs appending rows to table and scrolling to bottom of page

rich

Code here and repeated below: http://codepen.io/anon/pen/rLvBbA

Click the "add rows" link repeatedly. Often it takes a few seconds to scroll to the bottom of the page after adding the rows, sometimes it does it immediately.

I don't know if it's that jquery's animate is sometimes doing the scroll immediately instead of over a duration, or if sometimes the browser is scrolling to the bottom immediately itself perhaps? The behaviour seems broken one way on Chrome and Safari (irregular) and differently on Firefox (seems to work on first page load but break up after that).

HTML:

<table>
</table>

<a href="javascript:(addRows())">Add rows</a>

CSS:

body {
  padding: 100px;
}

td {
  padding: 10px 20px;
  border: 1px solid #ccc;
}

tr.level-WARN {
  background-color: #FFB347;
}

Javascript:

$(document).ready(function() {
  addRows();
  addRows();
  addRows();
  addRows();
});

function addRows() {
  for (var x = 0; x<5; x++) {
    var row = $('<tr/>');
    row.append($('<td/>').text('This is some table cell content.'));

    if (Math.floor(Math.random() * 10) == 0) {
      row.addClass('level-WARN');
    } else {
      row.addClass('level-INFO');
    }
    $('table').append(row);
  }

  $("html, body").animate({ scrollTop: $(document).height() }, 3000);
}
gaetanoM

When you call:

addRows();

the previous animation could not be finished so you may add a jQuery stop in order to stop the currently-running animation and start a new one.

My snippet:

function addRows() {
  for (var x = 0; x<5; x++) {
    var row = $('<tr/>');
    row.append($('<td/>').text('This is some table cell content.'));

    if (Math.floor(Math.random() * 10) == 0) {
      row.addClass('level-WARN');
    } else {
      row.addClass('level-INFO');
    }
    $('table').append(row);
  }

  $("html, body").stop().animate({ scrollTop: $(document).height() }, 3000);
}
$(function () {
  addRows();
  addRows();
  addRows();
  addRows();
});
body {
  padding: 100px;
}

td {
  padding: 10px 20px;
  border: 1px solid #ccc;
}

tr.level-WARN {
  background-color: #FFB347;
}
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>

<table>
</table>

<a href="javascript:(addRows())">Add rows</a>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

lightbox scrolling past page bottom

From Dev

Page not scrolling all the way to the bottom

From Dev

lightbox scrolling past page bottom

From Dev

Appending rows into table using JQuery

From Dev

Keep footer at the bottom of the page (with scrolling if needed)

From Dev

One Page Checkout scrolling to the bottom of screen on next

From Dev

Detect the scrolling to bottom of the page using Dart

From Dev

Why is my page automatically scrolling to the bottom/

From Dev

Jump div to bottom with out scrolling the page

From Dev

How to stick div to bottom page no scrolling

From Dev

Views and appending table rows in backbone.js

From Dev

Appending Rows to Nested HTML Table using Jquery

From Dev

How to append more rows when scrolling to the Bottom with Javascript

From Dev

Appending table, tr, td tags to innerHTML does not create table rows

From Dev

stops sidebar scrolling when its reach bottom of the page

From Dev

Detect dead scrolling at the bottom of the page (mousewheel, scroll events)

From Dev

How to prevent white space "bounce" after scrolling to the top of the page and the bottom

From Dev

RecyclerView scrolling to bottom of page doesn't trigger .addOnScrollListener's canScrollVertically

From Dev

CSS - Column aligned to bottom of page but grows with scrolling content.

From Dev

Update data source of an UITableView with new data after scrolling table to the bottom

From Dev

can not get the dom element after appending rows of table

From Dev

What is causing extra spacing to display when appending table rows with jquery

From Dev

Print table footer at the very bottom on last page

From Dev

Sticking HTML 5 table footer at bottom of the page

From Dev

SSRS Reports - force table to expand to bottom of page

From Dev

How to align table to the bottom of a page in XSL FO

From Dev

Float table to bottom of page in Word 2007

From Dev

Appending all page <table>'s to respective <div> with pure Javascript

From Dev

Load HTML table on page load appending with URL response

Related Related

  1. 1

    lightbox scrolling past page bottom

  2. 2

    Page not scrolling all the way to the bottom

  3. 3

    lightbox scrolling past page bottom

  4. 4

    Appending rows into table using JQuery

  5. 5

    Keep footer at the bottom of the page (with scrolling if needed)

  6. 6

    One Page Checkout scrolling to the bottom of screen on next

  7. 7

    Detect the scrolling to bottom of the page using Dart

  8. 8

    Why is my page automatically scrolling to the bottom/

  9. 9

    Jump div to bottom with out scrolling the page

  10. 10

    How to stick div to bottom page no scrolling

  11. 11

    Views and appending table rows in backbone.js

  12. 12

    Appending Rows to Nested HTML Table using Jquery

  13. 13

    How to append more rows when scrolling to the Bottom with Javascript

  14. 14

    Appending table, tr, td tags to innerHTML does not create table rows

  15. 15

    stops sidebar scrolling when its reach bottom of the page

  16. 16

    Detect dead scrolling at the bottom of the page (mousewheel, scroll events)

  17. 17

    How to prevent white space "bounce" after scrolling to the top of the page and the bottom

  18. 18

    RecyclerView scrolling to bottom of page doesn't trigger .addOnScrollListener's canScrollVertically

  19. 19

    CSS - Column aligned to bottom of page but grows with scrolling content.

  20. 20

    Update data source of an UITableView with new data after scrolling table to the bottom

  21. 21

    can not get the dom element after appending rows of table

  22. 22

    What is causing extra spacing to display when appending table rows with jquery

  23. 23

    Print table footer at the very bottom on last page

  24. 24

    Sticking HTML 5 table footer at bottom of the page

  25. 25

    SSRS Reports - force table to expand to bottom of page

  26. 26

    How to align table to the bottom of a page in XSL FO

  27. 27

    Float table to bottom of page in Word 2007

  28. 28

    Appending all page <table>'s to respective <div> with pure Javascript

  29. 29

    Load HTML table on page load appending with URL response

HotTag

Archive