2014-05-20 20 views
1

我实际上正在为wordpress开发一个小画廊插件。如何将注意力集中在刚刚失去它的DIV上

它使用jQuery多带几个插件: - JScrollPane的 - Hoverintent

我用JScrollPane中,以取代浏览器提供的丑陋滚动条,并有箭头滚动图像。

所有的图像排列在一行上。

事情是我希望画廊可以用键盘上的箭头键滚动。

所以javascript代码如下所示:

$(document).ready (function() { 

    $('.darkenjquery').bind('touchstart', function() { 
     $(this).find('img').fadeTo(200, 0.3); 
     $(this).find('span').css('z-index',3); 
    }).bind('touchend', function() { 
     $('body').find('img').fadeTo(200, 1); 
     $('body').find('span').css('z-index',1); 
    }).hoverIntent(function() { 
     $(this).find('img').fadeTo(200, 0.3); 
     $(this).find('span').css('z-index',3); 
    }, function() { 
     $(this).find('img').fadeTo(200, 1); 
     $(this).find('span').css('z-index',1); 
    }); 

    $('#oupsmangallery').on('blur',function() { 
     $('#oupsmangallery').trigger("focus"); 
    }); 

    $('#oupsmangallery').jScrollPane({showArrows: true, hideFocus: true}); 

    $('#oupsmangallery').trigger("focus"); 

}); 

由插件生成的HTML代码是类似这样的:

<p class='explain'>Vous pouvez faire défiler la galerie avec les flèches gauche et droite du clavier. En positionnant le curseur de votre souris sur une image, la légende apparaitra</p> 
<div id='oupsmangallery'> 
<table id='gallery'><tbody><tr> 
<td class="galleryelement"><div class="darkenjquery"> 
<img class="galleryimage" src="http://192.168.10.14/wp-content/uploads/2014/03/site_000_christiane_taubira_unnamed-750x500.jpg" alt=""><span class="legend">2013 - intervention de Madame Christiane Taubira, garde des seaux, dans le cadre du projet litt&eacute;raire Images de femmes des jeunes &eacute;crivains des ateliers d&#039;&eacute;criture &quot;La Cite Des Mots&quot; </span></div></td> 
</tr></tbody></table> 
</div> 

中有更大量的细胞(当然)桌子。

第一个关注焦点的人是ID为“oupsmangallery”的div,效果非常好。但是,当这个div失去焦点时,模糊事件被触发,但div不会回到焦点。

我在这里错过了什么?

非常感谢您的回答。

+0

你有这个问题的jsfiddle吗? –

回答

0

而不是调用模糊焦点()直接调用它使用settimeout()1到10毫秒超时应该是足够的。

相关问题