/*
* @title groscroll
* @description smooth scrolling by Vanilla; for jQuery.animate() lover
* @include http://*
* @include https://*
* @license MIT License https://opensource.org/licenses/MIT
* @javascript_url
*/
(() => {
'use strict';
const y = Math.max(...[
window.pageYOffset,
window.scrollY,
document.documentElement.scrollTop,
]);
// [^1] loose/strict scrolling to bottom details c.f.
// http://let.hatelabo.jp/noromanba/let/hLHUs7CEkec6
// you don't use `Number.MAX_SAFE_INTEGER`
// [0x7FFFFFFF, -1 >>> 1, 2 ** (32 - 1) - 1,].every(v => v === 2147483647) === true
// Firefox Desktop ignoring >Signed INT32
const MAX_SAFE_SIGNED_INT32 = -1 >>> 1;
const top = y ? 0 : MAX_SAFE_SIGNED_INT32;
// [^2] options c.f.
// https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollTo
window.scrollTo({ top, left: 0, behavior: 'smooth', });
//
})();
// DEV
//
// [1]: Signed INT32
// specs
// https://en.wikipedia.org/wiki/IEEE_754
// https://en.wikipedia.org/wiki/Single-precision_floating-point_format
//
// classical scrolling to bottom
/*
const Math.max(...[
document.documentElement.scrollHeight,
document.documentElement.clientHeight,
document.body.scrollHeight,
document.body.clientHeight,
]);
*/
//
// [2]: scroll* family
// window.scroll()
// https://developer.mozilla.org/en-US/docs/Web/API/Window/scroll
// window.scrollBy()
// https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollBy
//
// new scrolling features
// window.scrollByLines()
// https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollByLines
// window.scrollByPages()
// https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollByPages