How to apply isotope to svg nodes

核能气质少年 提交于 2019-12-08 09:07:27

问题


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/


回答1:


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.



来源:https://stackoverflow.com/questions/37624854/how-to-apply-isotope-to-svg-nodes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!