/* * @author: wenyu * @date: 2017-01-09 17:51:29 * @last modified by: wenyu * @last modified time: 2017-01-13 10:04:34 */ 'use strict'; var compspublicload = { init: function() { this.load(); }, load: function() { var _self = this; $(window).scrolltop(1) if ($(window).scrolltop() <= 0) { _self.renderdata() } else { window.onscroll = utils.throttle(_self.renderdata, 200); $(window).scrolltop(2); } }, renderdata: function() { $.each($(".m-components"), function() { var id = $(this).attr('id'); var scrollh = $(window).scrolltop(), winh = $(window).height(), top = $(this).offset().top; if (top < (winh + scrollh + 200)) { if ($.inarray(id, isloadeddata) == -1) { try{ compsloader['loadcomponent_' + id](); }catch(err){ console.log('%c'+id,'font-size:18px;color:#f00') } } } }) } } compspublicload.init();