jquery.appear - 如何在canvas-element上添加?

时间:2014-04-11 16:17:16

标签: javascript jquery image canvas appearance

如何将 jquery.appear -Plugin添加到此canvas元素(id =" pic")?脚本本身已包含在html页面中,但是如果元素在屏幕上,如何使canvas-image只显示?

<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> 

似乎必须在某处添加 .appear()。但在哪里?

非常感谢!

1 个答案:

答案 0 :(得分:0)

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

});