[英]Hide a HTML5 Canvas element
我嘗試使用HTML5 Canvas標簽,直到現在我設法做我想要的。 但現在我試圖隱藏淡入Canvas元素(上下文)。 返回的錯誤是context.fadeOut is not a function
。
在這里查看我的草稿: http : //jsfiddle.net/t46Ze/4/
謝謝你的幫助。
編輯>這里我最初想要的: http : //jsfiddle.net/t46Ze/15/
編輯>這里安德魯命題: http : //jsfiddle.net/t46Ze/16/ (附評論)
您試圖淡出畫布的2D上下文,而不是畫布元素本身。 相反淡出元素本身。
做$(canvas).fadeOut
而不是context.fadeOut
你可以完全按照你的方式繪制它,但相反,
我在畫布上嘗試了下面的代碼
<canvas id="newCanvas" style="display: none"></canvas>
您可能想嘗試使用jQuery。
<html>
<head>
<!-- Path to your jQuery core js library or you can use one from Google.
<script type="text/javascript" src="jquery.min.js" />
<!-- Path to your jQuery UI js library or you can use one from Google.
<script type="text/javascript" src="jquery-ui.min.js" />
</head>
<body>
<canvas id="myCanvas" ..>..</canvas>
</body>
</html>
當你想淡出時,只需致電:
$("#myCanvas").fadeOut(2500); // 2 seconds and a half, for example
還有其他“效果”,如:
$("#myCanvas").slideUp(1500); // 1 and a half seconds, for example
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.