Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
-2
rated 0 times [  0] [ 2]  / answers: 1 / hits: 89178  / 11 Years ago, mon, october 21, 2013, 12:00:00

I am working on a mobile hybrid application.



In my html page, I have 3 tabs. When clicking a tab, the content of the scrollable div gets changed. My problem is when I scroll down the content of div (view) and click another tab, the content disappears (but the content is there). Please help me so I can reset the div scroll position when clicking any tab.



Please give me suggestions only with JavaScript or CSS, not with JQuery as I am not using the JQuery library.


More From » html

 Answers
21

Finally this worked for me



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');


Calling this function after transition between view ,will reset my scroll position.


[#74841] Saturday, October 19, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
muhammadbrandend

Total Points: 670
Total Questions: 95
Total Answers: 97

Location: Saint Vincent and the Grenadines
Member since Sat, Sep 11, 2021
3 Years ago
;