Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Special Interests > Visual Media > Web Design and Development

Reply
 
Thread Tools Search this Thread Display Modes
Old May 25, 2010, 04:43 PM   #1
fernandovalente
macrumors 6502
 
Join Date: Aug 2008
Location: Third world **** hole, I mean, Brazil
Send a message via AIM to fernandovalente Send a message via MSN to fernandovalente
Scroll to anchor on Mobile Safari

I'm developing and website and I need it to scroll to an anchor. It needs to be animated, so I decided to use jQuery for that. I tried this:

Code:
function goToByScroll(id){
      $('html,body').animate({scrollTop: $("#"+id).offset().top},'slow');
}
It works perfectly on the desktop. On Mobile Safari it first goes to the top of the page, then it scrolls to the anchor I want it to scroll to. What's the trick to make it work on Mobile Safari?

Thanks in advanced
__________________
Check out the iPhone and Mac apps I developed.
iChat: fernandovalente [a] mac [d] com
Personal blog: www.fvalente.org
E-mail: fernando [a] fvalente [d] org
fernandovalente is offline   0 Reply With Quote
Old May 25, 2010, 04:59 PM   #2
angelwatt
Moderator emeritus
 
angelwatt's Avatar
 
Join Date: Aug 2005
Location: USA
I created a script called Gentle Anchors a bit back. I don't know how it works on mobile Safari, but could be worth a shot.

I don't use jQuery so can't say if there's any issues with your syntax. I have seen others trying to do this though, such as this one, but hard to say how well they work on mobile Safari.
angelwatt is offline   0 Reply With Quote
Old May 25, 2010, 05:04 PM   #3
fernandovalente
Thread Starter
macrumors 6502
 
Join Date: Aug 2008
Location: Third world **** hole, I mean, Brazil
Send a message via AIM to fernandovalente Send a message via MSN to fernandovalente
Thank you so much man! It's a pretty good script. It works perfectly on Mobile Safari. YOU SAVED MY LIFE!!! Thanks a lot for this GREAT script!
__________________
Check out the iPhone and Mac apps I developed.
iChat: fernandovalente [a] mac [d] com
Personal blog: www.fvalente.org
E-mail: fernando [a] fvalente [d] org
fernandovalente is offline   0 Reply With Quote
Old May 29, 2010, 02:43 PM   #4
fernandovalente
Thread Starter
macrumors 6502
 
Join Date: Aug 2008
Location: Third world **** hole, I mean, Brazil
Send a message via AIM to fernandovalente Send a message via MSN to fernandovalente
Quote:
Originally Posted by angelwatt View Post
I created a script called Gentle Anchors a bit back. I don't know how it works on mobile Safari, but could be worth a shot.

I don't use jQuery so can't say if there's any issues with your syntax. I have seen others trying to do this though, such as this one, but hard to say how well they work on mobile Safari.
I got a question. How may I call the function to scroll to an anchor from javascript?
__________________
Check out the iPhone and Mac apps I developed.
iChat: fernandovalente [a] mac [d] com
Personal blog: www.fvalente.org
E-mail: fernando [a] fvalente [d] org
fernandovalente is offline   0 Reply With Quote
Old May 29, 2010, 06:27 PM   #5
angelwatt
Moderator emeritus
 
angelwatt's Avatar
 
Join Date: Aug 2005
Location: USA
Quote:
Originally Posted by fernandovalente View Post
I got a question. How may I call the function to scroll to an anchor from javascript?
It wasn't really built for that, but I tweaked the code some to allow it since it didn't require much modification. The Gentle Anchors page has been updated to version 1.2. The example section on the page shows how to implement the new feature. I didn't do my normal testing across browsers, but I don't think there should be an issue.
angelwatt is offline   0 Reply With Quote
Old Jul 29, 2013, 01:18 PM   #6
lanativelea
macrumors newbie
 
Join Date: Jul 2013
Gentle Anchors ROCKS!

I just had to stop and thank Kendall Conrad for his amazing script that works so perfectly for iPhone Safari - I have tried many other solutions and they all came up short in one way or another. If you need to have precision scrolling to elements (and who doesn't when making a website work well in mobile) I highly recommend that you don't waste time as I did using other solutions. Here is the link again to Kendall's awesome script.

http://www.angelwatt.com/coding/gentle_anchors.php
lanativelea is offline   0 Reply With Quote

Reply
MacRumors Forums > Special Interests > Visual Media > Web Design and Development

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
How to make web site think I'm not on mobile Safari ycoidi2000 iPhone Tips, Help and Troubleshooting 10 Jun 10, 2013 07:01 AM
Sync'ing addresses to gMail, no Mobile Me Tearabite Mac OS X 10.7 Lion 4 Dec 22, 2011 08:34 PM
Scroll to the End in Safari pepi iPod touch 3 Jul 27, 2011 03:06 PM
OSX Reference Library on Mobile Safari? knightlie Mac Programming 3 Sep 13, 2010 12:58 AM
Apple Offers Clarification on Mobile Safari Anti-Phishing Feature MacRumors iOS Blog Discussion 42 Sep 16, 2009 04:24 AM


All times are GMT -5. The time now is 02:52 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC