From 2491f1a3ba053f1c6d974e8b256bc17f88321df3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BD=D0=B8=D0=B8=D0=BB=20=D0=9F=D1=80=D0=BE?= =?UTF-8?q?=D0=BD=D0=B8=D0=BD?= Date: Mon, 25 Jul 2016 13:46:28 +1000 Subject: [PATCH 01/11] fix cssOptions bug #216 https://github.com/bigspotteddog/ScrollToFixed/issues/216 --- jquery-scrolltofixed.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery-scrolltofixed.js b/jquery-scrolltofixed.js index aee7fa0..ddefc48 100644 --- a/jquery-scrolltofixed.js +++ b/jquery-scrolltofixed.js @@ -145,7 +145,7 @@ // not fill the rest of the page horizontally. Also, set its top // to the margin top specified in the options. - cssOptions={ + var cssOptions={ 'z-index' : base.options.zIndex, 'position' : 'fixed', 'top' : base.options.bottom == -1?getMarginTop():'', From 889ee629a625ec0cf162219111cbf1c6affbc2eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BD=D0=B8=D0=B8=D0=BB=20=D0=9F=D1=80=D0=BE?= =?UTF-8?q?=D0=BD=D0=B8=D0=BD?= Date: Mon, 25 Jul 2016 14:03:00 +1000 Subject: [PATCH 02/11] fix #208 bug https://github.com/bigspotteddog/ScrollToFixed/issues/208 --- jquery-scrolltofixed.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery-scrolltofixed.js b/jquery-scrolltofixed.js index ddefc48..b957bf0 100644 --- a/jquery-scrolltofixed.js +++ b/jquery-scrolltofixed.js @@ -211,7 +211,7 @@ 'margin-left' : '' }); - target.removeClass('scroll-to-fixed-fixed'); + target.removeClass(base.options.baseClassName); if (base.options.className) { target.removeClass(base.options.className); From b7091d68d202483041125c5db6b7f795ce1299f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BD=D0=B8=D0=B8=D0=BB=20=D0=9F=D1=80=D0=BE?= =?UTF-8?q?=D0=BD=D0=B8=D0=BD?= Date: Sat, 27 Aug 2016 23:13:04 +1000 Subject: [PATCH 03/11] Update jquery-scrolltofixed-min.js --- jquery-scrolltofixed-min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery-scrolltofixed-min.js b/jquery-scrolltofixed-min.js index 6b6fa8d..b2ecc1e 100644 --- a/jquery-scrolltofixed-min.js +++ b/jquery-scrolltofixed-min.js @@ -1 +1 @@ -(function(a){a.isScrollToFixed=function(b){return !!a(b).data("ScrollToFixed")};a.ScrollToFixed=function(d,i){var m=this;m.$el=a(d);m.el=d;m.$el.data("ScrollToFixed",m);var c=false;var H=m.$el;var I;var F;var k;var e;var z;var E=0;var r=0;var j=-1;var f=-1;var u=null;var A;var g;function v(){H.trigger("preUnfixed.ScrollToFixed");l();H.trigger("unfixed.ScrollToFixed");f=-1;E=H.offset().top;r=H.offset().left;if(m.options.offsets){r+=(H.offset().left-H.position().left)}if(j==-1){j=r}I=H.css("position");c=true;if(m.options.bottom!=-1){H.trigger("preFixed.ScrollToFixed");x();H.trigger("fixed.ScrollToFixed")}}function o(){var J=m.options.limit;if(!J){return 0}if(typeof(J)==="function"){return J.apply(H)}return J}function q(){return I==="fixed"}function y(){return I==="absolute"}function h(){return !(q()||y())}function x(){if(!q()){var J=H[0].getBoundingClientRect();u.css({display:H.css("display"),width:J.width,height:J.height,"float":H.css("float")});cssOptions={"z-index":m.options.zIndex,position:"fixed",top:m.options.bottom==-1?t():"",bottom:m.options.bottom==-1?"":m.options.bottom,"margin-left":"0px"};if(!m.options.dontSetWidth){cssOptions.width=H.css("width")}H.css(cssOptions);H.addClass(m.options.baseClassName);if(m.options.className){H.addClass(m.options.className)}I="fixed"}}function b(){var K=o();var J=r;if(m.options.removeOffsets){J="";K=K-E}cssOptions={position:"absolute",top:K,left:J,"margin-left":"0px",bottom:""};if(!m.options.dontSetWidth){cssOptions.width=H.css("width")}H.css(cssOptions);I="absolute"}function l(){if(!h()){f=-1;u.css("display","none");H.css({"z-index":z,width:"",position:F,left:"",top:e,"margin-left":""});H.removeClass("scroll-to-fixed-fixed");if(m.options.className){H.removeClass(m.options.className)}I=null}}function w(J){if(J!=f){H.css("left",r-J);f=J}}function t(){var J=m.options.marginTop;if(!J){return 0}if(typeof(J)==="function"){return J.apply(H)}return J}function B(){if(!a.isScrollToFixed(H)||H.is(":hidden")){return}var M=c;var L=h();if(!c){v()}else{if(h()){E=H.offset().top;r=H.offset().left}}var J=a(window).scrollLeft();var N=a(window).scrollTop();var K=o();if(m.options.minWidth&&a(window).width()m.options.maxWidth){if(!h()||!M){p();H.trigger("preUnfixed.ScrollToFixed");l();H.trigger("unfixed.ScrollToFixed")}}else{if(m.options.bottom==-1){if(K>0&&N>=K-t()){if(!L&&(!y()||!M)){p();H.trigger("preAbsolute.ScrollToFixed");b();H.trigger("unfixed.ScrollToFixed")}}else{if(N>=E-t()){if(!q()||!M){p();H.trigger("preFixed.ScrollToFixed");x();f=-1;H.trigger("fixed.ScrollToFixed")}w(J)}else{if(!h()||!M){p();H.trigger("preUnfixed.ScrollToFixed");l();H.trigger("unfixed.ScrollToFixed")}}}}else{if(K>0){if(N+a(window).height()-H.outerHeight(true)>=K-(t()||-n())){if(q()){p();H.trigger("preUnfixed.ScrollToFixed");if(F==="absolute"){b()}else{l()}H.trigger("unfixed.ScrollToFixed")}}else{if(!q()){p();H.trigger("preFixed.ScrollToFixed");x()}w(J);H.trigger("fixed.ScrollToFixed")}}else{w(J)}}}}}function n(){if(!m.options.bottom){return 0}return m.options.bottom}function p(){var J=H.css("position");if(J=="absolute"){H.trigger("postAbsolute.ScrollToFixed")}else{if(J=="fixed"){H.trigger("postFixed.ScrollToFixed")}else{H.trigger("postUnfixed.ScrollToFixed")}}}var D=function(J){if(H.is(":visible")){c=false;B()}else{l()}};var G=function(J){(!!window.requestAnimationFrame)?requestAnimationFrame(B):B()};var C=function(){var K=document.body;if(document.createElement&&K&&K.appendChild&&K.removeChild){var M=document.createElement("div");if(!M.getBoundingClientRect){return null}M.innerHTML="x";M.style.cssText="position:fixed;top:100px;";K.appendChild(M);var N=K.style.height,O=K.scrollTop;K.style.height="3000px";K.scrollTop=500;var J=M.getBoundingClientRect().top;K.style.height=N;var L=(J===100);K.removeChild(M);K.scrollTop=O;return L}return null};var s=function(J){J=J||window.event;if(J.preventDefault){J.preventDefault()}J.returnValue=false};m.init=function(){m.options=a.extend({},a.ScrollToFixed.defaultOptions,i);z=H.css("z-index");m.$el.css("z-index",m.options.zIndex);u=a("
");I=H.css("position");F=H.css("position");k=H.css("float");e=H.css("top");if(h()){m.$el.after(u)}a(window).bind("resize.ScrollToFixed",D);a(window).bind("scroll.ScrollToFixed",G);if("ontouchmove" in window){a(window).bind("touchmove.ScrollToFixed",B)}if(m.options.preFixed){H.bind("preFixed.ScrollToFixed",m.options.preFixed)}if(m.options.postFixed){H.bind("postFixed.ScrollToFixed",m.options.postFixed)}if(m.options.preUnfixed){H.bind("preUnfixed.ScrollToFixed",m.options.preUnfixed)}if(m.options.postUnfixed){H.bind("postUnfixed.ScrollToFixed",m.options.postUnfixed)}if(m.options.preAbsolute){H.bind("preAbsolute.ScrollToFixed",m.options.preAbsolute)}if(m.options.postAbsolute){H.bind("postAbsolute.ScrollToFixed",m.options.postAbsolute)}if(m.options.fixed){H.bind("fixed.ScrollToFixed",m.options.fixed)}if(m.options.unfixed){H.bind("unfixed.ScrollToFixed",m.options.unfixed)}if(m.options.spacerClass){u.addClass(m.options.spacerClass)}H.bind("resize.ScrollToFixed",function(){u.height(H.height())});H.bind("scroll.ScrollToFixed",function(){H.trigger("preUnfixed.ScrollToFixed");l();H.trigger("unfixed.ScrollToFixed");B()});H.bind("detach.ScrollToFixed",function(J){s(J);H.trigger("preUnfixed.ScrollToFixed");l();H.trigger("unfixed.ScrollToFixed");a(window).unbind("resize.ScrollToFixed",D);a(window).unbind("scroll.ScrollToFixed",G);H.unbind(".ScrollToFixed");u.remove();m.$el.removeData("ScrollToFixed")});D()};m.init()};a.ScrollToFixed.defaultOptions={marginTop:0,limit:0,bottom:-1,zIndex:1000,baseClassName:"scroll-to-fixed-fixed"};a.fn.scrollToFixed=function(b){return this.each(function(){(new a.ScrollToFixed(this,b))})}})(jQuery); \ No newline at end of file +(function(a){a.isScrollToFixed=function(b){return !!a(b).data("ScrollToFixed")};a.ScrollToFixed=function(d,i){var m=this;m.$el=a(d);m.el=d;m.$el.data("ScrollToFixed",m);var c=false;var H=m.$el;var I;var F;var k;var e;var z;var E=0;var r=0;var j=-1;var f=-1;var u=null;var A;var g;function v(){H.trigger("preUnfixed.ScrollToFixed");l();H.trigger("unfixed.ScrollToFixed");f=-1;E=H.offset().top;r=H.offset().left;if(m.options.offsets){r+=(H.offset().left-H.position().left)}if(j==-1){j=r}I=H.css("position");c=true;if(m.options.bottom!=-1){H.trigger("preFixed.ScrollToFixed");x();H.trigger("fixed.ScrollToFixed")}}function o(){var J=m.options.limit;if(!J){return 0}if(typeof(J)==="function"){return J.apply(H)}return J}function q(){return I==="fixed"}function y(){return I==="absolute"}function h(){return !(q()||y())}function x(){if(!q()){var K=H[0].getBoundingClientRect();u.css({display:H.css("display"),width:K.width,height:K.height,"float":H.css("float")});var J={"z-index":m.options.zIndex,position:"fixed",top:m.options.bottom==-1?t():"",bottom:m.options.bottom==-1?"":m.options.bottom,"margin-left":"0px"};if(!m.options.dontSetWidth){J.width=H.css("width")}H.css(J);H.addClass(m.options.baseClassName);if(m.options.className){H.addClass(m.options.className)}I="fixed"}}function b(){var K=o();var J=r;if(m.options.removeOffsets){J="";K=K-E}cssOptions={position:"absolute",top:K,left:J,"margin-left":"0px",bottom:""};if(!m.options.dontSetWidth){cssOptions.width=H.css("width")}H.css(cssOptions);I="absolute"}function l(){if(!h()){f=-1;u.css("display","none");H.css({"z-index":z,width:"",position:F,left:"",top:e,"margin-left":""});H.removeClass(m.options.baseClassName);if(m.options.className){H.removeClass(m.options.className)}I=null}}function w(J){if(J!=f){H.css("left",r-J);f=J}}function t(){var J=m.options.marginTop;if(!J){return 0}if(typeof(J)==="function"){return J.apply(H)}return J}function B(){if(!a.isScrollToFixed(H)||H.is(":hidden")){return}var M=c;var L=h();if(!c){v()}else{if(h()){E=H.offset().top;r=H.offset().left}}var J=a(window).scrollLeft();var N=a(window).scrollTop();var K=o();if(m.options.minWidth&&a(window).width()m.options.maxWidth){if(!h()||!M){p();H.trigger("preUnfixed.ScrollToFixed");l();H.trigger("unfixed.ScrollToFixed")}}else{if(m.options.bottom==-1){if(K>0&&N>=K-t()){if(!L&&(!y()||!M)){p();H.trigger("preAbsolute.ScrollToFixed");b();H.trigger("unfixed.ScrollToFixed")}}else{if(N>=E-t()){if(!q()||!M){p();H.trigger("preFixed.ScrollToFixed");x();f=-1;H.trigger("fixed.ScrollToFixed")}w(J)}else{if(!h()||!M){p();H.trigger("preUnfixed.ScrollToFixed");l();H.trigger("unfixed.ScrollToFixed")}}}}else{if(K>0){if(N+a(window).height()-H.outerHeight(true)>=K-(t()||-n())){if(q()){p();H.trigger("preUnfixed.ScrollToFixed");if(F==="absolute"){b()}else{l()}H.trigger("unfixed.ScrollToFixed")}}else{if(!q()){p();H.trigger("preFixed.ScrollToFixed");x()}w(J);H.trigger("fixed.ScrollToFixed")}}else{w(J)}}}}}function n(){if(!m.options.bottom){return 0}return m.options.bottom}function p(){var J=H.css("position");if(J=="absolute"){H.trigger("postAbsolute.ScrollToFixed")}else{if(J=="fixed"){H.trigger("postFixed.ScrollToFixed")}else{H.trigger("postUnfixed.ScrollToFixed")}}}var D=function(J){if(H.is(":visible")){c=false;B()}else{l()}};var G=function(J){(!!window.requestAnimationFrame)?requestAnimationFrame(B):B()};var C=function(){var K=document.body;if(document.createElement&&K&&K.appendChild&&K.removeChild){var M=document.createElement("div");if(!M.getBoundingClientRect){return null}M.innerHTML="x";M.style.cssText="position:fixed;top:100px;";K.appendChild(M);var N=K.style.height,O=K.scrollTop;K.style.height="3000px";K.scrollTop=500;var J=M.getBoundingClientRect().top;K.style.height=N;var L=(J===100);K.removeChild(M);K.scrollTop=O;return L}return null};var s=function(J){J=J||window.event;if(J.preventDefault){J.preventDefault()}J.returnValue=false};m.init=function(){m.options=a.extend({},a.ScrollToFixed.defaultOptions,i);z=H.css("z-index");m.$el.css("z-index",m.options.zIndex);u=a("
");I=H.css("position");F=H.css("position");k=H.css("float");e=H.css("top");if(h()){m.$el.after(u)}a(window).bind("resize.ScrollToFixed",D);a(window).bind("scroll.ScrollToFixed",G);if("ontouchmove" in window){a(window).bind("touchmove.ScrollToFixed",B)}if(m.options.preFixed){H.bind("preFixed.ScrollToFixed",m.options.preFixed)}if(m.options.postFixed){H.bind("postFixed.ScrollToFixed",m.options.postFixed)}if(m.options.preUnfixed){H.bind("preUnfixed.ScrollToFixed",m.options.preUnfixed)}if(m.options.postUnfixed){H.bind("postUnfixed.ScrollToFixed",m.options.postUnfixed)}if(m.options.preAbsolute){H.bind("preAbsolute.ScrollToFixed",m.options.preAbsolute)}if(m.options.postAbsolute){H.bind("postAbsolute.ScrollToFixed",m.options.postAbsolute)}if(m.options.fixed){H.bind("fixed.ScrollToFixed",m.options.fixed)}if(m.options.unfixed){H.bind("unfixed.ScrollToFixed",m.options.unfixed)}if(m.options.spacerClass){u.addClass(m.options.spacerClass)}H.bind("resize.ScrollToFixed",function(){u.height(H.height())});H.bind("scroll.ScrollToFixed",function(){H.trigger("preUnfixed.ScrollToFixed");l();H.trigger("unfixed.ScrollToFixed");B()});H.bind("detach.ScrollToFixed",function(J){s(J);H.trigger("preUnfixed.ScrollToFixed");l();H.trigger("unfixed.ScrollToFixed");a(window).unbind("resize.ScrollToFixed",D);a(window).unbind("scroll.ScrollToFixed",G);H.unbind(".ScrollToFixed");u.remove();m.$el.removeData("ScrollToFixed")});D()};m.init()};a.ScrollToFixed.defaultOptions={marginTop:0,limit:0,bottom:-1,zIndex:1000,baseClassName:"scroll-to-fixed-fixed"};a.fn.scrollToFixed=function(b){return this.each(function(){(new a.ScrollToFixed(this,b))})}})(jQuery); From 25fdcab00186bfbba025fb088185e4288e26b492 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BD=D0=B8=D0=B8=D0=BB=20=D0=9F=D1=80=D0=BE?= =?UTF-8?q?=D0=BD=D0=B8=D0=BD?= Date: Fri, 2 Sep 2016 00:00:40 +1000 Subject: [PATCH 04/11] fix(js) add missing variable declaration https://github.com/bigspotteddog/ScrollToFixed/issues/216#issuecomment-244063391 --- jquery-scrolltofixed.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery-scrolltofixed.js b/jquery-scrolltofixed.js index b957bf0..eff946f 100644 --- a/jquery-scrolltofixed.js +++ b/jquery-scrolltofixed.js @@ -176,7 +176,7 @@ top = top - offsetTop; } - cssOptions={ + var cssOptions={ 'position' : 'absolute', 'top' : top, 'left' : left, From 17d839cf196f2574303979552fbc3288586b81f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BD=D0=B8=D0=B8=D0=BB=20=D0=9F=D1=80=D0=BE?= =?UTF-8?q?=D0=BD=D0=B8=D0=BD?= Date: Fri, 2 Sep 2016 00:01:56 +1000 Subject: [PATCH 05/11] Update jquery-scrolltofixed-min.js --- jquery-scrolltofixed-min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery-scrolltofixed-min.js b/jquery-scrolltofixed-min.js index b2ecc1e..8f46011 100644 --- a/jquery-scrolltofixed-min.js +++ b/jquery-scrolltofixed-min.js @@ -1 +1 @@ -(function(a){a.isScrollToFixed=function(b){return !!a(b).data("ScrollToFixed")};a.ScrollToFixed=function(d,i){var m=this;m.$el=a(d);m.el=d;m.$el.data("ScrollToFixed",m);var c=false;var H=m.$el;var I;var F;var k;var e;var z;var E=0;var r=0;var j=-1;var f=-1;var u=null;var A;var g;function v(){H.trigger("preUnfixed.ScrollToFixed");l();H.trigger("unfixed.ScrollToFixed");f=-1;E=H.offset().top;r=H.offset().left;if(m.options.offsets){r+=(H.offset().left-H.position().left)}if(j==-1){j=r}I=H.css("position");c=true;if(m.options.bottom!=-1){H.trigger("preFixed.ScrollToFixed");x();H.trigger("fixed.ScrollToFixed")}}function o(){var J=m.options.limit;if(!J){return 0}if(typeof(J)==="function"){return J.apply(H)}return J}function q(){return I==="fixed"}function y(){return I==="absolute"}function h(){return !(q()||y())}function x(){if(!q()){var K=H[0].getBoundingClientRect();u.css({display:H.css("display"),width:K.width,height:K.height,"float":H.css("float")});var J={"z-index":m.options.zIndex,position:"fixed",top:m.options.bottom==-1?t():"",bottom:m.options.bottom==-1?"":m.options.bottom,"margin-left":"0px"};if(!m.options.dontSetWidth){J.width=H.css("width")}H.css(J);H.addClass(m.options.baseClassName);if(m.options.className){H.addClass(m.options.className)}I="fixed"}}function b(){var K=o();var J=r;if(m.options.removeOffsets){J="";K=K-E}cssOptions={position:"absolute",top:K,left:J,"margin-left":"0px",bottom:""};if(!m.options.dontSetWidth){cssOptions.width=H.css("width")}H.css(cssOptions);I="absolute"}function l(){if(!h()){f=-1;u.css("display","none");H.css({"z-index":z,width:"",position:F,left:"",top:e,"margin-left":""});H.removeClass(m.options.baseClassName);if(m.options.className){H.removeClass(m.options.className)}I=null}}function w(J){if(J!=f){H.css("left",r-J);f=J}}function t(){var J=m.options.marginTop;if(!J){return 0}if(typeof(J)==="function"){return J.apply(H)}return J}function B(){if(!a.isScrollToFixed(H)||H.is(":hidden")){return}var M=c;var L=h();if(!c){v()}else{if(h()){E=H.offset().top;r=H.offset().left}}var J=a(window).scrollLeft();var N=a(window).scrollTop();var K=o();if(m.options.minWidth&&a(window).width()m.options.maxWidth){if(!h()||!M){p();H.trigger("preUnfixed.ScrollToFixed");l();H.trigger("unfixed.ScrollToFixed")}}else{if(m.options.bottom==-1){if(K>0&&N>=K-t()){if(!L&&(!y()||!M)){p();H.trigger("preAbsolute.ScrollToFixed");b();H.trigger("unfixed.ScrollToFixed")}}else{if(N>=E-t()){if(!q()||!M){p();H.trigger("preFixed.ScrollToFixed");x();f=-1;H.trigger("fixed.ScrollToFixed")}w(J)}else{if(!h()||!M){p();H.trigger("preUnfixed.ScrollToFixed");l();H.trigger("unfixed.ScrollToFixed")}}}}else{if(K>0){if(N+a(window).height()-H.outerHeight(true)>=K-(t()||-n())){if(q()){p();H.trigger("preUnfixed.ScrollToFixed");if(F==="absolute"){b()}else{l()}H.trigger("unfixed.ScrollToFixed")}}else{if(!q()){p();H.trigger("preFixed.ScrollToFixed");x()}w(J);H.trigger("fixed.ScrollToFixed")}}else{w(J)}}}}}function n(){if(!m.options.bottom){return 0}return m.options.bottom}function p(){var J=H.css("position");if(J=="absolute"){H.trigger("postAbsolute.ScrollToFixed")}else{if(J=="fixed"){H.trigger("postFixed.ScrollToFixed")}else{H.trigger("postUnfixed.ScrollToFixed")}}}var D=function(J){if(H.is(":visible")){c=false;B()}else{l()}};var G=function(J){(!!window.requestAnimationFrame)?requestAnimationFrame(B):B()};var C=function(){var K=document.body;if(document.createElement&&K&&K.appendChild&&K.removeChild){var M=document.createElement("div");if(!M.getBoundingClientRect){return null}M.innerHTML="x";M.style.cssText="position:fixed;top:100px;";K.appendChild(M);var N=K.style.height,O=K.scrollTop;K.style.height="3000px";K.scrollTop=500;var J=M.getBoundingClientRect().top;K.style.height=N;var L=(J===100);K.removeChild(M);K.scrollTop=O;return L}return null};var s=function(J){J=J||window.event;if(J.preventDefault){J.preventDefault()}J.returnValue=false};m.init=function(){m.options=a.extend({},a.ScrollToFixed.defaultOptions,i);z=H.css("z-index");m.$el.css("z-index",m.options.zIndex);u=a("
");I=H.css("position");F=H.css("position");k=H.css("float");e=H.css("top");if(h()){m.$el.after(u)}a(window).bind("resize.ScrollToFixed",D);a(window).bind("scroll.ScrollToFixed",G);if("ontouchmove" in window){a(window).bind("touchmove.ScrollToFixed",B)}if(m.options.preFixed){H.bind("preFixed.ScrollToFixed",m.options.preFixed)}if(m.options.postFixed){H.bind("postFixed.ScrollToFixed",m.options.postFixed)}if(m.options.preUnfixed){H.bind("preUnfixed.ScrollToFixed",m.options.preUnfixed)}if(m.options.postUnfixed){H.bind("postUnfixed.ScrollToFixed",m.options.postUnfixed)}if(m.options.preAbsolute){H.bind("preAbsolute.ScrollToFixed",m.options.preAbsolute)}if(m.options.postAbsolute){H.bind("postAbsolute.ScrollToFixed",m.options.postAbsolute)}if(m.options.fixed){H.bind("fixed.ScrollToFixed",m.options.fixed)}if(m.options.unfixed){H.bind("unfixed.ScrollToFixed",m.options.unfixed)}if(m.options.spacerClass){u.addClass(m.options.spacerClass)}H.bind("resize.ScrollToFixed",function(){u.height(H.height())});H.bind("scroll.ScrollToFixed",function(){H.trigger("preUnfixed.ScrollToFixed");l();H.trigger("unfixed.ScrollToFixed");B()});H.bind("detach.ScrollToFixed",function(J){s(J);H.trigger("preUnfixed.ScrollToFixed");l();H.trigger("unfixed.ScrollToFixed");a(window).unbind("resize.ScrollToFixed",D);a(window).unbind("scroll.ScrollToFixed",G);H.unbind(".ScrollToFixed");u.remove();m.$el.removeData("ScrollToFixed")});D()};m.init()};a.ScrollToFixed.defaultOptions={marginTop:0,limit:0,bottom:-1,zIndex:1000,baseClassName:"scroll-to-fixed-fixed"};a.fn.scrollToFixed=function(b){return this.each(function(){(new a.ScrollToFixed(this,b))})}})(jQuery); +(function(a){a.isScrollToFixed=function(b){return !!a(b).data("ScrollToFixed")};a.ScrollToFixed=function(d,i){var m=this;m.$el=a(d);m.el=d;m.$el.data("ScrollToFixed",m);var c=false;var H=m.$el;var I;var F;var k;var e;var z;var E=0;var r=0;var j=-1;var f=-1;var u=null;var A;var g;function v(){H.trigger("preUnfixed.ScrollToFixed");l();H.trigger("unfixed.ScrollToFixed");f=-1;E=H.offset().top;r=H.offset().left;if(m.options.offsets){r+=(H.offset().left-H.position().left)}if(j==-1){j=r}I=H.css("position");c=true;if(m.options.bottom!=-1){H.trigger("preFixed.ScrollToFixed");x();H.trigger("fixed.ScrollToFixed")}}function o(){var J=m.options.limit;if(!J){return 0}if(typeof(J)==="function"){return J.apply(H)}return J}function q(){return I==="fixed"}function y(){return I==="absolute"}function h(){return !(q()||y())}function x(){if(!q()){var K=H[0].getBoundingClientRect();u.css({display:H.css("display"),width:K.width,height:K.height,"float":H.css("float")});var J={"z-index":m.options.zIndex,position:"fixed",top:m.options.bottom==-1?t():"",bottom:m.options.bottom==-1?"":m.options.bottom,"margin-left":"0px"};if(!m.options.dontSetWidth){J.width=H.css("width")}H.css(J);H.addClass(m.options.baseClassName);if(m.options.className){H.addClass(m.options.className)}I="fixed"}}function b(){var L=o();var K=r;if(m.options.removeOffsets){K="";L=L-E}var J={position:"absolute",top:L,left:K,"margin-left":"0px",bottom:""};if(!m.options.dontSetWidth){J.width=H.css("width")}H.css(J);I="absolute"}function l(){if(!h()){f=-1;u.css("display","none");H.css({"z-index":z,width:"",position:F,left:"",top:e,"margin-left":""});H.removeClass(m.options.baseClassName);if(m.options.className){H.removeClass(m.options.className)}I=null}}function w(J){if(J!=f){H.css("left",r-J);f=J}}function t(){var J=m.options.marginTop;if(!J){return 0}if(typeof(J)==="function"){return J.apply(H)}return J}function B(){if(!a.isScrollToFixed(H)||H.is(":hidden")){return}var M=c;var L=h();if(!c){v()}else{if(h()){E=H.offset().top;r=H.offset().left}}var J=a(window).scrollLeft();var N=a(window).scrollTop();var K=o();if(m.options.minWidth&&a(window).width()m.options.maxWidth){if(!h()||!M){p();H.trigger("preUnfixed.ScrollToFixed");l();H.trigger("unfixed.ScrollToFixed")}}else{if(m.options.bottom==-1){if(K>0&&N>=K-t()){if(!L&&(!y()||!M)){p();H.trigger("preAbsolute.ScrollToFixed");b();H.trigger("unfixed.ScrollToFixed")}}else{if(N>=E-t()){if(!q()||!M){p();H.trigger("preFixed.ScrollToFixed");x();f=-1;H.trigger("fixed.ScrollToFixed")}w(J)}else{if(!h()||!M){p();H.trigger("preUnfixed.ScrollToFixed");l();H.trigger("unfixed.ScrollToFixed")}}}}else{if(K>0){if(N+a(window).height()-H.outerHeight(true)>=K-(t()||-n())){if(q()){p();H.trigger("preUnfixed.ScrollToFixed");if(F==="absolute"){b()}else{l()}H.trigger("unfixed.ScrollToFixed")}}else{if(!q()){p();H.trigger("preFixed.ScrollToFixed");x()}w(J);H.trigger("fixed.ScrollToFixed")}}else{w(J)}}}}}function n(){if(!m.options.bottom){return 0}return m.options.bottom}function p(){var J=H.css("position");if(J=="absolute"){H.trigger("postAbsolute.ScrollToFixed")}else{if(J=="fixed"){H.trigger("postFixed.ScrollToFixed")}else{H.trigger("postUnfixed.ScrollToFixed")}}}var D=function(J){if(H.is(":visible")){c=false;B()}else{l()}};var G=function(J){(!!window.requestAnimationFrame)?requestAnimationFrame(B):B()};var C=function(){var K=document.body;if(document.createElement&&K&&K.appendChild&&K.removeChild){var M=document.createElement("div");if(!M.getBoundingClientRect){return null}M.innerHTML="x";M.style.cssText="position:fixed;top:100px;";K.appendChild(M);var N=K.style.height,O=K.scrollTop;K.style.height="3000px";K.scrollTop=500;var J=M.getBoundingClientRect().top;K.style.height=N;var L=(J===100);K.removeChild(M);K.scrollTop=O;return L}return null};var s=function(J){J=J||window.event;if(J.preventDefault){J.preventDefault()}J.returnValue=false};m.init=function(){m.options=a.extend({},a.ScrollToFixed.defaultOptions,i);z=H.css("z-index");m.$el.css("z-index",m.options.zIndex);u=a("
");I=H.css("position");F=H.css("position");k=H.css("float");e=H.css("top");if(h()){m.$el.after(u)}a(window).bind("resize.ScrollToFixed",D);a(window).bind("scroll.ScrollToFixed",G);if("ontouchmove" in window){a(window).bind("touchmove.ScrollToFixed",B)}if(m.options.preFixed){H.bind("preFixed.ScrollToFixed",m.options.preFixed)}if(m.options.postFixed){H.bind("postFixed.ScrollToFixed",m.options.postFixed)}if(m.options.preUnfixed){H.bind("preUnfixed.ScrollToFixed",m.options.preUnfixed)}if(m.options.postUnfixed){H.bind("postUnfixed.ScrollToFixed",m.options.postUnfixed)}if(m.options.preAbsolute){H.bind("preAbsolute.ScrollToFixed",m.options.preAbsolute)}if(m.options.postAbsolute){H.bind("postAbsolute.ScrollToFixed",m.options.postAbsolute)}if(m.options.fixed){H.bind("fixed.ScrollToFixed",m.options.fixed)}if(m.options.unfixed){H.bind("unfixed.ScrollToFixed",m.options.unfixed)}if(m.options.spacerClass){u.addClass(m.options.spacerClass)}H.bind("resize.ScrollToFixed",function(){u.height(H.height())});H.bind("scroll.ScrollToFixed",function(){H.trigger("preUnfixed.ScrollToFixed");l();H.trigger("unfixed.ScrollToFixed");B()});H.bind("detach.ScrollToFixed",function(J){s(J);H.trigger("preUnfixed.ScrollToFixed");l();H.trigger("unfixed.ScrollToFixed");a(window).unbind("resize.ScrollToFixed",D);a(window).unbind("scroll.ScrollToFixed",G);H.unbind(".ScrollToFixed");u.remove();m.$el.removeData("ScrollToFixed")});D()};m.init()};a.ScrollToFixed.defaultOptions={marginTop:0,limit:0,bottom:-1,zIndex:1000,baseClassName:"scroll-to-fixed-fixed"};a.fn.scrollToFixed=function(b){return this.each(function(){(new a.ScrollToFixed(this,b))})}})(jQuery); From 16172083205ce0a7ece6ae2054cc5eeac6963c32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BD=D0=B8=D0=B8=D0=BB=20=D0=9F=D1=80=D0=BE?= =?UTF-8?q?=D0=BD=D0=B8=D0=BD?= Date: Sun, 4 Sep 2016 12:19:25 +1000 Subject: [PATCH 06/11] add(package) build JS with gulp --- .editorconfig | 16 ++++++++++++++++ .gitignore | 1 + .travis.yml | 7 +++++++ deploy.sh | 13 +++++++++++++ gulpfile.js | 44 ++++++++++++++++++++++++++++++++++++++++++++ package.json | 35 +++++++++++++++++++++++++++++++++-- 6 files changed, 114 insertions(+), 2 deletions(-) create mode 100644 .editorconfig create mode 100644 .gitignore create mode 100644 .travis.yml create mode 100644 deploy.sh create mode 100644 gulpfile.js diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..f0abe75 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,16 @@ +root = true + +[*] +indent_style = tab +indent_size = 4 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.md] +trim_trailing_whitespace = false + +[*.json] +indent_style = space +indent_size = 2 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..ed5f2a1 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,7 @@ +language: node_js +node_js: + - "stable" +cache: + directories: + - node_modules +script: bash ./deploy.sh diff --git a/deploy.sh b/deploy.sh new file mode 100644 index 0000000..37422a9 --- /dev/null +++ b/deploy.sh @@ -0,0 +1,13 @@ +#!/bin/bash +set -e # Exit with nonzero exit code if anything fails +git checkout master +npm run gulp +if [ -z `git diff --exit-code` ]; then + echo "No changes to the output on this push; exiting." + exit 0 +fi +git add . +git remote add deployment https://$USER:$PASSWORD@github.com/$TRAVIS_REPO_SLUG.git +git config user.name "Travis CI" +git commit -m "Travis CI $TRAVIS_COMMIT" +git push -u deployment master diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000..e403c63 --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,44 @@ +'use strict' +// global +const gulp = require('gulp') +const browserify = require('browserify') +const $ = require('gulp-load-plugins')() +// local +const env = { + scriptsToCompile: [ + './*.js', + '!./*-min.js', + '!./gulpfile.js' + ], + destScriptsNaming: $.rename({ + suffix: '-min' + }), + dest: './' +} +// public tasks +gulp.task('default', ['scripts']) +gulp.task('scripts', ()=> { + // some strange code because of gulp team think there is not necessary to have a plugin to just `.pipe(browserify())`, you have to build bicycles instead: https://github.com/gulpjs/plugins/issues/47 + return gulp.src(env.scriptsToCompile, {read: false}) + .pipe( + // transform file objects + $.tap(file=> { + $.util.log('bundling ' + file.path) + // replace file contents with Browserify bundle stream + file.contents = browserify( + file.path, + // Babel and other transforms is plugged in package.json + { + debug: true + } + ).bundle() + }) + ) + // transform streaming contents into buffer contents (because gulp-sourcemaps does not support streaming contents) + .pipe($.buffer()) + // non-bycicle gulp pipeline starts here + .pipe(env.destScriptsNaming) + .pipe($.sourcemaps.init({loadMaps: true})) + .pipe($.sourcemaps.write('./')) + .pipe(gulp.dest(env.dest)) +}) diff --git a/package.json b/package.json index 42e6491..82662ff 100644 --- a/package.json +++ b/package.json @@ -16,12 +16,43 @@ "test": "tests" }, "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "gulp": "gulp" }, "keywords": [ "scroll", "fixed", "jquery" ], - "license": "MIT" + "license": "MIT", + "browserify": { + "transform": [ + [ + "babelify", + { + "presets": [ + "es2015" + ] + } + ], + [ + "uglifyify" + ] + ] + }, + "devDependencies": { + "babel-preset-es2015": "^6.14.0", + "babelify": "^7.3.0", + "browserify": "^13.1.0", + "gulp": "^3.9.1", + "gulp-buffer": "0.0.2", + "gulp-load-plugins": "^1.2.4", + "gulp-rename": "^1.2.2", + "gulp-sourcemaps": "^1.6.0", + "gulp-tap": "^0.1.3", + "gulp-util": "^3.0.7", + "uglifyify": "^3.0.2" + }, + "dependencies": { + "jquery": "^3.1.0" + } } From 863f1190170aaf574780a0bc67d2ce55ba695092 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Sun, 4 Sep 2016 02:22:10 +0000 Subject: [PATCH 07/11] Travis CI 16172083205ce0a7ece6ae2054cc5eeac6963c32 --- jquery-scrolltofixed-min.js | 8 +++++++- jquery-scrolltofixed-min.js.map | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 jquery-scrolltofixed-min.js.map diff --git a/jquery-scrolltofixed-min.js b/jquery-scrolltofixed-min.js index 8f46011..7518e9a 100644 --- a/jquery-scrolltofixed-min.js +++ b/jquery-scrolltofixed-min.js @@ -1 +1,7 @@ -(function(a){a.isScrollToFixed=function(b){return !!a(b).data("ScrollToFixed")};a.ScrollToFixed=function(d,i){var m=this;m.$el=a(d);m.el=d;m.$el.data("ScrollToFixed",m);var c=false;var H=m.$el;var I;var F;var k;var e;var z;var E=0;var r=0;var j=-1;var f=-1;var u=null;var A;var g;function v(){H.trigger("preUnfixed.ScrollToFixed");l();H.trigger("unfixed.ScrollToFixed");f=-1;E=H.offset().top;r=H.offset().left;if(m.options.offsets){r+=(H.offset().left-H.position().left)}if(j==-1){j=r}I=H.css("position");c=true;if(m.options.bottom!=-1){H.trigger("preFixed.ScrollToFixed");x();H.trigger("fixed.ScrollToFixed")}}function o(){var J=m.options.limit;if(!J){return 0}if(typeof(J)==="function"){return J.apply(H)}return J}function q(){return I==="fixed"}function y(){return I==="absolute"}function h(){return !(q()||y())}function x(){if(!q()){var K=H[0].getBoundingClientRect();u.css({display:H.css("display"),width:K.width,height:K.height,"float":H.css("float")});var J={"z-index":m.options.zIndex,position:"fixed",top:m.options.bottom==-1?t():"",bottom:m.options.bottom==-1?"":m.options.bottom,"margin-left":"0px"};if(!m.options.dontSetWidth){J.width=H.css("width")}H.css(J);H.addClass(m.options.baseClassName);if(m.options.className){H.addClass(m.options.className)}I="fixed"}}function b(){var L=o();var K=r;if(m.options.removeOffsets){K="";L=L-E}var J={position:"absolute",top:L,left:K,"margin-left":"0px",bottom:""};if(!m.options.dontSetWidth){J.width=H.css("width")}H.css(J);I="absolute"}function l(){if(!h()){f=-1;u.css("display","none");H.css({"z-index":z,width:"",position:F,left:"",top:e,"margin-left":""});H.removeClass(m.options.baseClassName);if(m.options.className){H.removeClass(m.options.className)}I=null}}function w(J){if(J!=f){H.css("left",r-J);f=J}}function t(){var J=m.options.marginTop;if(!J){return 0}if(typeof(J)==="function"){return J.apply(H)}return J}function B(){if(!a.isScrollToFixed(H)||H.is(":hidden")){return}var M=c;var L=h();if(!c){v()}else{if(h()){E=H.offset().top;r=H.offset().left}}var J=a(window).scrollLeft();var N=a(window).scrollTop();var K=o();if(m.options.minWidth&&a(window).width()m.options.maxWidth){if(!h()||!M){p();H.trigger("preUnfixed.ScrollToFixed");l();H.trigger("unfixed.ScrollToFixed")}}else{if(m.options.bottom==-1){if(K>0&&N>=K-t()){if(!L&&(!y()||!M)){p();H.trigger("preAbsolute.ScrollToFixed");b();H.trigger("unfixed.ScrollToFixed")}}else{if(N>=E-t()){if(!q()||!M){p();H.trigger("preFixed.ScrollToFixed");x();f=-1;H.trigger("fixed.ScrollToFixed")}w(J)}else{if(!h()||!M){p();H.trigger("preUnfixed.ScrollToFixed");l();H.trigger("unfixed.ScrollToFixed")}}}}else{if(K>0){if(N+a(window).height()-H.outerHeight(true)>=K-(t()||-n())){if(q()){p();H.trigger("preUnfixed.ScrollToFixed");if(F==="absolute"){b()}else{l()}H.trigger("unfixed.ScrollToFixed")}}else{if(!q()){p();H.trigger("preFixed.ScrollToFixed");x()}w(J);H.trigger("fixed.ScrollToFixed")}}else{w(J)}}}}}function n(){if(!m.options.bottom){return 0}return m.options.bottom}function p(){var J=H.css("position");if(J=="absolute"){H.trigger("postAbsolute.ScrollToFixed")}else{if(J=="fixed"){H.trigger("postFixed.ScrollToFixed")}else{H.trigger("postUnfixed.ScrollToFixed")}}}var D=function(J){if(H.is(":visible")){c=false;B()}else{l()}};var G=function(J){(!!window.requestAnimationFrame)?requestAnimationFrame(B):B()};var C=function(){var K=document.body;if(document.createElement&&K&&K.appendChild&&K.removeChild){var M=document.createElement("div");if(!M.getBoundingClientRect){return null}M.innerHTML="x";M.style.cssText="position:fixed;top:100px;";K.appendChild(M);var N=K.style.height,O=K.scrollTop;K.style.height="3000px";K.scrollTop=500;var J=M.getBoundingClientRect().top;K.style.height=N;var L=(J===100);K.removeChild(M);K.scrollTop=O;return L}return null};var s=function(J){J=J||window.event;if(J.preventDefault){J.preventDefault()}J.returnValue=false};m.init=function(){m.options=a.extend({},a.ScrollToFixed.defaultOptions,i);z=H.css("z-index");m.$el.css("z-index",m.options.zIndex);u=a("
");I=H.css("position");F=H.css("position");k=H.css("float");e=H.css("top");if(h()){m.$el.after(u)}a(window).bind("resize.ScrollToFixed",D);a(window).bind("scroll.ScrollToFixed",G);if("ontouchmove" in window){a(window).bind("touchmove.ScrollToFixed",B)}if(m.options.preFixed){H.bind("preFixed.ScrollToFixed",m.options.preFixed)}if(m.options.postFixed){H.bind("postFixed.ScrollToFixed",m.options.postFixed)}if(m.options.preUnfixed){H.bind("preUnfixed.ScrollToFixed",m.options.preUnfixed)}if(m.options.postUnfixed){H.bind("postUnfixed.ScrollToFixed",m.options.postUnfixed)}if(m.options.preAbsolute){H.bind("preAbsolute.ScrollToFixed",m.options.preAbsolute)}if(m.options.postAbsolute){H.bind("postAbsolute.ScrollToFixed",m.options.postAbsolute)}if(m.options.fixed){H.bind("fixed.ScrollToFixed",m.options.fixed)}if(m.options.unfixed){H.bind("unfixed.ScrollToFixed",m.options.unfixed)}if(m.options.spacerClass){u.addClass(m.options.spacerClass)}H.bind("resize.ScrollToFixed",function(){u.height(H.height())});H.bind("scroll.ScrollToFixed",function(){H.trigger("preUnfixed.ScrollToFixed");l();H.trigger("unfixed.ScrollToFixed");B()});H.bind("detach.ScrollToFixed",function(J){s(J);H.trigger("preUnfixed.ScrollToFixed");l();H.trigger("unfixed.ScrollToFixed");a(window).unbind("resize.ScrollToFixed",D);a(window).unbind("scroll.ScrollToFixed",G);H.unbind(".ScrollToFixed");u.remove();m.$el.removeData("ScrollToFixed")});D()};m.init()};a.ScrollToFixed.defaultOptions={marginTop:0,limit:0,bottom:-1,zIndex:1000,baseClassName:"scroll-to-fixed-fixed"};a.fn.scrollToFixed=function(b){return this.each(function(){(new a.ScrollToFixed(this,b))})}})(jQuery); +(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;og.options.maxWidth?l()&&i||(F(),v.trigger("preUnfixed.ScrollToFixed"),x(),v.trigger("unfixed.ScrollToFixed")):g.options.bottom==-1?b>0&&T>=b-f()?e||s()&&i||(F(),v.trigger("preAbsolute.ScrollToFixed"),c(),v.trigger("unfixed.ScrollToFixed")):T>=U-f()?(r()&&i||(F(),v.trigger("preFixed.ScrollToFixed"),d(),A=-1,v.trigger("fixed.ScrollToFixed")),p(a)):l()&&i||(F(),v.trigger("preUnfixed.ScrollToFixed"),x(),v.trigger("unfixed.ScrollToFixed")):b>0?T+o(window).height()-v.outerHeight(!0)>=b-(f()||-u())?r()&&(F(),v.trigger("preUnfixed.ScrollToFixed"),"absolute"===S?c():x(),v.trigger("unfixed.ScrollToFixed")):(r()||(F(),v.trigger("preFixed.ScrollToFixed"),d()),p(a),v.trigger("fixed.ScrollToFixed")):p(a)}}function u(){return g.options.bottom?g.options.bottom:0}function F(){var o=v.css("position");"absolute"==o?v.trigger("postAbsolute.ScrollToFixed"):"fixed"==o?v.trigger("postFixed.ScrollToFixed"):v.trigger("postUnfixed.ScrollToFixed")}var g=this;g.$el=o(i),g.el=i,g.$el.data("ScrollToFixed",g);var T,S,b,m,w,h=!1,v=g.$el,U=0,C=0,z=-1,A=-1,y=null,N=function(o){v.is(":visible")?(h=!1,a()):x()},W=function(o){window.requestAnimationFrame?requestAnimationFrame(a):a()},$=function(o){o=o||window.event,o.preventDefault&&o.preventDefault(),o.returnValue=!1};g.init=function(){g.options=o.extend({},o.ScrollToFixed.defaultOptions,e),w=v.css("z-index"),g.$el.css("z-index",g.options.zIndex),y=o("
"),T=v.css("position"),S=v.css("position"),b=v.css("float"),m=v.css("top"),l()&&g.$el.after(y),o(window).bind("resize.ScrollToFixed",N),o(window).bind("scroll.ScrollToFixed",W),"ontouchmove"in window&&o(window).bind("touchmove.ScrollToFixed",a),g.options.preFixed&&v.bind("preFixed.ScrollToFixed",g.options.preFixed),g.options.postFixed&&v.bind("postFixed.ScrollToFixed",g.options.postFixed),g.options.preUnfixed&&v.bind("preUnfixed.ScrollToFixed",g.options.preUnfixed),g.options.postUnfixed&&v.bind("postUnfixed.ScrollToFixed",g.options.postUnfixed),g.options.preAbsolute&&v.bind("preAbsolute.ScrollToFixed",g.options.preAbsolute),g.options.postAbsolute&&v.bind("postAbsolute.ScrollToFixed",g.options.postAbsolute),g.options.fixed&&v.bind("fixed.ScrollToFixed",g.options.fixed),g.options.unfixed&&v.bind("unfixed.ScrollToFixed",g.options.unfixed),g.options.spacerClass&&y.addClass(g.options.spacerClass),v.bind("resize.ScrollToFixed",function(){y.height(v.height())}),v.bind("scroll.ScrollToFixed",function(){v.trigger("preUnfixed.ScrollToFixed"),x(),v.trigger("unfixed.ScrollToFixed"),a()}),v.bind("detach.ScrollToFixed",function(i){$(i),v.trigger("preUnfixed.ScrollToFixed"),x(),v.trigger("unfixed.ScrollToFixed"),o(window).unbind("resize.ScrollToFixed",N),o(window).unbind("scroll.ScrollToFixed",W),v.unbind(".ScrollToFixed"),y.remove(),g.$el.removeData("ScrollToFixed")}),N()},g.init()},o.ScrollToFixed.defaultOptions={marginTop:0,limit:0,bottom:-1,zIndex:1e3,baseClassName:"scroll-to-fixed-fixed"},o.fn.scrollToFixed=function(i){return this.each(function(){new o.ScrollToFixed(this,i)})}}(jQuery); + +},{}]},{},[1]) + + +//# sourceMappingURL=jquery-scrolltofixed-min.js.map diff --git a/jquery-scrolltofixed-min.js.map b/jquery-scrolltofixed-min.js.map new file mode 100644 index 0000000..409e356 --- /dev/null +++ b/jquery-scrolltofixed-min.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["node_modules/browser-pack/_prelude.js","jquery-scrolltofixed.js"],"names":[],"mappings":"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","file":"jquery-scrolltofixed-min.js","sourceRoot":"/source/","sourcesContent":["(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require==\"function\"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error(\"Cannot find module '\"+o+\"'\");throw f.code=\"MODULE_NOT_FOUND\",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require==\"function\"&&require;for(var o=0;o base.options.maxWidth) {\n if (!isUnfixed() || !wasReset) {\n postPosition();\n target.trigger('preUnfixed.ScrollToFixed');\n setUnfixed();\n target.trigger('unfixed.ScrollToFixed');\n }\n } else if (base.options.bottom == -1) {\n // If the vertical scroll position, plus the optional margin, would\n // put the target element at the specified limit, set the target\n // element to absolute.\n if (limit > 0 && y >= limit - getMarginTop()) {\n if (!wasUnfixed && (!isAbsolute() || !wasReset)) {\n postPosition();\n target.trigger('preAbsolute.ScrollToFixed');\n setAbsolute();\n target.trigger('unfixed.ScrollToFixed');\n }\n // If the vertical scroll position, plus the optional margin, would\n // put the target element above the top of the page, set the target\n // element to fixed.\n } else if (y >= offsetTop - getMarginTop()) {\n if (!isFixed() || !wasReset) {\n postPosition();\n target.trigger('preFixed.ScrollToFixed');\n\n // Set the target element to fixed.\n setFixed();\n\n // Reset the last offset left because we just went fixed.\n lastOffsetLeft = -1;\n\n target.trigger('fixed.ScrollToFixed');\n }\n // If the page has been scrolled horizontally as well, move the\n // target element accordingly.\n setLeft(x);\n } else {\n // Set the target element to unfixed, placing it where it was\n // before.\n if (!isUnfixed() || !wasReset) {\n postPosition();\n target.trigger('preUnfixed.ScrollToFixed');\n setUnfixed();\n target.trigger('unfixed.ScrollToFixed');\n }\n }\n } else {\n if (limit > 0) {\n if (y + $(window).height() - target.outerHeight(true) >= limit - (getMarginTop() || -getBottom())) {\n if (isFixed()) {\n postPosition();\n target.trigger('preUnfixed.ScrollToFixed');\n\n if (originalPosition === 'absolute') {\n setAbsolute();\n } else {\n setUnfixed();\n }\n\n target.trigger('unfixed.ScrollToFixed');\n }\n } else {\n if (!isFixed()) {\n postPosition();\n target.trigger('preFixed.ScrollToFixed');\n setFixed();\n }\n setLeft(x);\n target.trigger('fixed.ScrollToFixed');\n }\n } else {\n setLeft(x);\n }\n }\n }\n\n function getBottom() {\n if (!base.options.bottom) return 0;\n return base.options.bottom;\n }\n\n function postPosition() {\n var position = target.css('position');\n\n if (position == 'absolute') {\n target.trigger('postAbsolute.ScrollToFixed');\n } else if (position == 'fixed') {\n target.trigger('postFixed.ScrollToFixed');\n } else {\n target.trigger('postUnfixed.ScrollToFixed');\n }\n }\n\n var windowResize = function(event) {\n // Check if the element is visible before updating it's position, which\n // improves behavior with responsive designs where this element is hidden.\n if(target.is(':visible')) {\n isReset = false;\n checkScroll();\n } else {\n // Ensure the spacer is hidden\n setUnfixed();\n }\n }\n\n var windowScroll = function(event) {\n (!!window.requestAnimationFrame) ? requestAnimationFrame(checkScroll) : checkScroll();\n }\n\n // From: http://kangax.github.com/cft/#IS_POSITION_FIXED_SUPPORTED\n var isPositionFixedSupported = function() {\n var container = document.body;\n\n if (document.createElement && container && container.appendChild && container.removeChild) {\n var el = document.createElement('div');\n\n if (!el.getBoundingClientRect) return null;\n\n el.innerHTML = 'x';\n el.style.cssText = 'position:fixed;top:100px;';\n container.appendChild(el);\n\n var originalHeight = container.style.height,\n originalScrollTop = container.scrollTop;\n\n container.style.height = '3000px';\n container.scrollTop = 500;\n\n var elementTop = el.getBoundingClientRect().top;\n container.style.height = originalHeight;\n\n var isSupported = (elementTop === 100);\n container.removeChild(el);\n container.scrollTop = originalScrollTop;\n\n return isSupported;\n }\n\n return null;\n }\n\n var preventDefault = function(e) {\n e = e || window.event;\n if (e.preventDefault) {\n e.preventDefault();\n }\n e.returnValue = false;\n }\n\n // Initializes this plugin. Captures the options passed in, turns this\n // off for devices that do not support fixed position, adds the spacer,\n // and binds to the window scroll and resize events.\n base.init = function() {\n // Capture the options for this plugin.\n base.options = $.extend({}, $.ScrollToFixed.defaultOptions, options);\n\n originalZIndex = target.css('z-index')\n\n // Turn off this functionality for devices that do not support it.\n // if (!(base.options && base.options.dontCheckForPositionFixedSupport)) {\n // var fixedSupported = isPositionFixedSupported();\n // if (!fixedSupported) return;\n // }\n\n // Put the target element on top of everything that could be below\n // it. This reduces flicker when the target element is transitioning\n // to fixed.\n base.$el.css('z-index', base.options.zIndex);\n\n // Create a spacer element to fill the void left by the target\n // element when it goes fixed.\n spacer = $('
');\n\n position = target.css('position');\n originalPosition = target.css('position');\n originalFloat = target.css('float');\n originalOffsetTop = target.css('top');\n\n // Place the spacer right after the target element.\n if (isUnfixed()) base.$el.after(spacer);\n\n // Reset the target element offsets when the window is resized, then\n // check to see if we need to fix or unfix the target element.\n $(window).bind('resize.ScrollToFixed', windowResize);\n\n // When the window scrolls, check to see if we need to fix or unfix\n // the target element.\n $(window).bind('scroll.ScrollToFixed', windowScroll);\n\n // For touch devices, call checkScroll directlly rather than\n // rAF wrapped windowScroll to animate the element\n if ('ontouchmove' in window) {\n $(window).bind('touchmove.ScrollToFixed', checkScroll);\n }\n\n if (base.options.preFixed) {\n target.bind('preFixed.ScrollToFixed', base.options.preFixed);\n }\n if (base.options.postFixed) {\n target.bind('postFixed.ScrollToFixed', base.options.postFixed);\n }\n if (base.options.preUnfixed) {\n target.bind('preUnfixed.ScrollToFixed', base.options.preUnfixed);\n }\n if (base.options.postUnfixed) {\n target.bind('postUnfixed.ScrollToFixed', base.options.postUnfixed);\n }\n if (base.options.preAbsolute) {\n target.bind('preAbsolute.ScrollToFixed', base.options.preAbsolute);\n }\n if (base.options.postAbsolute) {\n target.bind('postAbsolute.ScrollToFixed', base.options.postAbsolute);\n }\n if (base.options.fixed) {\n target.bind('fixed.ScrollToFixed', base.options.fixed);\n }\n if (base.options.unfixed) {\n target.bind('unfixed.ScrollToFixed', base.options.unfixed);\n }\n\n if (base.options.spacerClass) {\n spacer.addClass(base.options.spacerClass);\n }\n\n target.bind('resize.ScrollToFixed', function() {\n spacer.height(target.height());\n });\n\n target.bind('scroll.ScrollToFixed', function() {\n target.trigger('preUnfixed.ScrollToFixed');\n setUnfixed();\n target.trigger('unfixed.ScrollToFixed');\n checkScroll();\n });\n\n target.bind('detach.ScrollToFixed', function(ev) {\n preventDefault(ev);\n\n target.trigger('preUnfixed.ScrollToFixed');\n setUnfixed();\n target.trigger('unfixed.ScrollToFixed');\n\n $(window).unbind('resize.ScrollToFixed', windowResize);\n $(window).unbind('scroll.ScrollToFixed', windowScroll);\n\n target.unbind('.ScrollToFixed');\n\n //remove spacer from dom\n spacer.remove();\n\n base.$el.removeData('ScrollToFixed');\n });\n\n // Reset everything.\n windowResize();\n };\n\n // Initialize the plugin.\n base.init();\n };\n\n // Sets the option defaults.\n $.ScrollToFixed.defaultOptions = {\n marginTop : 0,\n limit : 0,\n bottom : -1,\n zIndex : 1000,\n baseClassName: 'scroll-to-fixed-fixed'\n };\n\n // Returns enhanced elements that will fix to the top of the page when the\n // page is scrolled.\n $.fn.scrollToFixed = function(options) {\n return this.each(function() {\n (new $.ScrollToFixed(this, options));\n });\n };\n})(jQuery);\n"]} \ No newline at end of file From 4b2ee2d862daca13bac234f0b84f480c287a2c56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BD=D0=B8=D0=B8=D0=BB=20=D0=9F=D1=80=D0=BE?= =?UTF-8?q?=D0=BD=D0=B8=D0=BD?= Date: Sun, 4 Sep 2016 12:24:02 +1000 Subject: [PATCH 08/11] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7d0876a..8f7c85b 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ *More [fiddle](http://jsfiddle.net/) demo links [below](#demos).* -ScrollToFixed +ScrollToFixed [![Build Status](https://travis-ci.org/Grawl/ScrollToFixed.svg?branch=master)](https://travis-ci.org/Grawl/ScrollToFixed) ========================== This jQuery plugin is used to fix elements on the page (top, bottom, anywhere); however, it still allows the element to continue to move left or right with the horizontal scroll. From 693a21777a31cecb2aa54ebe3ab31b8a7b705767 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BD=D0=B8=D0=B8=D0=BB=20=D0=9F=D1=80=D0=BE?= =?UTF-8?q?=D0=BD=D0=B8=D0=BD?= Date: Sun, 4 Sep 2016 22:21:34 +1000 Subject: [PATCH 09/11] fix deploy script --- deploy.sh | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) mode change 100644 => 100755 deploy.sh diff --git a/deploy.sh b/deploy.sh old mode 100644 new mode 100755 index 37422a9..7763dc6 --- a/deploy.sh +++ b/deploy.sh @@ -2,12 +2,16 @@ set -e # Exit with nonzero exit code if anything fails git checkout master npm run gulp -if [ -z `git diff --exit-code` ]; then - echo "No changes to the output on this push; exiting." +if [[ `git status --porcelain` ]]; then + echo "There are changes to publish!" + git status + exit 0 + git add . + git remote add deployment https://${USER}:${PASSWORD}@github.com/${TRAVIS_REPO_SLUG}.git + git config user.name "Travis CI" + git commit -m "Travis CI $TRAVIS_COMMIT" + git push -u deployment master +else + echo "No changes to the output on this push; exiting." exit 0 fi -git add . -git remote add deployment https://$USER:$PASSWORD@github.com/$TRAVIS_REPO_SLUG.git -git config user.name "Travis CI" -git commit -m "Travis CI $TRAVIS_COMMIT" -git push -u deployment master From 970dde3a1c9d2e194ed84a60faeca940e314a714 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Sun, 4 Sep 2016 22:54:59 +1000 Subject: [PATCH 10/11] Travis CI [skip ci] --- deploy.sh | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/deploy.sh b/deploy.sh index 7763dc6..6d653d0 100755 --- a/deploy.sh +++ b/deploy.sh @@ -1,16 +1,29 @@ #!/bin/bash set -e # Exit with nonzero exit code if anything fails +TRAVIS_PULL_REQUEST="true" +function build() { + npm run gulp +} +# Pull requests and commits to other branches shouldn't try to deploy, just build to verify +if [ "$TRAVIS_PULL_REQUEST" != "false" -o ]; then + echo "Skipping deploy; just doing a build." + build + exit 0 +fi +# let's go back from Travis auto-generated branch to out target branch for publishing git checkout master -npm run gulp +# run our build process +build +# check if there are changes generated by build if [[ `git status --porcelain` ]]; then echo "There are changes to publish!" git status - exit 0 git add . git remote add deployment https://${USER}:${PASSWORD}@github.com/${TRAVIS_REPO_SLUG}.git git config user.name "Travis CI" - git commit -m "Travis CI $TRAVIS_COMMIT" + git commit -m "Travis CI $TRAVIS_COMMIT [skip ci]" git push -u deployment master +# if no changes generated by build else echo "No changes to the output on this push; exiting." exit 0 From a65b3bb5e112f6f8cc2dc443d7252590c06e663d Mon Sep 17 00:00:00 2001 From: Travis CI Date: Mon, 5 Sep 2016 03:29:57 +1000 Subject: [PATCH 11/11] update Travis CI deployment --- build.sh | 2 ++ deploy.sh | 90 +++++++++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 77 insertions(+), 15 deletions(-) create mode 100644 build.sh diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..b1d3426 --- /dev/null +++ b/build.sh @@ -0,0 +1,2 @@ +#!/bin/bash +npm run gulp diff --git a/deploy.sh b/deploy.sh index 6d653d0..351d395 100755 --- a/deploy.sh +++ b/deploy.sh @@ -1,30 +1,90 @@ #!/bin/bash -set -e # Exit with nonzero exit code if anything fails -TRAVIS_PULL_REQUEST="true" -function build() { - npm run gulp +# This is a Bash shell script to use with [Travis Continuous Integration](https://travis-ci.org) +# It will build your project as you will configure Travis CI, and if there will be any changes, it will push them into your repository as a commit. Basically, this script will push any added or removed files by your build process. +# For example: if you update `some-script.js`, you want to minify it and push as `some-script.min.js`. Travis CI can launch your build script on it's own server just after you push `some-script.js` and then it will push updated `some-script.min.js`. +# To use it, you have to authenticate on Travis CI and enable Continuous Integration for this project, then open settings and add some environment variables to allow Travis CI to push into your repository: +# `GIT_HOST` – server hostname, `github.com` by default +# `GIT_USER` – username +# `GIT_PASSWORD` – password +# Don't worry, [you can trust Travis](https://docs.travis-ci.com/user/environment-variables/#Defining-Variables-in-Repository-Settings) +# Also, you have to add `.travis.yml` file with this: + +# script: bash ./deploy.sh + +# Configuring Travis CI [is not hard](https://docs.travis-ci.com/user/getting-started/), just few lines and you are a pilot! + +# And after, you can change this function to what you want to do to build your project: +function build { + bash ./build.sh } -# Pull requests and commits to other branches shouldn't try to deploy, just build to verify -if [ "$TRAVIS_PULL_REQUEST" != "false" -o ]; then - echo "Skipping deploy; just doing a build." + +# I am using some Travis environment variables like `TRAVIS` or `TRAVIS_COMMIT` here, you can look their output in [Travis CI Documentation](https://docs.travis-ci.com/user/environment-variables/#Default-Environment-Variables) + +set -e # Exit with nonzero exit code if anything fails +# set -x # Enable debug mode. It will print every executed line into log. Do not forget to clear any public logs after debug build that prints your sensitive data like passwords! +if [ ! "$TRAVIS" ]; then + echo "This script should work only on Travis CI server" + # Remove this code if you want to debug this script + exit 0 +fi +# Pull requests shouldn't try to deploy, just build to verify +if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then + echo "Should not deploy pull request; just doing a build." build exit 0 fi -# let's go back from Travis auto-generated branch to out target branch for publishing -git checkout master -# run our build process +SETTINGS_URL="https://travis-ci.org/${TRAVIS_REPO_SLUG}/settings" +if [ ! "$GIT_USER" ]; then + echo "Cannot push without git credentials: no user provided; set up GIT_USER environment variable in Travis CI project settings: ${SETTINGS_URL}" + # There is no reason to continue deploy without push – the target action of this script + exit 0 +fi +if [ ! "$GIT_PASSWORD" ]; then + echo "Cannot push without git credentials: no password provided; set up GIT_PASSWORD environment variable in Travis CI project settings: ${SETTINGS_URL}" + # There is no reason to continue deploy without push – the target action of this script + exit 0 +fi +if [ ! "$GIT_HOST" ]; then + echo "Cannot push without git credentials: no host provided; using GitHub.com as a default." + echo "You can set up GIT_HOST environment variable in Travis CI project settings: ${SETTINGS_URL}" + # You can skip defining this variable if your project are hosted on GitHub.com + GIT_HOST="github.com" +fi +if [ ! "$SOURCE_BRANCH" ]; then + echo "You are not provided a source git branch; using current Travis CI branch as a default." + echo "You can set up SOURCE_BRANCH environment variable in Travis CI project settings: ${SETTINGS_URL}" + # You can skip defining this variable if you want to deploy to the same branch + SOURCE_BRANCH=$TRAVIS_BRANCH +fi +if [ ! "$TARGET_BRANCH" ]; then + echo "You are not provided a target git branch; using current Travis CI branch as a default." + echo "You can set up TARGET_BRANCH environment variable in Travis CI project settings: ${SETTINGS_URL}" + # You can skip defining this variable if you want to deploy to the same branch + # TODO: add specific behaviour if SOURCE_BRANCH != TARGET_BRANCH (gh-pages for example) + TARGET_BRANCH=$TRAVIS_BRANCH +fi +# If we want to deploy, we want to push. But Travis CI doing `git checkout -qf ${TRAVIS_COMMIT}` and there comes a detached HEAD. I don't want to figure out this shit, just let's checkout from detached HEAD into source branch. +git checkout ${SOURCE_BRANCH} +# Now let's build our project to know if there are will be any changes: build -# check if there are changes generated by build +# Check if there are changes generated by build: if [[ `git status --porcelain` ]]; then echo "There are changes to publish!" - git status + git status # debug + # Add any changes to index git add . - git remote add deployment https://${USER}:${PASSWORD}@github.com/${TRAVIS_REPO_SLUG}.git + # Tell everyone that this changes is pushed by Travis CI: git config user.name "Travis CI" + # Author email will contain server address where this build done and looks like [this](travis@testing-worker-linux-docker-c84a3a30-3437-linux-5.prod.travis-ci.org) + # Add `[skip ci]` to commit message to not start Travis CI build from push of this deployment commit git commit -m "Travis CI $TRAVIS_COMMIT [skip ci]" - git push -u deployment master -# if no changes generated by build + # Build HTTPS git remote from Travis CI project environment variables + git remote add deployment https://${GIT_USER}:${GIT_PASSWORD}@${GIT_HOST}/${TRAVIS_REPO_SLUG}.git + # Push changes to target branch + git push -u deployment ${TARGET_BRANCH} +# If no changes generated by build: else echo "No changes to the output on this push; exiting." exit 0 fi +# I am scripting in Bash for the first time. Many thanks to [Domenic Denicola](https://github.com/domenic) for his [GitHub Pages publish script](https://gist.github.com/domenic/ec8b0fc8ab45f39403dd).