1

I want to scroll to bottom without triggering layout/reflow.

So I tried to set a fixed large number(Number.MAX_SAFE_INTEGER or 1000000000000000) to scrollTop, which caused different behavior across browsers:

  • Firefox(59.02)/Safari(11.1): scroll to top
  • Chrome(66.0.3359.139): scroll to bottom

Here's the Example.

Is this a bug or there's something I went wrong...?

Banana-In-Black
  • 2,558
  • 1
  • 27
  • 33

2 Answers2

1

Instead you can try with scrollTop to the calculated height of the page. It is simpler and straight forward. Steps to follow 1. Find the height of the document / any container div

var containerHeight= $("#box").height();

  1. scrollTop with containerHeight.

document.querySelector('#box').scrollTop = containerHeight;

This will surely work with any behaviour mismatch.

0

This could be caused by the different max values for elements across browsers. For instance, in Chrome the limit is 33554428px. A complete list was given here: What's the maximum pixel value of CSS width and height properties?

11AND2
  • 1,067
  • 7
  • 10