本文介绍了同位素定位后查找目标位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将David Desandros Isotope 用于新站点,但是现在看来我无法使用jquery找到每个元素的位置.具体来说,我想在悬停上附加一个工具提示,但通常我想知道在同位素格式化它们后如何获取每个锚点的position().

I'm using David Desandros Isotope for a new site, but now it seems I'm unable to find each elements position using jquery. Specifically I'm trying to attach a tooltip on hover, but generally I'd like to know how to get the position() of each anchor after Isotope has formatted them.

到目前为止,每个元素的left,margin-left,position().left以及我能想到的所有其他定位属性都显示为"0".

As of now each element displays a '0' for left, margin-left, position().left, and every other positioning property I could think of.

推荐答案

有关 itemPositionDataEnabled 的同位素文档,请参见

See Isotope docs for itemPositionDataEnabled

$('#container').isotope({
  itemSelector: '.element',
  itemPositionDataEnabled: true
})
// log position of each item
.find('.element').each(function(){
  var position = $(this).data('isotope-item-position');
  console.log('item position is x: ' + position.x + ', y: ' + position.y  );
});

这篇关于同位素定位后查找目标位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 14:02