플러그인 공부중인데
window load에서만 제대로 작동합니다.
플러그인 내에서 window load 작성요령을 알고 싶습니다.
resize도 알려주시면 감사합니다.
Copy
(function($){ $.fn.parcon = function(option,callback){ if($.isFunction(option)){ callback = option; option = null; } $.fn.parcon.setting = { column: 4, margin: 10, padding: 15, background: "transparent" }; option = $.extend($.fn.parcon.setting,option); return this.each(function(){ var i = 0; $(this).find("li").each(function(){ var obJecty = $(this); var winW = $(window).width(); var thisIdx = $(this).index(); var thisPrevL = parseInt($(this).prev().css("left")); var thisPrevT = parseInt($(this).prev().css("top")); var prevW = $(this).prev().outerWidth(true); var thisMrg = option.margin; var thisPdd = option.padding; var lineLen = option.column; var backColor = option.background; $(this).css({ "padding" : thisPdd, "box-sizing": "border-box", "background-color": backColor, "position": "absolute", "top": 0, "left": 0 }); if (thisIdx < lineLen){ i++; if(thisIdx != 0){ $(this).css({"width": prevW, "left": (thisPrevL + prevW) + thisMrg, "top": thisMrg}); } else { $(this).css({"width": (winW - (thisMrg*(lineLen+1)))/lineLen, "left": thisMrg, "top": thisMrg}); } } else if(thisIdx >= lineLen ){ var topLi = $(this).parent().find("li").eq(thisIdx - lineLen); var topLiH = topLi.outerHeight(true); var topOff = topLi.offset(); var topOffT = topOff.top; if(i%lineLen != 0){ i++; $(this).css({"width": prevW, "left": (thisPrevL + prevW) + thisMrg, "top": (topOffT + topLiH) + thisMrg}); } else { i++; $(this).css({"width": prevW, "left": thisMrg, "top": (topOffT + topLiH) + thisMrg}); } } }); }); }})(jQuery);
답변 1개
채택된 답변
+20 포인트
9년 전
정확한 질문 내용은 잘 모르겠는데요....
window load 는
$(window).load(function(){
제이쿼리 내용
});
으로 사용하시면 됩니다.
현재 소스는
(function($){
제이쿼리 내용
});
인데 이것은
$(document).ready(function(){
제이쿼리 내용
});
와 같은 방식이고 축약형입니다.
jQuery ready와 load의 차이는
여기 참고해 보세요.
답변을 작성하려면 로그인이 필요합니다.