/* author: 小鑫 date: 2019/4/19 qq: 857525554 */ var xroll = function(el, fn) { xroll.prototype.init(el, fn) }; xroll.prototype = { init: function(_el, fn) { _el.attr("data-state", false); this.start(_el, fn); $(window).on("scroll", function() { xroll.prototype.start(_el, fn) }) }, start: function(_el, fn) { var _this = this; $(_el).each(function() { var _self = $(this); var xrolltop = $(window).scrolltop(); var iswindowheiget = $(window).height(); if (_self.data().state) { return } if (xrolltop + iswindowheiget > $(this).offset().top) { fn(); settimeout(function() { _self.attr("data-state", true); _self.data().state = true }) } }) } };