diff --git a/composer.json b/composer.json index df4d4b3..9d38a31 100755 --- a/composer.json +++ b/composer.json @@ -15,5 +15,5 @@ "framework" ], "license": "MIT", - "version": "1.10.2" + "version": "1.10.4" } \ No newline at end of file diff --git a/index.js b/index.js index 38ca893..a1a54a2 100755 --- a/index.js +++ b/index.js @@ -1,9 +1,9 @@ - /* - * # Semantic - Sticky +/*! + * # Semantic UI 1.10.4 - Sticky * http://github.com/semantic-org/semantic-ui/ * * - * Copyright 2014 Contributors + * Copyright 2014 Contributorss * Released under the MIT license * http://opensource.org/licenses/MIT * @@ -93,8 +93,9 @@ module.exports = function(parameters) { $scroll .on('scroll' + eventNamespace, module.event.scroll) ; - - module.observeChanges(); + if(settings.observeChanges) { + module.observeChanges(); + } module.instantiate(); }, @@ -127,25 +128,23 @@ module.exports = function(parameters) { var context = $context[0] ; - if(settings.observeChanges) { - if('MutationObserver' in window) { - observer = new MutationObserver(function(mutations) { - clearTimeout(module.timer); - module.timer = setTimeout(function() { - module.verbose('DOM tree modified, updating sticky menu'); - module.refresh(); - }, 200); - }); - observer.observe(element, { - childList : true, - subtree : true - }); - observer.observe(context, { - childList : true, - subtree : true - }); - module.debug('Setting up mutation observer', observer); - } + if('MutationObserver' in window) { + observer = new MutationObserver(function(mutations) { + clearTimeout(module.timer); + module.timer = setTimeout(function() { + module.verbose('DOM tree modified, updating sticky menu'); + module.refresh(); + }, 20); + }); + observer.observe(element, { + childList : true, + subtree : true + }); + observer.observe(context, { + childList : true, + subtree : true + }); + module.debug('Setting up mutation observer', observer); } }, diff --git a/package.js b/package.js index 304c0dc..cd99705 100755 --- a/package.js +++ b/package.js @@ -2,7 +2,7 @@ Package.describe({ name : 'semantic:ui-sticky', summary : 'Semantic UI - Sticky: Single component release', - version : '1.10.2', + version : '1.10.4', git : 'git://github.com/Semantic-Org/UI-Sticky.git', }); diff --git a/package.json b/package.json index da74e05..eb28634 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "semantic-ui-sticky", - "version": "1.10.2", + "version": "1.10.4", "title": "Semantic UI - Sticky", "description": "Single component release of sticky", "homepage": "http://www.semantic-ui.com", diff --git a/sticky.css b/sticky.css index 5c07d4a..c8a62d1 100755 --- a/sticky.css +++ b/sticky.css @@ -1,7 +1,7 @@ - /* - * # Semantic UI - 1.10.2 - * https://github.com/Semantic-Org/Semantic-UI - * http://www.semantic-ui.com/ +/*! + * # Semantic UI 1.10.4 - Sticky + * http://github.com/semantic-org/semantic-ui/ + * * * Copyright 2014 Contributors * Released under the MIT license @@ -10,7 +10,6 @@ */ - /******************************* Sticky *******************************/ diff --git a/sticky.js b/sticky.js index 6354f90..db5e6ca 100755 --- a/sticky.js +++ b/sticky.js @@ -1,9 +1,9 @@ - /* - * # Semantic - Sticky +/*! + * # Semantic UI 1.10.4 - Sticky * http://github.com/semantic-org/semantic-ui/ * * - * Copyright 2014 Contributors + * Copyright 2014 Contributorss * Released under the MIT license * http://opensource.org/licenses/MIT * @@ -91,8 +91,9 @@ $.fn.sticky = function(parameters) { $scroll .on('scroll' + eventNamespace, module.event.scroll) ; - - module.observeChanges(); + if(settings.observeChanges) { + module.observeChanges(); + } module.instantiate(); }, @@ -125,25 +126,23 @@ $.fn.sticky = function(parameters) { var context = $context[0] ; - if(settings.observeChanges) { - if('MutationObserver' in window) { - observer = new MutationObserver(function(mutations) { - clearTimeout(module.timer); - module.timer = setTimeout(function() { - module.verbose('DOM tree modified, updating sticky menu'); - module.refresh(); - }, 200); - }); - observer.observe(element, { - childList : true, - subtree : true - }); - observer.observe(context, { - childList : true, - subtree : true - }); - module.debug('Setting up mutation observer', observer); - } + if('MutationObserver' in window) { + observer = new MutationObserver(function(mutations) { + clearTimeout(module.timer); + module.timer = setTimeout(function() { + module.verbose('DOM tree modified, updating sticky menu'); + module.refresh(); + }, 20); + }); + observer.observe(element, { + childList : true, + subtree : true + }); + observer.observe(context, { + childList : true, + subtree : true + }); + module.debug('Setting up mutation observer', observer); } }, diff --git a/sticky.min.css b/sticky.min.css index 29ea6ca..deadf44 100755 --- a/sticky.min.css +++ b/sticky.min.css @@ -1,11 +1,10 @@ - /* - * # Semantic UI - 1.10.2 - * https://github.com/Semantic-Org/Semantic-UI - * http://www.semantic-ui.com/ +/*! + * # Semantic UI 1.10.4 - Sticky + * http://github.com/semantic-org/semantic-ui/ + * * * Copyright 2014 Contributors * Released under the MIT license * http://opensource.org/licenses/MIT * - */ -.ui.sticky{position:static;-webkit-transition:width .2s ease,height .2s ease,top .2s ease,bottom .2s ease;transition:width .2s ease,height .2s ease,top .2s ease,bottom .2s ease;z-index:800}.ui.sticky.bound{position:absolute;left:auto;right:auto}.ui.sticky.fixed{position:fixed;left:auto;right:auto}.ui.sticky.bound.top,.ui.sticky.fixed.top{top:0;bottom:auto}.ui.sticky.bound.bottom,.ui.sticky.fixed.bottom{top:auto;bottom:0}.ui.native.sticky{position:-webkit-sticky;position:-moz-sticky;position:-ms-sticky;position:-o-sticky;position:sticky} \ No newline at end of file + */.ui.sticky{position:static;-webkit-transition:width .2s ease,height .2s ease,top .2s ease,bottom .2s ease;transition:width .2s ease,height .2s ease,top .2s ease,bottom .2s ease;z-index:800}.ui.sticky.bound{position:absolute;left:auto;right:auto}.ui.sticky.fixed{position:fixed;left:auto;right:auto}.ui.sticky.bound.top,.ui.sticky.fixed.top{top:0;bottom:auto}.ui.sticky.bound.bottom,.ui.sticky.fixed.bottom{top:auto;bottom:0}.ui.native.sticky{position:-webkit-sticky;position:-moz-sticky;position:-ms-sticky;position:-o-sticky;position:sticky} \ No newline at end of file diff --git a/sticky.min.js b/sticky.min.js index 72fdee3..3fc229f 100755 --- a/sticky.min.js +++ b/sticky.min.js @@ -1,11 +1,11 @@ - /* - * # Semantic UI - 1.10.2 - * https://github.com/Semantic-Org/Semantic-UI - * http://www.semantic-ui.com/ +/*! + * # Semantic UI 1.10.4 - Sticky + * http://github.com/semantic-org/semantic-ui/ * - * Copyright 2014 Contributors + * + * Copyright 2014 Contributorss * Released under the MIT license * http://opensource.org/licenses/MIT * */ -!function(e,t,o,n){"use strict";e.fn.sticky=function(o){var i,s=e(this),r=s.selector||"",c=(new Date).getTime(),a=[],l=arguments[0],f="string"==typeof l,m=[].slice.call(arguments,1);return s.each(function(){var s,u,d,h=e.extend(!0,{},e.fn.sticky.settings,o),g=h.className,p=h.namespace,b=h.error,v="."+p,x="module-"+p,C=e(this),S=e(t),y=C.offsetParent(),k=e(h.scrollContext),T=(C.selector||"",C.data(x)),w=t.requestAnimationFrame||t.mozRequestAnimationFrame||t.webkitRequestAnimationFrame||t.msRequestAnimationFrame||function(e){setTimeout(e,0)},z=this;d={initialize:function(){return s=h.context?e(h.context):y,0===s.length?void d.error(b.invalidContext,h.context,C):(d.verbose("Initializing sticky",h,y),d.save.positions(),d.is.hidden()&&d.error(b.visible,C),d.cache.element.height>d.cache.context.height?(d.reset(),void d.error(b.elementSize,C)):(S.on("resize"+v,d.event.resize),k.on("scroll"+v,d.event.scroll),d.observeChanges(),void d.instantiate()))},instantiate:function(){d.verbose("Storing instance of module",d),T=d,C.data(x,d)},destroy:function(){d.verbose("Destroying previous module"),d.reset(),u&&u.disconnect(),S.off("resize"+v,d.event.resize),k.off("scroll"+v,d.event.scroll),C.removeData(x)},observeChanges:function(){var e=s[0];h.observeChanges&&"MutationObserver"in t&&(u=new MutationObserver(function(){clearTimeout(d.timer),d.timer=setTimeout(function(){d.verbose("DOM tree modified, updating sticky menu"),d.refresh()},200)}),u.observe(z,{childList:!0,subtree:!0}),u.observe(e,{childList:!0,subtree:!0}),d.debug("Setting up mutation observer",u))},event:{resize:function(){w(function(){d.refresh(),d.stick()})},scroll:function(){w(function(){d.stick(),h.onScroll.call(z)})}},refresh:function(e){d.reset(),e&&(y=C.offsetParent()),d.save.positions(),d.stick(),h.onReposition.call(z)},supports:{sticky:function(){{var t=e("
");t.get()}return t.addClass(g.supported),t.css("position").match("sticky")}},save:{scroll:function(e){d.lastScroll=e},positions:function(){var e={height:S.height()},t={margin:{top:parseInt(C.css("margin-top"),10),bottom:parseInt(C.css("margin-bottom"),10)},offset:C.offset(),width:C.outerWidth(),height:C.outerHeight()},o={offset:s.offset(),height:s.outerHeight()};d.cache={fits:t.heighte&&(t="up")),t},scrollChange:function(e){return e=e||k.scrollTop(),d.lastScroll?e-d.lastScroll:0},currentElementScroll:function(){return d.is.top()?Math.abs(parseInt(C.css("top"),10))||0:Math.abs(parseInt(C.css("bottom"),10))||0},elementScroll:function(e){e=e||k.scrollTop();var t,o=d.cache.element,n=d.cache.window,i=d.get.scrollChange(e),s=o.height-n.height+h.offset,r=d.get.currentElementScroll(),c=r+i;return t=d.cache.fits||0>c?0:c>s?s:c}},remove:{offset:function(){C.css("margin-top","")}},set:{offset:function(){d.verbose("Setting offset on element",h.offset),C.css("margin-top",h.offset)},containerSize:function(){var e=y.get(0).tagName;"HTML"===e||"body"==e?y=C.offsetParent():(d.debug("Settings container size",d.cache.context.height),Math.abs(y.height()-d.cache.context.height)>5&&y.height(d.cache.context.height))},scroll:function(e){d.debug("Setting scroll on element",e),d.is.top()&&C.css("bottom","").css("top",-e),d.is.bottom()&&C.css("top","").css("bottom",e)},size:function(){0!==d.cache.element.height&&0!==d.cache.element.width&&C.css({width:d.cache.element.width,height:d.cache.element.height})}},is:{top:function(){return C.hasClass(g.top)},bottom:function(){return C.hasClass(g.bottom)},initialPosition:function(){return!d.is.fixed()&&!d.is.bound()},hidden:function(){return!C.is(":visible")},bound:function(){return C.hasClass(g.bound)},fixed:function(){return C.hasClass(g.fixed)}},stick:function(){var e=d.cache,t=e.fits,o=e.element,n=e.window,i=e.context,s=d.is.bottom()&&h.pushing?h.bottomOffset:h.offset,r={top:k.scrollTop()+s,bottom:k.scrollTop()+s+n.height},c=(d.get.direction(r.top),d.get.elementScroll(r.top)),a=!t,l=0!==o.height;d.save.scroll(r.top),l&&(d.is.initialPosition()?r.top>=o.top&&(d.debug("Element passed, fixing element to page"),d.fixTop()):d.is.fixed()?d.is.top()?r.topi.bottom?(d.debug("Fixed element reached bottom of container"),d.bindBottom()):a&&d.set.scroll(c):d.is.bottom()&&(r.bottom-o.heighti.bottom?(d.debug("Bottom fixed rail has reached bottom of container"),d.bindBottom()):a&&d.set.scroll(c)):d.is.bottom()&&(h.pushing?d.is.bound()&&r.bottom0&&(console.groupCollapsed(t),console.table?console.table(a):e.each(a,function(e,t){console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.groupEnd()),a=[]}},invoke:function(t,o,s){var r,c,a,l=T;return o=o||m,s=z||s,"string"==typeof t&&l!==n&&(t=t.split(/[\. ]/),r=t.length-1,e.each(t,function(o,i){var s=o!=r?i+t[o+1].charAt(0).toUpperCase()+t[o+1].slice(1):t;if(e.isPlainObject(l[s])&&o!=r)l=l[s];else{if(l[s]!==n)return c=l[s],!1;if(!e.isPlainObject(l[i])||o==r)return l[i]!==n?(c=l[i],!1):!1;l=l[i]}})),e.isFunction(c)?a=c.apply(s,o):c!==n&&(a=c),e.isArray(i)?i.push(a):i!==n?i=[i,a]:a!==n&&(i=a),c}},f?(T===n&&d.initialize(),d.invoke(l)):(T!==n&&T.invoke("destroy"),d.initialize())}),i!==n?i:this},e.fn.sticky.settings={name:"Sticky",namespace:"sticky",debug:!1,verbose:!1,performance:!1,pushing:!1,context:!1,scrollContext:t,offset:0,bottomOffset:0,observeChanges:!0,onReposition:function(){},onScroll:function(){},onStick:function(){},onUnstick:function(){},onTop:function(){},onBottom:function(){},error:{container:"Sticky element must be inside a relative container",visible:"Element is hidden, you must call refresh after element becomes visible",method:"The method you called is not defined.",invalidContext:"Context specified does not exist",elementSize:"Sticky element is larger than its container, cannot create sticky."},className:{bound:"bound",fixed:"fixed",supported:"native",top:"top",bottom:"bottom"}}}(jQuery,window,document); \ No newline at end of file +!function(e,t,o,n){"use strict";e.fn.sticky=function(o){var i,s=e(this),r=s.selector||"",c=(new Date).getTime(),a=[],l=arguments[0],f="string"==typeof l,m=[].slice.call(arguments,1);return s.each(function(){var s,u,d,h=e.extend(!0,{},e.fn.sticky.settings,o),g=h.className,p=h.namespace,b=h.error,v="."+p,x="module-"+p,C=e(this),S=e(t),y=C.offsetParent(),k=e(h.scrollContext),T=(C.selector||"",C.data(x)),w=t.requestAnimationFrame||t.mozRequestAnimationFrame||t.webkitRequestAnimationFrame||t.msRequestAnimationFrame||function(e){setTimeout(e,0)},z=this;d={initialize:function(){return s=h.context?e(h.context):y,0===s.length?void d.error(b.invalidContext,h.context,C):(d.verbose("Initializing sticky",h,y),d.save.positions(),d.is.hidden()&&d.error(b.visible,C),d.cache.element.height>d.cache.context.height?(d.reset(),void d.error(b.elementSize,C)):(S.on("resize"+v,d.event.resize),k.on("scroll"+v,d.event.scroll),h.observeChanges&&d.observeChanges(),void d.instantiate()))},instantiate:function(){d.verbose("Storing instance of module",d),T=d,C.data(x,d)},destroy:function(){d.verbose("Destroying previous module"),d.reset(),u&&u.disconnect(),S.off("resize"+v,d.event.resize),k.off("scroll"+v,d.event.scroll),C.removeData(x)},observeChanges:function(){var e=s[0];"MutationObserver"in t&&(u=new MutationObserver(function(){clearTimeout(d.timer),d.timer=setTimeout(function(){d.verbose("DOM tree modified, updating sticky menu"),d.refresh()},20)}),u.observe(z,{childList:!0,subtree:!0}),u.observe(e,{childList:!0,subtree:!0}),d.debug("Setting up mutation observer",u))},event:{resize:function(){w(function(){d.refresh(),d.stick()})},scroll:function(){w(function(){d.stick(),h.onScroll.call(z)})}},refresh:function(e){d.reset(),e&&(y=C.offsetParent()),d.save.positions(),d.stick(),h.onReposition.call(z)},supports:{sticky:function(){{var t=e("
");t.get()}return t.addClass(g.supported),t.css("position").match("sticky")}},save:{scroll:function(e){d.lastScroll=e},positions:function(){var e={height:S.height()},t={margin:{top:parseInt(C.css("margin-top"),10),bottom:parseInt(C.css("margin-bottom"),10)},offset:C.offset(),width:C.outerWidth(),height:C.outerHeight()},o={offset:s.offset(),height:s.outerHeight()};d.cache={fits:t.heighte&&(t="up")),t},scrollChange:function(e){return e=e||k.scrollTop(),d.lastScroll?e-d.lastScroll:0},currentElementScroll:function(){return d.is.top()?Math.abs(parseInt(C.css("top"),10))||0:Math.abs(parseInt(C.css("bottom"),10))||0},elementScroll:function(e){e=e||k.scrollTop();var t,o=d.cache.element,n=d.cache.window,i=d.get.scrollChange(e),s=o.height-n.height+h.offset,r=d.get.currentElementScroll(),c=r+i;return t=d.cache.fits||0>c?0:c>s?s:c}},remove:{offset:function(){C.css("margin-top","")}},set:{offset:function(){d.verbose("Setting offset on element",h.offset),C.css("margin-top",h.offset)},containerSize:function(){var e=y.get(0).tagName;"HTML"===e||"body"==e?y=C.offsetParent():(d.debug("Settings container size",d.cache.context.height),Math.abs(y.height()-d.cache.context.height)>5&&y.height(d.cache.context.height))},scroll:function(e){d.debug("Setting scroll on element",e),d.is.top()&&C.css("bottom","").css("top",-e),d.is.bottom()&&C.css("top","").css("bottom",e)},size:function(){0!==d.cache.element.height&&0!==d.cache.element.width&&C.css({width:d.cache.element.width,height:d.cache.element.height})}},is:{top:function(){return C.hasClass(g.top)},bottom:function(){return C.hasClass(g.bottom)},initialPosition:function(){return!d.is.fixed()&&!d.is.bound()},hidden:function(){return!C.is(":visible")},bound:function(){return C.hasClass(g.bound)},fixed:function(){return C.hasClass(g.fixed)}},stick:function(){var e=d.cache,t=e.fits,o=e.element,n=e.window,i=e.context,s=d.is.bottom()&&h.pushing?h.bottomOffset:h.offset,r={top:k.scrollTop()+s,bottom:k.scrollTop()+s+n.height},c=(d.get.direction(r.top),d.get.elementScroll(r.top)),a=!t,l=0!==o.height;d.save.scroll(r.top),l&&(d.is.initialPosition()?r.top>=o.top&&(d.debug("Element passed, fixing element to page"),d.fixTop()):d.is.fixed()?d.is.top()?r.topi.bottom?(d.debug("Fixed element reached bottom of container"),d.bindBottom()):a&&d.set.scroll(c):d.is.bottom()&&(r.bottom-o.heighti.bottom?(d.debug("Bottom fixed rail has reached bottom of container"),d.bindBottom()):a&&d.set.scroll(c)):d.is.bottom()&&(h.pushing?d.is.bound()&&r.bottom0&&(console.groupCollapsed(t),console.table?console.table(a):e.each(a,function(e,t){console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.groupEnd()),a=[]}},invoke:function(t,o,s){var r,c,a,l=T;return o=o||m,s=z||s,"string"==typeof t&&l!==n&&(t=t.split(/[\. ]/),r=t.length-1,e.each(t,function(o,i){var s=o!=r?i+t[o+1].charAt(0).toUpperCase()+t[o+1].slice(1):t;if(e.isPlainObject(l[s])&&o!=r)l=l[s];else{if(l[s]!==n)return c=l[s],!1;if(!e.isPlainObject(l[i])||o==r)return l[i]!==n?(c=l[i],!1):!1;l=l[i]}})),e.isFunction(c)?a=c.apply(s,o):c!==n&&(a=c),e.isArray(i)?i.push(a):i!==n?i=[i,a]:a!==n&&(i=a),c}},f?(T===n&&d.initialize(),d.invoke(l)):(T!==n&&T.invoke("destroy"),d.initialize())}),i!==n?i:this},e.fn.sticky.settings={name:"Sticky",namespace:"sticky",debug:!1,verbose:!1,performance:!1,pushing:!1,context:!1,scrollContext:t,offset:0,bottomOffset:0,observeChanges:!0,onReposition:function(){},onScroll:function(){},onStick:function(){},onUnstick:function(){},onTop:function(){},onBottom:function(){},error:{container:"Sticky element must be inside a relative container",visible:"Element is hidden, you must call refresh after element becomes visible",method:"The method you called is not defined.",invalidContext:"Context specified does not exist",elementSize:"Sticky element is larger than its container, cannot create sticky."},className:{bound:"bound",fixed:"fixed",supported:"native",top:"top",bottom:"bottom"}}}(jQuery,window,document); \ No newline at end of file