Go Back   MacRumors Forums > Special Interests > Visual Media > Web Design and Development

Reply
 
Thread Tools Search this Thread Display Modes
Old May 25, 2010, 05: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, 05: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, 06: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, 03: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, 07: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, 02: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

Similar Threads
thread Thread Starter Forum Replies Last Post
Safari Tilt to scroll in iOS 8? Defender2010 iOS 7 26 May 12, 2014 03:04 AM
Safari freezes after trying to scroll (updated to 10.9) cramazing MacBook Air 3 Feb 28, 2014 05:03 PM
iPad: Is there a way to disable horizontal scroll in Safari? Yr Blues iPad 2 Jun 9, 2013 11:52 AM
Safari won't scroll... Tipsy McStagger MacBook Pro 4 Jul 31, 2012 09:54 AM
Zoom/Scroll not working in Safari now Sapphire08 OS X 10.8 Mountain Lion 0 Jul 27, 2012 07:52 AM

Forum Jump

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

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

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