diff --git a/dist/zebra_pin.min.js b/dist/zebra_pin.min.js index c4f6860..c547847 100644 --- a/dist/zebra_pin.min.js +++ b/dist/zebra_pin.min.js @@ -1 +1 @@ -!function(u){"use strict";u.Zebra_Pin=function(s,t){var n={class_name:"Zebra_Pin",contain:!(this.version="3.0.0"),hard:!1,top_spacing:0,bottom_spacing:0,z_index:1e3,onPin:null,onUnpin:null},c=this,g=(Math.random()+1).toString(36).substring(2,7),p=u(window),d=function(s){s.clone().addClass("Zebra_Pin_Clone").insertAfter(s).css("visibility","hidden"),s.data("zt_previous_style",s.attr("style")).addClass(c.settings.class_name),c.settings.onPin&&"function"==typeof c.settings.onPin&&c.settings.onPin(s)},f=function(s){s.next(".Zebra_Pin_Clone").remove(),s.attr("style",s.data("zt_previous_style")||"").removeClass(c.settings.class_name),c.settings.onUnpin&&"function"==typeof c.settings.onUnpin&&c.settings.onUnpin(s)};c.update=function(){s.each(function(s){var t,n,e=u(this),i=(e.hasClass(c.settings.class_name)&&(e.attr("style",e.data("zt_previous_style")||"").removeClass(c.settings.class_name).removeClass("Zebra_Pin_Contained"),e.next(".Zebra_Pin_Clone").remove()),e.offset()),a=e.position(),o=e.outerHeight(),_=e.outerWidth(),l=parseInt(e.css("marginLeft"),10)||0,r=parseInt(e.css("marginTop"),10)||0;i.left-=l,i.top-=r,c.settings.contain&&(l=e.parent(),t=l.height(),n=l.offset()),c.settings.hard?e.css({position:"fixed",left:i.left,top:i.top,width:_,zIndex:c.settings.z_index}).addClass(c.settings.class_name):(p.off("scroll"+(r=".Zebra_Pin_"+g+"_"+s)).on("scroll"+r,function(){var s=p.scrollTop();s>=i.top-c.settings.top_spacing&&(!c.settings.contain||s<=n.top+t-c.settings.top_spacing-o-c.settings.bottom_spacing)&&(!e.hasClass(c.settings.class_name)||e.hasClass("Zebra_Pin_Contained"))?(e.hasClass("Zebra_Pin_Contained")?e.removeClass("Zebra_Pin_Contained"):d(e),e.css({position:"fixed",left:i.left,top:c.settings.top_spacing,width:_,zIndex:c.settings.z_index})):s=n.top+t-c.settings.top_spacing-o-c.settings.bottom_spacing&&!e.hasClass("Zebra_Pin_Contained")&&(e.hasClass(c.settings.class_name)||d(e),e.css({position:"absolute",left:a.left,top:t-o-c.settings.bottom_spacing-c.settings.bottom_spacing}).addClass("Zebra_Pin_Contained"))}),p.trigger("scroll"+r))})},c.destroy=function(){p.off("resize.Zebra_Pin_"+g),s.each(function(s){p.off("scroll.Zebra_Pin_"+g+"_"+s),f(u(this))})},c.settings={},c.settings=u.extend({},n,t),c.update(),p.on("resize.Zebra_Pin_"+g,function(){c.update()})}}(jQuery); \ No newline at end of file +!function(u){"use strict";u.Zebra_Pin=function(s,t){var n={class_name:"Zebra_Pin",contain:!(this.version="3.0.1"),hard:!1,top_spacing:0,bottom_spacing:0,z_index:1e3,onPin:null,onUnpin:null},c=this,g=(Math.random()+1).toString(36).substring(2,7),p=u(window),d=function(s){s.clone().addClass("Zebra_Pin_Clone").insertAfter(s).css("visibility","hidden"),s.data("zt_previous_style",s.attr("style")).addClass(c.settings.class_name),c.settings.onPin&&"function"==typeof c.settings.onPin&&c.settings.onPin(s)},f=function(s){s.next(".Zebra_Pin_Clone").remove(),s.attr("style",s.data("zt_previous_style")||"").removeClass(c.settings.class_name),c.settings.onUnpin&&"function"==typeof c.settings.onUnpin&&c.settings.onUnpin(s)};c.update=function(){s.each(function(s){var t,n,e=u(this),i=(e.hasClass(c.settings.class_name)&&(e.attr("style",e.data("zt_previous_style")||"").removeClass(c.settings.class_name).removeClass("Zebra_Pin_Contained"),e.next(".Zebra_Pin_Clone").remove()),e.offset()),a=e.position(),o=e.outerHeight(),_=e.outerWidth(),l=parseInt(e.css("marginLeft"),10)||0,r=parseInt(e.css("marginTop"),10)||0;i.left-=l,i.top-=r,c.settings.contain&&(l=e.parent(),t=l.height(),n=l.offset()),c.settings.hard?e.css({position:"fixed",left:i.left,top:i.top,width:_,zIndex:c.settings.z_index}).addClass(c.settings.class_name):(p.off("scroll"+(r=".Zebra_Pin_"+g+"_"+s)).on("scroll"+r,function(){var s=p.scrollTop();s>=i.top-c.settings.top_spacing&&(!c.settings.contain||s<=n.top+t-c.settings.top_spacing-o-c.settings.bottom_spacing)&&(!e.hasClass(c.settings.class_name)||e.hasClass("Zebra_Pin_Contained"))?(e.hasClass("Zebra_Pin_Contained")?e.removeClass("Zebra_Pin_Contained"):d(e),e.css({position:"fixed",left:i.left,top:c.settings.top_spacing,width:_,zIndex:c.settings.z_index})):s=n.top+t-c.settings.top_spacing-o-c.settings.bottom_spacing&&!e.hasClass("Zebra_Pin_Contained")&&(e.hasClass(c.settings.class_name)||d(e),e.css({position:"absolute",left:a.left,top:t-o-c.settings.bottom_spacing-c.settings.bottom_spacing}).addClass("Zebra_Pin_Contained"))}),p.trigger("scroll"+r))})},c.destroy=function(){p.off("resize.Zebra_Pin_"+g),s.each(function(s){p.off("scroll.Zebra_Pin_"+g+"_"+s),f(u(this))})},c.settings={},c.settings=u.extend({},n,t),c.update(),p.on("resize.Zebra_Pin_"+g,function(){c.update()})}}(jQuery); \ No newline at end of file