如何将同位素应用于svg节点 [英] How to apply isotope to svg nodes

查看:128
本文介绍了如何将同位素应用于svg节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于大量元素(> 5000),我想将同位素应用于SVG,而不是应用于HTML节点。节点表示为:

 < rect class =nodewidth =2height =2/> ; 

我使用'.node'作为项目选择器,但同位素似乎找不到元素发生。任何提示,如果这是可能的,或者如果库不能应用于SVG元素?



这里的测试用例: https://jsfiddle.net/geraldo/bL25f73a/

解决方案<

 我已经看过Isotope的源代码,不幸的是它看起来像是明确排除了SVG。 elems.forEach(function(elem){
//检查elem是否为实际元素
if(!(elem instanceof HTMLElement)){
return;
}

https://github.com/metafizzy/isotope/blob/master/dist/isotope.pkgd.js#L653



只是为了验证,我做了 $(rect)[0] instanceof HTMLElement ,并返回false。


Because of a big amount of elements (>5000), I'd like to apply isotope to SVG and not to HTML nodes. The nodes are represented as:

<rect class="node" width="2" height="2"/>

I use '.node' as item selector but isotope doesn't seem to find the elements and nothing happens. Any hint if this could be possible or if the library can't be applied to SVG elements?

Here the test case: https://jsfiddle.net/geraldo/bL25f73a/

解决方案

I've taken a look at the Isotope source code, unfortunately it looks like it's explicitly excluding SVG.

  elems.forEach( function( elem ) {
    // check that elem is an actual element
    if ( !( elem instanceof HTMLElement ) ) {
      return;
    }

https://github.com/metafizzy/isotope/blob/master/dist/isotope.pkgd.js#L653

Just to verify, I did $("rect")[0] instanceof HTMLElement and it's returning false.

这篇关于如何将同位素应用于svg节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆