드래그 컨트롤
define(function(require, exports, module) {})------------------------- 。
module.exports = {
AssistiveTouch: AssistiveTouch
};---------------------------------------------- , 。
2. 클릭 | | | 터치 위치 (호환)
function mousePosition(ev){
if(ev.targetTouches&&ev.targetTouches[0]){
return {x:ev.targetTouches[0].pageX, y:ev.targetTouches[0].pageY};
}
if(ev.touches&&ev.touches[0]){
return {x:ev.touches[0].pageX, y:ev.touches[0].pageY};
}
if(ev.changedTouches&&ev.changedTouches[0]){
return {x:ev.changedTouches[0].pageX, y:ev.changedTouches[0].pageY};
}
if(ev.pageX || ev.pageY){
return {x:ev.pageX, y:ev.pageY};
}
return {
x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,
y:ev.clientY + document.body.scrollTop - document.body.clientTop
};
}
3. 컨트롤 대상 자체
function AssistiveTouch(sets,clickFunc){ var atClass=(sets.atClass)?sets.atClass:“”, imgUrl=(sets.imgUrl)?sets.imgUrl:", // closeBtn=(sets.closeBtn)?sets.closeBtn:false; // clipH=(sets.clipH)?sets.clipH:0; // clipW = (sets.clipW)?sets.clipW:0, // autoSide=(sets.autoSide)?sets.autoSide:false; // $(atClass).css("position","fixed"); $(atClass).css("z-index","100"); $(atClass).append('
'); ---- if(imgUrl){ $(".assistive-touch-content").css("background-image","url('"+imgUrl+"')");} if(closeBtn){ $(atClass).append('
×'); } $(".assistive-touch-close-btn").on(" click mouseup touchend",function(e){ // window.event? window.event.cancelBubble = true : e.stopPropagation(); $(atClass).hide(); }); ---------------------------------------------------- $(atClass).on("mousedown touchstart",function(e){ var e=e||window.event; e.preventDefault(); var mousePos=mousePosition(e); $(this).attr("moving","true"); $(this).attr("offset-left",mousePos.x-$(this)[0].offsetLeft); $(this).attr("offset-top",mousePos.y-$(this)[0].offsetTop); $(this).attr("origin-left",mousePos.x); $(this).attr("origin-top",mousePos.y); })------------------------------------------------- $(atClass).on("mouseup touchend",function(e){ if($(this).attr("moving")!="true")return; var e=e||window.event; e.preventDefault(); var mousePos=mousePosition(e); $(this).[0].style.left = (mousePos.x-$(this).attr("offset-left"))+"px"; $(this)[0].style.top = (mousePos.y-$(this).attr("offset-top"))+"px"; })------------------------------------------------- $(atClass).on("mouseup touchend",function(e){ var e=e||window.event; e.preventDefault(); var windowHeight = document.documentElement.clientHeight||document.body.clientHeight; var windowWidth = document.documentElement.offsetWidth||document.body.offsetWidth; windowHeight += clipH; windowWidth += clipW; $(this).attr("moving","false"); var mousePos = mousePosition(e); $(this)[0].style.top = (mousePos.y-$(this).attr("offset-top"))+"px"; if(Math.abs(mousePos.x-$(this).attr("origin-left"))<=3||Math.abs(mousePos.y-$(this).attr("origin-top"))<=3){ $(this)[0].style.left = ($(this).attr("origin-left")-$(this).attr("offset-left"))+"px"; $(this)[0].style.top = ($(this).attr("origin-top")-$(this).attr("offset-top"))+"px"; $(this).click(function(e){ clickFunc($(".assistive-touch-content")[0],$(this)[0]); }); $(this).click(); return; } $(".assistive-touch-close-btn").removeClass("right").removeClass('top'); function sideOverflowFunc(t) { if(t[0].offsetLeft<0){ t[0].style.left = 0; } if((t[0].offsetTop+t[0].offsetHeight)>windowHeight){ t[0].style.top = (windowHeight - t[0].offsetHeight)+"px"; } if((t[0].offsetLeft+t[0].offsetWidth)>windowWidth){ t[0].style.left = (windowWidth - t[0].offsetWidth)+"px"; $(".assistive-touch-close-btn").addClass("right"); } }-------------------------------------------------------------------- function autoSideFunc(t){ if (!autoSide)return; if(t[0].offsetTopwindowHeight/10*9){ t.animate({top:(windowHeight-t[0].offsetHeight)+"px"},200); return; } if(t[0].offsetLeft+(t[0].offsetWidth/2)<=windowWidth/2){ t.animate({left:"0px"},200); }else{ t.animate({left:(windowWidth-t[0].offsetWidth)+"px"},200); $(".assistive-touch-close-btn").addClass("right"); } }-------------------------------------------------------------- sideOverflowFunc($(this)); autoSideFunc($(this)); })------------------------------------------------------------------ return $(atClass);-------------------------------------------------------- }
4.调用:
assTouch.AssistiveTouch({
atClass:".js_drap_img",
imgUrl:config.baseloc+"images/index/fenqi2_icon.png",
closeBtn:false,
autoSide:true,
clipH:-50
},function(content,self){
com.jumpUrl("lend/frontstage.html?productId=1&footer=1&productType=2",config.USERCERTIFICATION);
});
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.