It seems android is more annoying than ie when it comes to this (for me at least ) The problem is that the JQuery scrollTop works on every device except android when it comes to overflow beind set to auto, or scroll. There is a workaround that is supposed to work, but it seems it doesn't for me. This is the workaround:
[syntax=javascript]
$("#chat_container").css('overflow', 'hidden');
$("#chat_container").scrollTop($("#chat_container")[0].scrollHeight);
$("#chat_container").css('overflow', 'auto');[/syntax]
It seems that the css is executing before the scrolltop, even with a delay() added to setting overflow back to auto. Without setting overflow back to auto, the scroll works, but users can't scroll because the overflow is now hidden...any ideas would be greatly appreciated
PS: Any attempts to find the location of scrollTop will be useless because android has a bug where it is always 0.
JQuery scrollTop issues for android
-
- Posts: 205
- Joined: Mon Jul 09, 2012 11:13 pm
JQuery scrollTop issues for android
<?php while(!$succeed = try()); ?>
Re: JQuery scrollTop issues for android
You've probably tried this already, but this guy seems to have a working solution:
http://blog.jonathanargentiero.com/?p=134
[syntax=javascript]
if (navigator.userAgent.match(/(iPod|iPhone|iPad|Android)/)) {
window.scrollTo(200,100) // first value for left offset, second value for top offset
}else{
$('html,body').animate({
scrollTop: 100,
scrollLeft: 200
}, 800, function(){
$('html,body').clearQueue();
});
}[/syntax]
http://blog.jonathanargentiero.com/?p=134
[syntax=javascript]
if (navigator.userAgent.match(/(iPod|iPhone|iPad|Android)/)) {
window.scrollTo(200,100) // first value for left offset, second value for top offset
}else{
$('html,body').animate({
scrollTop: 100,
scrollLeft: 200
}, 800, function(){
$('html,body').clearQueue();
});
}[/syntax]
The reason is because the mobile ios doesn’t know what $(‘html,body’)
is you have to animate $(“body”) instead.
-
- Posts: 205
- Joined: Mon Jul 09, 2012 11:13 pm
Re: JQuery scrollTop issues for android
Thanks for the suggestion. I will try this after I get off work but at a quick glance, it looks like it will need the scrollTop of the div since it was originally meant for html/body.
<?php while(!$succeed = try()); ?>
Re: JQuery scrollTop issues for android
Yes it appears that without knowing the distance left to scroll, that method is impossible to use for my purposes
I'm going to experiment with it a bit more and let you know how it goes. If there are any more suggestions I'd love to try them.
PS: It's EG. It was an old name based on a site I made but ended up selling so it kind of got old.
I'm going to experiment with it a bit more and let you know how it goes. If there are any more suggestions I'd love to try them.
PS: It's EG. It was an old name based on a site I made but ended up selling so it kind of got old.
<?php while(!$succeed = try()); ?>
Re: JQuery scrollTop issues for android
I see.
It's a shame Jacek isn't here. He could change your username.
It's a shame Jacek isn't here. He could change your username.
Re: JQuery scrollTop issues for android
Yea, but its ok. So I've figured out the issue. The css does not get executed before the scroll, rather, setting overflow back to auto resets it to scroll back to the top. I'm completely stumped as for what to do now.
EDIT: The issue seems to be the android browser. FireFox for android has a problem where it only scrolls partially down. Opera for android has no issue with this. I did more research and tried all of the popular open source chats and they all result in the same. It appears that there is no solution for this issue.
EDIT: The issue seems to be the android browser. FireFox for android has a problem where it only scrolls partially down. Opera for android has no issue with this. I did more research and tried all of the popular open source chats and they all result in the same. It appears that there is no solution for this issue.
<?php while(!$succeed = try()); ?>