有谁知道,如果存在一个插件或类似的实现导航这样的网站上:http://discover.store.sony.com/tablet/#entertainment箭头导航你在
我讲的向上和向下箭头悬停在上面PR时出现屏幕底部。
有谁知道,如果存在一个插件或类似的实现导航这样的网站上:http://discover.store.sony.com/tablet/#entertainment箭头导航你在
我讲的向上和向下箭头悬停在上面PR时出现屏幕底部。
从理论上讲,这应该不会太难写自己。这是在页面某些部分悬停时实现箭头的起点。您只需要根据用户当前正在查看的部分来处理附加到箭头的特定链接。
详情请参见注释。
注意的是,在小提琴我用event.pageX
和event.pageY
得到当前鼠标的位置,但在现实中,你应该使用event.screenX
和event.screenY
。因为小提琴中的演示作为一个小窗口嵌入到实际页面中,所以使用后者将无法工作。
// Define how wide the areas should be
// where the arrow appears
var top_nav_height = 70;
var bottom_nav_height = 70;
// Get some dimensions
var page_height = $(document).height();
var half_arrow_size = $('.uparrow').width()/2;
// Listen to the user moving their mouse
$(document).mousemove(function(event) {
// Where is the mouse?
var pos_y = event.screenY; // Distance from top of the page
var pos_x = event.screenX; // Distance from left of the page
var in_area;
// Leave a 5px space to hide the arrows when
// the pointer moves outside of the page
if (pos_y <= top_nav_height
&& pos_y > 5) {
in_area = 'top_nav';
}
else if (page_height - pos_y <= bottom_nav_height
&& page_height - pos_y > 5) {
in_area = 'bottom_nav';
}
// Show the arrow when in a nav area
switch(in_area) {
// We are in the top nav area
case 'top_nav':
// Show the .uparrow and have it follow the mouse
$('.uparrow')
.show()
.css({
top: pos_y - half_arrow_size,
left: pos_x - half_arrow_size
});
break;
// We are in the bottom nav area
case 'bottom_nav':
// Show the .bottomarrow and have it follow the mouse
$('.bottomarrow')
.show()
.css({
top: pos_y - half_arrow_size,
left: pos_x - half_arrow_size
});
break;
// We aren't in a nav area
default:
// Hide both arrows
$('.uparrow, .bottomarrow').hide();
}
// Decide where the arrow should link
});
要处理的环节,我想你也可以有单独的一组上你的页面的每个部分的箭头,让他们链接到目标几乎可以被硬编码。
谢谢Elise!这是一个非常好的起点。如果你只能解释如何使用硬编码链接,或者如何获取当前部分,然后使用该href作为链接。问题在于我无法获得当前的部分href,因为它与skrollr.js冲突,后者是我用于本网站的插件。如果你有兴趣,这里是链接:http://m10.auroralighting.com/m10V2/index.html – suludi
更新:有趣,你说我应该event.page改变event.screen,但它仅与页作品,如果我使用屏幕,行为不符合预期。 – suludi
更新-2:不幸的是,它不会工作。至少它不会工作,你可以检查上面的链接,箭头只显示在网站的顶部,就是这样。我想这是关于使用页面(X,Y),但如果使用屏幕,我根本没有箭头。 – suludi
滚动时查看地址栏。站点的每个部分都将在URL后更改'#'。 – M1K1O
这个插件是在这里你链接的页面: 看到这个页面上的HTML获取如何使用它。 – lexasss