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');
|
pagesizeForm = wrapper.querySelector('#' + tableIdent + '-pagesize-form');
|
||||||
|
|
||||||
// take options into account
|
// take options into account
|
||||||
if (options && options.scrollToTop) {
|
if (options && options.scrollTo) {
|
||||||
window.scrollTo(0, 0);
|
window.scrollTo(options.scrollTo);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options && options.horizPos && scrollTable) {
|
if (options && options.horizPos && scrollTable) {
|
||||||
@ -63,7 +63,16 @@
|
|||||||
pageLinks.forEach(function(link) {
|
pageLinks.forEach(function(link) {
|
||||||
link.clickHandler = function(event) {
|
link.clickHandler = function(event) {
|
||||||
var boundClickHandler = clickHandler.bind(this);
|
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);
|
link.element.addEventListener('click', link.clickHandler);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user