diff --git a/bower.json b/bower.json index 0acf25f..9fb38f5 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "kist-inView", - "version": "0.5.1", + "version": "0.5.2", "description": "Check if elements are in viewport.", "authors": [ "Ivan Nikolić" diff --git a/dist/kist-inView.js b/dist/kist-inView.js index a62806c..a5c5b0b 100644 --- a/dist/kist-inView.js +++ b/dist/kist-inView.js @@ -1,10 +1,10 @@ -/*! kist-inView 0.5.1 - Check if elements are in viewport. | Author: Ivan Nikolić, 2014 | License: MIT */ +/*! kist-inView 0.5.2 - Check if elements are in viewport. | Author: Ivan Nikolić, 2014 | License: MIT */ ;(function ( $, window, document, undefined ) { var plugin = { name: 'inView', ns: { - css: 'KistInView', + css: 'kist-InView', event: '.kist.inView' }, instance: { @@ -82,7 +82,7 @@ /** * Bouncing mechanism * - * @param {Number} timeout + * @param {Integer} timeout * @param {Function} fn * @param {Function} cb * @@ -104,6 +104,8 @@ domRef.setup.call(this); events.setup.call(this, cb); + windowChange.call(this, cb); + } $.extend(InView.prototype, { @@ -112,7 +114,7 @@ * Check if element is (partially) visible in viewport * * @param {jQuery} el - * @param {Number} threshold + * @param {Integer} threshold * * @return {Boolean} */ @@ -130,7 +132,7 @@ * Return list of elements visible in viewport * * @param {jQuery} el - * @param {Number} threshold + * @param {Integer} threshold * * @return {jQuery} */ diff --git a/dist/kist-inView.min.js b/dist/kist-inView.min.js index 973dc4a..cfee0e4 100644 --- a/dist/kist-inView.min.js +++ b/dist/kist-inView.min.js @@ -1,2 +1,2 @@ -/*! kist-inView 0.5.1 - Check if elements are in viewport. | Author: Ivan Nikolić, 2014 | License: MIT */ -!function(a,b){function c(){return j.top=h.common.window.scrollTop(),j.bottom=j.top+h.common.window.height(),j}function d(a){var b=this.getElements(this.dom.el,this.options.threshold);return b.length?a.call(null,b):void 0}function e(b,c,d){return this.options.debounce&&a.debounce?a.debounce(b,a.proxy(c,this,d)):a.proxy(c,this,d)}function f(b,c,d){this.element=b,this.options=a.extend({},this.defaults,c),g.instance.setup.call(this),h.setup.call(this),i.setup.call(this,d)}var g={name:"inView",ns:{css:"KistInView",event:".kist.inView"},instance:{id:0,setup:function(){this.instance=this.instance||{},this.instance.id=g.instance.id++,this.instance.ens=g.ns.event+"."+this.instance.id},destroy:function(){this.dom.el.each(function(b,c){delete a.data(c)[g.name]})}}},h={common:{window:a(b)},setup:function(){this.dom=this.dom||{},this.dom.el=a(this.element)}},i={setup:function(a){h.common.window.on("scroll"+this.instance.ens+" resize"+this.instance.ens,e.call(this,this.options.debounce,d,a))},destroy:function(){h.common.window.off(this.instance.ens)}},j={top:0,bottom:0};a.extend(f.prototype,{isVisible:function(a,b){var c=a.offset().top,d=c+a.height();return b=b||this.defaults.threshold,d>=j.top-b&&c<=j.bottom+b},getElements:function(b,d){return c(),b.filter(a.proxy(function(b,c){return this.isVisible(a(c),d)},this))},destroy:function(){g.instance.destroy.call(this),i.destroy.call(this)},defaults:{threshold:0,debounce:300,success:null}}),a.inView={defaults:f.prototype.defaults},a.fn.inView=function(b,c){return b=b||{},c=c||b.success,"number"==typeof b&&(b={threshold:b}),"string"==typeof b?this.each(function(){a.data(this,g.name)&&a.data(this,g.name)[b]()}):c?this.filter(function(b,c){return!a.data(c,g.name)}).data(g.name,new f(this,b,c)):f.prototype.getElements(this,b.threshold)}}(jQuery,window,document); \ No newline at end of file +/*! kist-inView 0.5.2 - Check if elements are in viewport. | Author: Ivan Nikolić, 2014 | License: MIT */ +!function(a,b){function c(){return j.top=h.common.window.scrollTop(),j.bottom=j.top+h.common.window.height(),j}function d(a){var b=this.getElements(this.dom.el,this.options.threshold);return b.length?a.call(null,b):void 0}function e(b,c,d){return this.options.debounce&&a.debounce?a.debounce(b,a.proxy(c,this,d)):a.proxy(c,this,d)}function f(b,c,e){this.element=b,this.options=a.extend({},this.defaults,c),g.instance.setup.call(this),h.setup.call(this),i.setup.call(this,e),d.call(this,e)}var g={name:"inView",ns:{css:"kist-InView",event:".kist.inView"},instance:{id:0,setup:function(){this.instance=this.instance||{},this.instance.id=g.instance.id++,this.instance.ens=g.ns.event+"."+this.instance.id},destroy:function(){this.dom.el.each(function(b,c){delete a.data(c)[g.name]})}}},h={common:{window:a(b)},setup:function(){this.dom=this.dom||{},this.dom.el=a(this.element)}},i={setup:function(a){h.common.window.on("scroll"+this.instance.ens+" resize"+this.instance.ens,e.call(this,this.options.debounce,d,a))},destroy:function(){h.common.window.off(this.instance.ens)}},j={top:0,bottom:0};a.extend(f.prototype,{isVisible:function(a,b){var c=a.offset().top,d=c+a.height();return b=b||this.defaults.threshold,d>=j.top-b&&c<=j.bottom+b},getElements:function(b,d){return c(),b.filter(a.proxy(function(b,c){return this.isVisible(a(c),d)},this))},destroy:function(){g.instance.destroy.call(this),i.destroy.call(this)},defaults:{threshold:0,debounce:300,success:null}}),a.inView={defaults:f.prototype.defaults},a.fn.inView=function(b,c){return b=b||{},c=c||b.success,"number"==typeof b&&(b={threshold:b}),"string"==typeof b?this.each(function(){a.data(this,g.name)&&a.data(this,g.name)[b]()}):c?this.filter(function(b,c){return!a.data(c,g.name)}).data(g.name,new f(this,b,c)):f.prototype.getElements(this,b.threshold)}}(jQuery,window,document); \ No newline at end of file diff --git a/package.json b/package.json index b163da7..3959d79 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "kist-inView", - "version": "0.5.1", + "version": "0.5.2", "description": "Check if elements are in viewport.", "author": "Ivan Nikolić", "license": "MIT",