1
我想在下面的教程中所描述重新创建以下类型的滚动缩略图导航的隐藏:试图创建滚动水平缩略图导航是在左边在不使用时
http://tympanus.net/codrops/2010/05/10/scrollable-thumbs-menu/
我需要我的拇指从左侧水平滑出。我已经尽最大努力修改了代码,但我无法实现它的功能。 (认为问题出现在jQuery的前三分之一)。
这是我要约会:
HTML
<ul class="menu" id="menu">
<li>
<a href="#"></a>
<div class="sc_menu_wrapper">
<div class="sc_menu">
<a href="#"><img src="images/gallery/1.jpg" alt=""/></a>
<a href="#"><img src="images/gallery/2.jpg" alt=""/></a>
<a href="#"><img src="images/gallery/3.jpg" alt=""/></a>
<a href="#"><img src="images/gallery/4.jpg" alt=""/></a>
<a href="#"><img src="images/gallery/5.jpg" alt=""/></a>
</div>
</div>
</li>
</ul>
CSS
/* Navigation Style */
ul.menu{
position: fixed;
top: 0px;
left:0px;
width: 100%;
}
ul.menu li{
position:relative;
width: 100%
}
ul.menu li > a{
position:absolute;
top:300px;
left:0px;
width:40px;
height:200px;
background-color:#e7e7e8;
}
/* Thumb Scrolling Style */
div.sc_menu_wrapper {
position: absolute;
right: 0px;
height: 220px;
overflow: hidden;
top: 300px;
left:0px;
visibility:hidden;
}
div.sc_menu {
height: 200px;
visibility:hidden;
}
.sc_menu a {
display: block;
background-color:#e7e7e8;
}
.sc_menu img {
display: block;
border: none;
opacity:0.3;
filter:progid:DXImageTransform.Microsoft.Alpha(opacity=30);
}
JQUERY
$(function(){
// function to make the thumbs menu scrollable
function buildThumbs($elem){
var $wrapper = $elem.next();
var $menu = $wrapper.find('.sc_menu');
var inactiveMargin = 220;
// move the scroll down to the beggining (move as much as the height of the menu)
$wrapper.scrollRight($menu.outerHeight());
//when moving the mouse up or down, the wrapper moves (scrolls) up or down
$wrapper.bind('mousemove',function(e){
var wrapperWidth = $wrapper.width();
var menuWidth = $menu.outerWidth() + 2 * inactiveMargin;
var top = (e.pageX - $wrapper.offset().right) * (menuWidth - wrapperWidth)/wrapperWidth - inactiveMargin;
$wrapper.scrollRight(right+10);
});
}
var stacktime;
$('#menu li > a').bind('mouseover',function() {
var $this = $(this);
buildThumbs($this);
var pos = $this.next().find('a').size();
var f = function(){
if(pos==0) clearTimeout(stacktime);
$this.next().find('a:nth-child('+pos+')').css('visibility','visible');
--pos;
};
// each thumb will appear with a delay
stacktime = setInterval(f , 50);
});
/// on mouseleave of the whole <li> the scrollable area is hidden
$('#menu li').bind('mouseleave',function() {
var $this = $(this);
clearTimeout(stacktime);
$this.find('.sc_menu').css('visibility','hidden').find('a').css('visibility','hidden');
$this.find('.sc_menu_wrapper').css('visibility','hidden');
});
// when hovering a thumb, change its opacity
$('.sc_menu a').hover(
function() {
var $this = $(this);
$this.find('img')
.stop()
.animate({'opacity':'1.0'},400);
},
function() {
var $this = $(this);
$this.find('img')
.stop()
.animate({'opacity':'0.3'},400);
}
);
});
想知道一些鹰眼也许能够指出我在哪里我错了。由于我对JQuery的知识是有限的,我猜它在那里。
我真的很感谢任何花时间看这个的人。
谢谢!
天啊太感谢你非常忙之中抽出时间来帮我整理了这一点。 (我不相信这个社区的人的慷慨)。我将在今天晚上在我的网站上工作,如果/当它运行时,我会回来向您提供正当的赞誉(复选标记和向上箭头)。 而这jsfiddle网站看起来不可思议。非常感谢您分享链接。我显然必须考虑这个资源。 我可以吻你湿的小鼻子,Fudgey :)再次感谢你。 – heathwaller 2010-06-18 19:09:05
三角洲嘻嘻,欢迎您:) – Mottie 2010-06-18 21:39:46
嗨Fudgey, 我试过了,它完美的工作......从右侧出来,向左开放。我知道你已经完成了大量的工作 - 如果你只是提供一些建议,我应该使用哪个JQuery CSS位置选择器,以便从左侧打开,向右走(希望这是有道理的?) - 这是这个项目所需要的。它是$(选择器).offset()?我从未使用过这些选择器。无论如何,我都会继续在这里工作,如果我成功了,就会发布我的结果。 – heathwaller 2010-06-19 01:43:36