使用 Mootools Scroll 的一页网站 + jQuery 突出显示导航锚链接?
好吧,我距离解决问题还有大约 2 英寸,但现在我不知道如何继续。
开发站点: http://www.kendraschaefer.com/meilin
我正在使用 Mootools 和 jQuery同一页面来创建单页网站。 Mootools 处理页面滚动 - 页面在指定的 div 内上下滚动。
Jquery 处理所有其他效果。
问题是导航栏 - 我试图根据当前活动的 div 来突出显示导航项。
在意识到它并不能完全解决问题之前,我最终决定采用以下解决方案:
- MooTools 处理滚动
- Jquery 为单击的任何导航项分配“当前”类,并从任何其他导航项中删除“当前”类。
问题:我现在无法创建页内链接,因为页内链接没有以任何方式连接到导航。例如,在“主页”页面上,尝试单击内容区域中的“工作”或“团队”按钮 - 未选择适当的导航项目,并且我不知道如何使其工作。
也许我应该在滚动生效后通过 Mootools 添加类分配? (如果你知道怎么做,请分享!)
或者也许我应该修改 Jquery?
欢迎任何和所有解决方案!谢谢!
Okay, I'm about 2 inches away from solving my problem, and now I'm not sure how to proceed.
Dev site: http://www.kendraschaefer.com/meilin
I'm using Mootools and jQuery in the same page to create a one-page site. Mootools handles the page scrolling - page scrolls up and down within a specified div.
Jquery handles all other effects.
The problem is the navigation bar - I'm trying to get the nav items to highlight based on which div is currently active.
I finally settled on the following solution before realizing it doesn't quite cut it:
- MooTools handles scrolling
- Jquery assigns a "current" class to any nav item that's clicked, and removes the "current" class from any other nav item.
The problem: I now can't create in-page links, because in-page links aren't hooked up to the nav in any way. For example, on the "home" page, try clicking the "work" or "team" buttons in the content area - appropriate nav items aren't selected, and I don't know how to make that work.
Maybe I should add the class assignment via Mootools after the scroll takes effect? (If you know how, please share!)
Or maybe I should modify the Jquery?
Any and all solutions welcome! Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
scrollableLinks 与您当前的标记配合使用,以获取所有具有 href 的页面链接,并且它包含 # 并且它不仅仅是 #
在更高版本(如 1.2、1.3)中,您可以将其应用于所有锚链接,如下所示:
document. getElements("a[href~=#]")
另一种方法是创建一个简单的“导航”类,如果您希望链接充当导航类,只需执行
关于我们
- 进行通用的包罗万象可能会使常规锚点变得困难。更新的示例: http://www.jsfiddle.net/dimitar/WkTzr/6/ 其中第一个容器上的 TEAM 映像是复制顶部菜单链接的链接。
the scrollableLinks works with your current markup to fetch all page links that have a href and it contains # and it's not just #
in later versions like 1.2, 1.3 you could have just applied it to all anchor links like so:
document.getElements("a[href~=#]")
another way is to create a simple 'nav' class, and if you want a link to act as the nav ones, simply do
<a href="#about" class="nav">about us</a>
- doing a generic catch-all may make it difficult to have regular anchors.updated example: http://www.jsfiddle.net/dimitar/WkTzr/6/ where the TEAM image on first container is a link that replicates the top menu link.