I have following code to scroll the desired section targeted by attr
$('html, body').animate({
scrollTop: $( attr).offset().top -300
}, 500)
Page successfully scrolls to that position in desktop but not in iPad. I will have to update the value from 300 to suitable values for iPad. How can i make it dynamic so that it works correctly in all the devices?