jquery.appear-如何在画布上添加元素

jquery.appear - How to add on a canvas-element?

本文关键字:添加 元素 appear- jquery      更新时间:2023-09-26

如何将jquery.exappe-插件添加到此画布元素(id="pic")?脚本本身已经包含在html页面中,但如果元素在屏幕上,如何使画布图像仅可见?

<canvas id="pic"></canvas> 
<script type="text/javascript">    
var picData6 = whatever1
var options =  whatever2  
var ct6 = document.getElementById("pic").getContext("2d");
ct6.canvas.width = document.getElementById("pic").offsetWidth-4;
ct6.canvas.height = document.getElementById("pic").offsetHeight;
var Chart6  = new Chart(ct6).Line(picData6,options);
</script> 

似乎必须在某个地方添加.eappear()。但是在哪里呢?

非常感谢!

jQuery.appear只为您注册的元素提供自定义appeardisappear事件。

要将其添加到画布中,您可以执行以下操作:

// register the element with the plugin
$('#pic').appear();
// do this when it appears
$('#pic').on('appear', function(ev, elements) {
    // elements is an array of elements which are now visible on the page
});