text: +(function(w){
  	w.damu = {};
  	w.damu.css=function (node,type,val){
  			if(typeof node ==="object" && typeof node["transform"] ==="undefined" ){
  				node["transform"]={};
  			}
  			
  			if(arguments.length>=3){
  				//设置
  				var text ="";
  				node["transform"][type] = val;
  				
  				for( item in node["transform"]){
  					if(node["transform"].hasOwnProperty(item)){
  						switch (item){
  							case "translateX":
  							case "translateY":
  								text +=  item+"("+node["transform"][item]+"px)";
  								break;
  							case "scale":
  								text +=  item+"("+node["transform"][item]+")";
  								break;
  							case "rotate":
  								text +=  item+"("+node["transform"][item]+"deg)";
  								break;
  						}
  					}
  				}
  				node.style.transform = node.style.webkitTransform = text;
  			}else if(arguments.length==2){
  				//读取
  				val =node["transform"][type];
  				if(typeof val === "undefined"){
  					switch (type){
  						case "translateX":
  						case "translateY":
  						case "rotate":
  							val =0;
  							break;
  						case "scale":
  							val =1;
  							break;
  					}
  				}
  				return val;
  			}
  		}
  	w.damu.carousel=function (arr){
  				//布局
  				var carouselWrap = document.querySelector(".carousel-wrap");
  				if(carouselWrap){
  					var pointslength = arr.length;
  					
  					//无缝
  					var needCarousel = carouselWrap.getAttribute("needCarousel");
  					needCarousel = needCarousel == null?false:true;
  					if(needCarousel){
  						arr=arr.concat(arr);
  					}
  					
  					
  					var ulNode = document.createElement("ul");
  					damu.css(ulNode,"translateZ",0);
  					var styleNode = document.createElement("style");
  					ulNode.classList.add("list");
  					for(var i=0;i<arr.length;i++){
  						ulNode.innerHTML+='<li><a href="javascript:;"><img src="'+arr[i]+'"/></a></li>';
  					}
  					styleNode.innerHTML=".carousel-wrap > .list > li{width: "+(1/arr.length*100)+"%;}.carousel-wrap > .list{width: "+arr.length+"00%}";
  					carouselWrap.appendChild(ulNode);
  					document.head.appendChild(styleNode);
  					
  					var imgNodes = document.querySelector(".carousel-wrap > .list > li > a >img");
  					setTimeout(function(){
  						carouselWrap.style.height=imgNodes.offsetHeight+"px";
  					},100)
  					
  					var pointsWrap = document.querySelector(".carousel-wrap > .points-wrap");
  					if(pointsWrap){
  						for(var i=0;i<pointslength;i++){
  							if(i==0){
  								pointsWrap.innerHTML+='<span class="active"></span>';
  							}else{
  								pointsWrap.innerHTML+='<span></span>';
  							}
  						}
  						var pointsSpan = document.querySelectorAll(".carousel-wrap > .points-wrap > span");
  					}
  					
  					
  					
  					/*滑屏
  					 * 	1.拿到元素一开始的位置
  					 * 	2.拿到手指一开始点击的位置
  					 * 	3.拿到手指move的实时距离
  					 * 	4.将手指移动的距离加给元素
  					 * */
  					/*
  					 * 防抖动
  					 * 
  					 * 1.判断用户首次滑屏的方向
  					 * 2.如果是x轴
  					 * 		以后不管用户怎么滑都会抖动
  					 * 3.如果是y轴
  					 * 		以后不管用户怎么滑都不会抖动	
  					 * */
  					var index =0;
  					//手指一开始的位置
  					var startX = 0;
  					var startY = 0;
  					//元素一开始的位置
  					var elementX = 0;
  					var elementY = 0;
  					//var translateX =0;
  					
  					//首次滑屏的方向
  					var isX = true;
  					var isFirst = true;
  					
  					carouselWrap.addEventListener("touchstart",function(ev){
  						ev=ev||event;
  						var TouchC = ev.changedTouches[0];
  						ulNode.style.transition="none";
  						
  						//无缝
  						if(needCarousel){
  							var index = damu.css(ulNode,"translateX")/document.documentElement.clientWidth;
  							if(-index === 0){
  								index = -pointslength;
  							}else if(-index ==(arr.length-1)){
  								index = -(pointslength-1)
  							}
  							damu.css(ulNode,"translateX",index*document.documentElement.clientWidth)
  						}
  						
  						
  						
  						startX=TouchC.clientX;
  						startY=TouchC.clientY;
  						elementX=damu.css(ulNode,"translateX");
  						elementY=damu.css(ulNode,"translateY");
  						
  						//清楚定时器
  						clearInterval(timer);
  						
  						isX = true;
  						isFirst = true;
  					})
  					carouselWrap.addEventListener("touchmove",function(ev){
  						//看门狗  二次以后的防抖动
  						if(!isX){
  							//咬住
  							return;
  						}
  						ev=ev||event;
  						var TouchC = ev.changedTouches[0];
  						var nowX = TouchC.clientX;
  						var nowY = TouchC.clientY;
  					    var disX = nowX - startX;
  					    var disY = nowY - startY;
  					    
  					    //首次判断用户的华东方向
  					    if(isFirst){
  					    	isFirst = false;
  					    	//判断用户的滑动方向
  					    	//x ---> 放行
  					    	//y ---> 首次狠狠的咬住，并且告诉兄弟 下次也给我咬住
  					    	if(Math.abs(disY)>Math.abs(disX)){
  						    	//y轴上滑
  						    	isX = false;
  						    	//首次防抖动
  						    	return;
  						    }
  					    }
  					    
  						damu.css(ulNode,"translateX",elementX+disX);
  					})
  					carouselWrap.addEventListener("touchend",function(ev){
  						ev=ev||event;
  					    index = damu.css(ulNode,"translateX")/document.documentElement.clientWidth;
  						index = Math.round(index);
  						
  						if(index>0){
  							index=0;
  						}else if(index<1-arr.length){
  							index=1-arr.length;
  						}
  						
  						xiaoyuandian(index);
  						
  						ulNode.style.transition=".5s transform";
  						damu.css(ulNode,"translateX",index*(document.documentElement.clientWidth));
  						
  						if(needAuto){
  							auto();
  						}
  					})
  				
  					//自动轮播
  					var timer =0;
  					var needAuto = carouselWrap.getAttribute("needAuto");
  					needAuto = needAuto == null?false:true;
  					if(needAuto){
  						auto();
  					}
  					function auto(){
  						clearInterval(timer);
  						timer=setInterval(function(){
  							if(index == 1-arr.length){
  								ulNode.style.transition="none";
  								index = 1-arr.length/2;
  								damu.css(ulNode,"translateX",index*document.documentElement.clientWidth);
  							}
  							
  							setTimeout(function(){
  								console.log(index)
  								index--;
  								ulNode.style.transition="1s transform";
  								xiaoyuandian(index);
  								damu.css(ulNode,"translateX",index*document.documentElement.clientWidth);
  							},50)
  						},2000)
  					}
  					
  					function xiaoyuandian(index){
  						if(!pointsWrap){
  							return;
  						}
  						for(var i=0;i<pointsSpan.length;i++){
  							pointsSpan[i].classList.remove("active");
  						}
  						pointsSpan[-index%pointslength].classList.add("active");
  					}
  				}
  			}
  	w.damu.dragNav=function(){
  		//滑屏区域
  		var wrap = document.querySelector(".damu-nav-drag-wrapper");
  		//滑屏元素
  		var item = document.querySelector(".damu-nav-drag-wrapper .list");
  		
  		//元素一开始的位置  手指一开始的位置
  		var startX=0;
  		var elementX =0;
  		var minX = wrap.clientWidth - item.offsetWidth;
  		//快速滑屏的必要参数
  		var lastTime =0;
  		var lastPoint =0;
  		var timeDis =1 ;
  		var pointDis =0;
  		wrap.addEventListener("touchstart",function(ev){
  			ev=ev||event;
  			var touchC = ev.changedTouches[0];
  			
  			startX = touchC.clientX;
  			elementX = damu.css(item,"translateX");
  			
  			item.style.transition="none";
  			
  			lastTime = new Date().getTime();
  			lastPoint = touchC.clientX;
  			//lastPoint = damu.css(item,"translateX");
  			
  			//清除速度的残留
  			pointDis=0;
  			item.handMove = false;
  		})
  		
  		wrap.addEventListener("touchmove",function(ev){
  			ev=ev||event;
  			var touchC = ev.changedTouches[0];
  			var nowX = touchC.clientX;
  			var disX = nowX - startX;
  			var translateX = elementX+disX;
  			
  			
  			var nowTime =new Date().getTime();
  			var nowPoint = touchC.clientX;
  			timeDis = nowTime - lastTime;
  			pointDis = nowPoint - lastPoint;
  			
  			lastTime = nowTime;
  			lastPoint = nowPoint;
  			
  			/*手动橡皮筋效果
  			 * 
  			 * 在move的过程中，每一次手指touchmove真正的有效距离慢慢变小，元素的滑动距离还是在变大
  			 * 
  			 * pointDis：整个手指touchmove真正的有效距
  			 * 
  			 * translateX = damu.css(item,"translateX") + pointDis*scale;!!!
  			 * 
  			 * */
  			if(translateX>0){
  				item.handMove = true;
  				var scale = document.documentElement.clientWidth/((document.documentElement.clientWidth+translateX)*1.5);
  				translateX = damu.css(item,"translateX") + pointDis*scale;
  			}else if(translateX<minX){
  				item.handMove = true;
  				var over = minX - translateX;
  				var scale = document.documentElement.clientWidth/((document.documentElement.clientWidth+over)*1.5);
  				translateX = damu.css(item,"translateX") + pointDis*scale;
  			}
  			damu.css(item,"translateX",translateX);
  		})
  		
  		wrap.addEventListener("touchend",function(ev){
  			var translateX = damu.css(item,"translateX");
  			if(!item.handMove){
  				//快速滑屏
  				//速度越大  位移越远
  				var speed = pointDis/timeDis;
  				speed = Math.abs(speed)<0.5?0:speed;
  				var targetX = translateX + speed*200;
  				var time = Math.abs(speed)*0.2;
  				time = time<0.8?0.8:time;
  				time = time>2?2:time;
  				//快速滑屏的橡皮筋效果
  				var bsr="";
  				if(targetX>0){
  					targetX=0;
  					bsr = "cubic-bezier(.26,1.51,.68,1.54)";
  				}else if(targetX<minX){
  					targetX = minX;
  					bsr = "cubic-bezier(.26,1.51,.68,1.54)";
  				}
  				item.style.transition=time+"s "+bsr+" transform";
  				damu.css(item,"translateX",targetX);
  			}else{
  				//手动橡皮筋效果
  				item.style.transition="1s transform";
  				if(translateX>0){
  					translateX=0;
  					damu.css(item,"translateX",translateX);
  				}else if(translateX<minX){
  					translateX = minX;
  					damu.css(item,"translateX",translateX);
  				}
  				
  			}
  		})
  	}
  })(window)
  