是否有人知道是否存在插件或类似内容以实现此网站上的导航:http://discover.store.sony.com/tablet/#entertainment
我说的是悬停在屏幕顶部的底部部分时出现的向上和向下箭头。
答案 0 :(得分:1)
理论上,这不应该太难写自己。这是在鼠标悬停在页面的某些部分时实现箭头的起点。您只需要根据用户当前查看的部分处理将特定链接附加到箭头。
有关详细信息,请参阅评论。
<强> Fiddle 强>
请注意,在小提琴中我使用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
});
要处理这些链接,我猜你可能还会在页面的每个部分都有一组单独的箭头,因此它们链接到的目标几乎可以硬编码。