Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/399.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript SVG getIntersectionList返回null_Javascript_Android_Svg_Android Browser - Fatal编程技术网

Javascript SVG getIntersectionList返回null

Javascript SVG getIntersectionList返回null,javascript,android,svg,android-browser,Javascript,Android,Svg,Android Browser,在SVG文件的上下文中,以下JavaScript: var svg = document.rootElement, hitRect, hits; hitRect = svg.createSVGRect(); hitRect.height = 1; hitRect.width = 1; hitRect.y = 100; hitRect.x = 100; hits = svg.getIntersectionList(hitRect, null); 始终将null分配给点击次数,无论是否存在任何

在SVG文件的上下文中,以下JavaScript:

var svg = document.rootElement, hitRect, hits;

hitRect = svg.createSVGRect();
hitRect.height = 1;
hitRect.width = 1;
hitRect.y = 100;
hitRect.x = 100;

hits = svg.getIntersectionList(hitRect, null);
始终将
null
分配给
点击次数
,无论是否存在任何交点(如果没有交点,则应为空节点列表)

有没有人偶然发现这个问题?在Android中测试SVG是否有已知的解决方法

测试版本:Android 4.0.3(emulator)和4.0.3(GALAXY Note SC-05D)上的Android默认浏览器。(谷歌浏览器)

编辑


我还尝试循环遍历所有元素(
document.getElementsByTagName(“*”
),使用
svg.checkIntersection
)测试每个元素,但没有成功
checkIntersection
刚刚为每个元素返回了
true

在测试iOS Safari时,我也遇到了这个问题,我试图在JSFIDLE上放置一个测试示例。FIDLE:
<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
   <rect id="r1" x="5" y="5" width="40" height="40"/>
   <rect id="r2" x="105" y="105" width="40" height="40"/>
   <rect id="r3" x="5" y="5" width="40" height="40"/>
   <rect id="rr" x="5" y="5" width="400" height="400" fill="red"/>
   <rect id="r4" x="5" y="5" width="40" height="40"/>
   <rect id="r5" x="5" y="5" width="40" height="40"/>
</svg>

<script type="text/javascript">

var isTouch = ('ontouchstart' in window) || ('DocumentTouch' in window && document instanceof DocumentTouch);
var downE = isTouch? 'touchstart' :'mousedown';
var moveE = isTouch? 'touchmove' :'mousemove';
var upE = isTouch? 'touchend' :'mouseup';

window.addEventListener(downE, startTest )
function startTest (evt) {
    setTimeout(function  () {

        var svg=document.querySelector('svg');
        var r = svg.createSVGRect();
        r.x = 20;
        r.y = 20;
        r.width = r.height = 44;
        var getIntersectionList = svg.getIntersectionList(r, null );
        var checkIntersection = svg.checkIntersection( document.querySelector('#r2'), r );
        var elementFromPoint = document.elementFromPoint(20,20);
        alert("getIntersectionList: "+getIntersectionList);
        alert("checkIntersection: "+checkIntersection);
        alert("elementFromPoint: "+elementFromPoint);

    },1000);

}
</script>
</body>
</html>
getIntersectionList: [object NodeList]
checkIntersection: false
elementFromPoint: [object SVGRectElement]
getIntersectionList: null
checkIntersection: true
elementFromPoint: [object SVGRectElement]
var el = document.elementFromPoint(x,y);