html5手機刮刮卡效果_手指滑動刮刮卡特效



68 268 90



特效描述:html5 手機刮刮卡 手指滑動 刮刮卡特效,刮刮卡,中獎,canvas擦除效果

代碼結構

1. 引入JS

<script src="jquery-1.7.2.min.js" type="text/javascript"></script>

2. HTML代碼

<div class="bg">
     <img src="images/bg_01.jpg" />
</div>
<div class='jiangp'>
    <span>合肥學堂信息技術有限公司</span>
</div>
<canvas></canvas>
<script type="text/javascript">     
(function(bodyStyle){         
	bodyStyle.mozUserSelect = 'none';         
	bodyStyle.webkitUserSelect = 'none';           
	var img = new Image();         
	var canvas = document.querySelector('canvas');         
	canvas.style.backgroundColor='transparent';         
	canvas.style.position = 'absolute';           
	img.addEventListener('load',function(e){  
		var ctx;
		var w = $(window).width()*0.8, h =45; 
		var f=$(window).width()*0.4            
		var offsetX = canvas.offsetLeft, offsetY = canvas.offsetTop;             
		var mousedown = false;               
		function layer(ctx){
			ctx.beginPath();                
			ctx.fillStyle = 'gray';                 
			ctx.fillRect(0, 0, w, h); 
			ctx.beginPath();  
			ctx.font = "Bold 20px Arial"
			ctx.textAlign = "center";  
			ctx.fillStyle = "#fff"; 
			ctx.fillText("刮獎區", f, 30);                             
		}   
		function eventDown(e){                 
			e.preventDefault();                 
			mousedown=true;             
		}   
		function eventUp(e){                 
			e.preventDefault();                 
			mousedown=false;             
		}               
		function eventMove(e){                 
			e.preventDefault();                 
			if(mousedown){                     
				if(e.changedTouches){                         
					e=e.changedTouches[e.changedTouches.length-1];                     
				}                     
				var x = (e.clientX + document.body.scrollLeft || e.pageX) - offsetX || 0,                         
				y = (e.clientY + document.body.scrollTop || e.pageY) - offsetY || 0;                     
				with(ctx){                    
					beginPath()                     
					arc(x, y, 15, 0, Math.PI * 2);                         
					fill();                     
				}                
			}             
		}               
		canvas.width=w;             
		canvas.height=h;             
		canvas.style.backgroundImage='url('+img.src+')';             
		ctx=canvas.getContext('2d');             
		ctx.fillStyle='red';             
		ctx.fillRect(0, 0, w, h);             
		layer(ctx);               
		ctx.globalCompositeOperation = 'destination-out';               
		canvas.addEventListener('touchstart', eventDown);             
		canvas.addEventListener('touchend', eventUp);             
		canvas.addEventListener('touchmove', eventMove);             
		canvas.addEventListener('mousedown', eventDown);             
		canvas.addEventListener('mouseup', eventUp);             
		canvas.addEventListener('mousemove', eventMove);       
	});
	img.src ='images/ditu.png';
})(document.body.style);
</script> 
<div class="img">
    <img src='images/jp_03.png' />
    <img src='images/jp_05.png' />
    <img src='images/jp_07.png' />
</div>



用戶評論
大牛,別默默的看了,快登錄幫我點評一下吧!:)      登錄 | 注冊


熱門標簽: 拖動 拖拽 拖動插件 拖拽插件 滑動星星打分 其他 圖片拖動 圖片拖拽 抽獎 轉盤抽獎
?
×
×

注冊

官方QQ群

掃描上面二維碼加微信群

官方QQ群

jQuery/js討論群
群號:642649996
Css3+Html5討論群
群號:322131262

加群請備注:從官網了解到

湖北30选5开奖结果走势图表