Reputation: 682
I am using a snippet of code that I found here:
Simple jQuery scroll to anchor up or down the page...?
I have it working fine but I get a quick flicker of the initial screen each time I click to scroll. I modified the script to work on a div instead of another anchor.
Does anyone have any idea why this is happening?
Thanks
http://www.mniac.com/portfolio/
Upvotes: 2
Views: 1047
Reputation: 3273
After testing some things in console I think (99% certain) this problem is be caused by you placing the the anchor href as '#.
You have a few options:
1) Replace the Anchor tags with something else. If you replace the the anchors with just P tags for example, and change your jquery to work off p.[class] rather than a.[class] it should fix the problem. (You can keep the same anchor styling by having cursor:pointer;
in your CSS to make it appear like a link when the mouse is over the link)
2) Prevent the default action of the link. Add return false
in your links eg <a class="work" href="#" onclick="return false;">Work</a>
The reason I think this may be the problem is because when you click an anchor that is "#" it will default take you to the top of the page, so I think it's taking you to the top of the page quickly, then returning and scrolling to the destination.
Upvotes: 3