smoother scroll behavior after pagination clicks
This commit is contained in:
parent
3c5ac66af3
commit
f52d255fa6
@ -38,8 +38,8 @@
|
||||
pagesizeForm = wrapper.querySelector('#' + tableIdent + '-pagesize-form');
|
||||
|
||||
// take options into account
|
||||
if (options && options.scrollToTop) {
|
||||
window.scrollTo(0, 0);
|
||||
if (options && options.scrollTo) {
|
||||
window.scrollTo(options.scrollTo);
|
||||
}
|
||||
|
||||
if (options && options.horizPos && scrollTable) {
|
||||
@ -63,7 +63,16 @@
|
||||
pageLinks.forEach(function(link) {
|
||||
link.clickHandler = function(event) {
|
||||
var boundClickHandler = clickHandler.bind(this);
|
||||
boundClickHandler(event, { scrollToTop: true });
|
||||
var wrapperBoundingRect = wrapper.getBoundingClientRect();
|
||||
var options = {};
|
||||
if (wrapperBoundingRect.top < 160) {
|
||||
options.scrollTo = {
|
||||
top: (wrapper.offsetTop || 0) - 60,
|
||||
left: wrapper.offsetLeft || 0,
|
||||
behavior: 'smooth',
|
||||
};
|
||||
}
|
||||
boundClickHandler(event, options);
|
||||
}
|
||||
link.element.addEventListener('click', link.clickHandler);
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user