Step1:
Welcome to designers dairy blog, Here We are going to discuss, how to reset scroll position in a div using javascript
Step2:
Let us consider you have table-grid with pagination inside the scroll.When we are scrolling down and clicking the next or number 2 button.
it has to show the second set of data on top position but inthis case we have to move the scroller to top to view the contents.
Step3:
To tackling this problem, Calling this function after transition between view ,will reset my scroll position.
Step4:
function resetScrollPos(selector) {
var divs = document.querySelectorAll(selector);
for (var p = 0; p < divs.length; p++) {
if (Boolean(divs[p].style.transform)) { //for IE(10) and firefox
divs[p].style.transform = 'translate3d(0px, 0px, 0px)';
} else { //for chrome and safari
divs[p].style['-webkit-transform'] = 'translate3d(0px, 0px, 0px)';
}
}
}
resetScrollPos('.mblScrollableViewContainer');
Step5:
Enjoy Folks
Welcome to designers dairy blog, Here We are going to discuss, how to reset scroll position in a div using javascript
Step2:
Let us consider you have table-grid with pagination inside the scroll.When we are scrolling down and clicking the next or number 2 button.
it has to show the second set of data on top position but inthis case we have to move the scroller to top to view the contents.
Step3:
To tackling this problem, Calling this function after transition between view ,will reset my scroll position.
Step4:
function resetScrollPos(selector) {
var divs = document.querySelectorAll(selector);
for (var p = 0; p < divs.length; p++) {
if (Boolean(divs[p].style.transform)) { //for IE(10) and firefox
divs[p].style.transform = 'translate3d(0px, 0px, 0px)';
} else { //for chrome and safari
divs[p].style['-webkit-transform'] = 'translate3d(0px, 0px, 0px)';
}
}
}
resetScrollPos('.mblScrollableViewContainer');
Step5:
Enjoy Folks
No comments:
Post a Comment