I want to implement window.scrollTo(x,y) functionality for iPad. It works in desktop but does not work for iPad. There are certain solutions already provided here and here which did not work for me.
I have implemented these solutions as below:
Component markup:
<aura:handler name="render" value="{!this}" action="{!c.onRender}"/>
Controller:
onRender : function(component, event, helper){
var scrollPosition = component.get('v.scrollPosition');
if($A.get("$Browser.isIPad")){
var container = document.getElementById("scrollerDiv");//This is outermost div of the outermost component.
setInterval(function() {
container.scrollTop += 1;
}, 20);
//ANOTHER TRY
/*var x = window.setTimeout(function() {
window.scrollTo(0, scrollPosition);
clearTimeout(x);
}, 0);*/
//ANOTHER TRY
//var scrollerDiv = document.getElementById("scrollerDiv");
//scrollerDiv.scrollTop = 0;
}
else{
window.scrollTo(0, scrollPosition); //Works in desktop.
}
}