繁体   English   中英

忽略全屏画布

[英]ignore full screen canvas

我在网页上全屏显示画布。 大小在processing.js中处理。

        <div id="canvasDiv">
            <canvas id="processingCanvas" data-processing-sources="resources/processing/canvas01.pde"> </canvas>
        </div>

画布后面是许多文字。 问题是我无法在iPad上滚动,因为画布在顶部。 有没有办法忽略画布,但仍将其显示在顶部? 这是当前的CSS:

#canvasDiv {
    position: absolute;
    left: 0;
    z-index: 999;
}



#processingCanvas {
    position: fixed;
    top: 0;
    left: 0;
}

这是让元素陷入基础元素的方法:

如果浏览器是Chrome,Firefox,Safari,Blackberry或Android,但不是IE或Opera,则可以使用指针事件告诉画布不要处理单击/触摸事件,然后单击/触摸将由底层元素处理。 因此,在CSS中:

 #topCanvas{ pointer-events: none; }

但是在IE和Opera中,您必须非常棘手:

  • 隐藏顶部画布,
  • 在底部元素上触发事件,
  • 显示顶部画布。

此代码显示了如何触发基础元素上的事件:

<!doctype html>
<html>
<head>
<link rel="stylesheet" type="text/css" media="all" href="css/reset.css" /> <!-- reset css -->
<script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>

<style>
body{ background-color: ivory; }
#wrapper{ width:200; height:200;}
#bottom{ position:absolute; top:0; left:0; width:200; height:200; background-color:red; }
#top{ position:absolute; top:0; left:0; width:200; height:200; background-color:blue; }
</style>

<script>
$(function(){

    $('#top').click(function (e) {
        $('#top').hide();
        $(document.elementFromPoint(e.clientX, e.clientY)).trigger("click");
        $('#top').show();
    });

    $("#bottom").click(function(){ alert("bottom was clicked."); });

}); // end $(function(){});
</script>

</head>

<body>
    <div id="wrapper">
        <canvas id="bottom"></canvas>
        <canvas id="top"></canvas>
    </div>
</body>
</html>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM