-
Notifications
You must be signed in to change notification settings - Fork 11
/
jquery.scrollLoading.min.js
1 lines (1 loc) · 1.17 KB
/
jquery.scrollLoading.min.js
1
(function(a){var b;a.fn.scrollLoading=function(c){return this.each(function(){b.init(a(this),c)})};b=a.scrollLoading={more:true,init:function(c,d){this.outer=c;this.appendTo=d.appendTo;this.judgeBy=d.appendTo||this.appendTo;this.ratio=d.ratio||0.9;this.ajaxData=d.ajaxData||{};if("undefined"===typeof this.ajaxData.dataType||!a.inArray(this.ajaxData.dataType,("html","json"))){this.ajaxData.dataType="html"}this.tmp_success=this.ajaxData.success;this.ajaxData.success=function(e){sl=b;sl.resultHandler(e);if("function"===typeof sl.tmp_success){sl.tmp_success(e)}if(sl.more){sl.checkGetMore()}};this.outer.scroll(function(){var e=b;var f=e.outer.scrollTop()+a(window).height();if((true===e.more)&&(f/e.judgeBy.height()>=e.ratio)){e.more=false;e.sendRequest()}});this.checkGetMore()},sendRequest:function(){a.ajax(this.ajaxData)},checkGetMore:function(){if(this.judgeBy.height()<this.outer.height()*2){this.more=false;this.sendRequest()}},resultHandler:function(c){var d="";if("html"===this.ajaxData.dataType){d=c}else{if("json"===this.ajaxData.dataType){if(true===c.error){d=""}else{if("undefined"!==typeof c.content){d=c.content}}}}if(""!==d){this.appendTo.append(d);this.more=true}}}})(jQuery);