Skip to content

Commit b4acccf

Browse files
Updated component to version 2.2.0
1 parent 4642a47 commit b4acccf

File tree

9 files changed

+112
-51
lines changed

9 files changed

+112
-51
lines changed

RELEASE-NOTES.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
### Version 2.2.0 - June 26, 2016
2+
3+
- **All UI** - Added new setting `silent` to all modules which allows you to disable all console output including errors. This can be useful for preventing known errors, like a popup which cannot place itself on screen, or `sticky` content which initializes before it is visible [#3713](https://github.com/Semantic-Org/Semantic-UI/issues/3713)
4+
- **Image** - `transition hidden image` now shows correctly as `visibility: hidden;` and not `display: none`. This will allow `offset` with `visibility` and `sticky` to work more seamlessly. `hidden image` will still remain `display: none;`
5+
- **Sticky/Visibility** - Added mutation observer to teardown element with `destroy` if removed from DOM context, fixing a possible memory leak
6+
17
### Version 2.1.7 - Dec 19, 2015
28

39
- **Sticky** - Renames variables used to account for scroll offset internally for greater code clarity
@@ -14,7 +20,7 @@
1420
### Version 2.0.4 - July 17, 2015
1521

1622
- **Sticky** - Fixed `sticky` element that cannot fit in viewport not scrolling correctly when fixed to viewport [#2605](https://github.com/Semantic-Org/Semantic-UI/issues/2605)
17-
- **Sticky** - Fixed `sticky` content jumping from `fixed` to `bount bottom` when scroll position has surpassed bottom of container during page refresh.
23+
- **Sticky** - Fixed `sticky` content jumping from `fixed` to `bound bottom` when scroll position has surpassed bottom of container during page refresh.
1824
- **Sticky** - Sticky no longer uses `bottomPadding` to determine bottom edge of container.
1925

2026
### Version 2.0.0 - June 30, 2015

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
"framework"
1616
],
1717
"license": "MIT",
18-
"version": "2.1.7"
18+
"version": "2.2.0"
1919
}

index.js

Lines changed: 49 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
11
/*!
2-
* # Semantic UI 2.1.7 - Sticky
2+
* # Semantic UI 2.2.0 - Sticky
33
* http://github.com/semantic-org/semantic-ui/
44
*
55
*
6-
* Copyright 2015 Contributors
76
* Released under the MIT license
87
* http://opensource.org/licenses/MIT
98
*
109
*/
1110

12-
;(function ( $, window, document, undefined ) {
11+
;(function ($, window, document, undefined) {
1312

1413
"use strict";
1514

15+
window = (typeof window != 'undefined' && window.Math == Math)
16+
? window
17+
: (typeof self != 'undefined' && self.Math == Math)
18+
? self
19+
: Function('return this')()
20+
;
21+
1622
var _module = module;
1723
module.exports = function(parameters) {
1824
var
@@ -58,6 +64,8 @@ module.exports = function(parameters) {
5864
|| function(callback) { setTimeout(callback, 0); },
5965

6066
element = this,
67+
68+
documentObserver,
6169
observer,
6270
module
6371
;
@@ -91,6 +99,9 @@ module.exports = function(parameters) {
9199
destroy: function() {
92100
module.verbose('Destroying previous instance');
93101
module.reset();
102+
if(documentObserver) {
103+
documentObserver.disconnect();
104+
}
94105
if(observer) {
95106
observer.disconnect();
96107
}
@@ -105,22 +116,18 @@ module.exports = function(parameters) {
105116
},
106117

107118
observeChanges: function() {
108-
var
109-
context = $context[0]
110-
;
111119
if('MutationObserver' in window) {
112-
observer = new MutationObserver(function(mutations) {
113-
clearTimeout(module.timer);
114-
module.timer = setTimeout(function() {
115-
module.verbose('DOM tree modified, updating sticky menu', mutations);
116-
module.refresh();
117-
}, 100);
120+
documentObserver = new MutationObserver(module.event.documentChanged);
121+
observer = new MutationObserver(module.event.changed);
122+
documentObserver.observe(document, {
123+
childList : true,
124+
subtree : true
118125
});
119126
observer.observe(element, {
120127
childList : true,
121128
subtree : true
122129
});
123-
observer.observe(context, {
130+
observer.observe($context[0], {
124131
childList : true,
125132
subtree : true
126133
});
@@ -172,6 +179,25 @@ module.exports = function(parameters) {
172179
},
173180

174181
event: {
182+
changed: function(mutations) {
183+
clearTimeout(module.timer);
184+
module.timer = setTimeout(function() {
185+
module.verbose('DOM tree modified, updating sticky menu', mutations);
186+
module.refresh();
187+
}, 100);
188+
},
189+
documentChanged: function(mutations) {
190+
[].forEach.call(mutations, function(mutation) {
191+
if(mutation.removedNodes) {
192+
[].forEach.call(mutation.removedNodes, function(node) {
193+
if(node == element || $(node).find(element).length > 0) {
194+
module.debug('Element removed from DOM, tearing down events');
195+
module.destroy();
196+
}
197+
});
198+
}
199+
});
200+
},
175201
load: function() {
176202
module.verbose('Page contents finished loading');
177203
requestAnimationFrame(module.refresh);
@@ -644,7 +670,7 @@ module.exports = function(parameters) {
644670
},
645671

646672
reset: function() {
647-
module.debug('Reseting elements position');
673+
module.debug('Resetting elements position');
648674
module.unbind();
649675
module.unfix();
650676
module.resetCSS();
@@ -689,7 +715,7 @@ module.exports = function(parameters) {
689715
}
690716
},
691717
debug: function() {
692-
if(settings.debug) {
718+
if(!settings.silent && settings.debug) {
693719
if(settings.performance) {
694720
module.performance.log(arguments);
695721
}
@@ -700,7 +726,7 @@ module.exports = function(parameters) {
700726
}
701727
},
702728
verbose: function() {
703-
if(settings.verbose && settings.debug) {
729+
if(!settings.silent && settings.verbose && settings.debug) {
704730
if(settings.performance) {
705731
module.performance.log(arguments);
706732
}
@@ -711,8 +737,10 @@ module.exports = function(parameters) {
711737
}
712738
},
713739
error: function() {
714-
module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
715-
module.error.apply(console, arguments);
740+
if(!settings.silent) {
741+
module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
742+
module.error.apply(console, arguments);
743+
}
716744
},
717745
performance: {
718746
log: function(message) {
@@ -846,6 +874,7 @@ _module.exports.settings = {
846874
name : 'Sticky',
847875
namespace : 'sticky',
848876

877+
silent : false,
849878
debug : false,
850879
verbose : true,
851880
performance : true,
@@ -889,7 +918,7 @@ _module.exports.settings = {
889918

890919
error : {
891920
container : 'Sticky element must be inside a relative container',
892-
visible : 'Element is hidden, you must call refresh after element becomes visible',
921+
visible : 'Element is hidden, you must call refresh after element becomes visible. Use silent setting to surpress this warning in production.',
893922
method : 'The method you called is not defined.',
894923
invalidContext : 'Context specified does not exist',
895924
elementSize : 'Sticky element is larger than its container, cannot create sticky.'
@@ -905,4 +934,4 @@ _module.exports.settings = {
905934

906935
};
907936

908-
})( require("jquery"), window, document );
937+
})( require("jquery"), window, document );

package.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Package.describe({
33
name : 'semantic:ui-sticky',
44
summary : 'Semantic UI - Sticky: Single component release',
5-
version : '2.1.7',
5+
version : '2.2.0',
66
git : 'git://github.com/Semantic-Org/UI-Sticky.git',
77
});
88

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "semantic-ui-sticky",
3-
"version": "2.1.7",
3+
"version": "2.2.0",
44
"title": "Semantic UI - Sticky",
55
"description": "Single component release of sticky",
66
"homepage": "http://www.semantic-ui.com",

sticky.css

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
/*!
2-
* # Semantic UI 2.1.7 - Sticky
2+
* # Semantic UI 2.2.0 - Sticky
33
* http://github.com/semantic-org/semantic-ui/
44
*
55
*
6-
* Copyright 2015 Contributors
76
* Released under the MIT license
87
* http://opensource.org/licenses/MIT
98
*

sticky.js

Lines changed: 49 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
11
/*!
2-
* # Semantic UI 2.1.7 - Sticky
2+
* # Semantic UI 2.2.0 - Sticky
33
* http://github.com/semantic-org/semantic-ui/
44
*
55
*
6-
* Copyright 2015 Contributors
76
* Released under the MIT license
87
* http://opensource.org/licenses/MIT
98
*
109
*/
1110

12-
;(function ( $, window, document, undefined ) {
11+
;(function ($, window, document, undefined) {
1312

1413
"use strict";
1514

15+
window = (typeof window != 'undefined' && window.Math == Math)
16+
? window
17+
: (typeof self != 'undefined' && self.Math == Math)
18+
? self
19+
: Function('return this')()
20+
;
21+
1622
$.fn.sticky = function(parameters) {
1723
var
1824
$allModules = $(this),
@@ -57,6 +63,8 @@ $.fn.sticky = function(parameters) {
5763
|| function(callback) { setTimeout(callback, 0); },
5864

5965
element = this,
66+
67+
documentObserver,
6068
observer,
6169
module
6270
;
@@ -90,6 +98,9 @@ $.fn.sticky = function(parameters) {
9098
destroy: function() {
9199
module.verbose('Destroying previous instance');
92100
module.reset();
101+
if(documentObserver) {
102+
documentObserver.disconnect();
103+
}
93104
if(observer) {
94105
observer.disconnect();
95106
}
@@ -104,22 +115,18 @@ $.fn.sticky = function(parameters) {
104115
},
105116

106117
observeChanges: function() {
107-
var
108-
context = $context[0]
109-
;
110118
if('MutationObserver' in window) {
111-
observer = new MutationObserver(function(mutations) {
112-
clearTimeout(module.timer);
113-
module.timer = setTimeout(function() {
114-
module.verbose('DOM tree modified, updating sticky menu', mutations);
115-
module.refresh();
116-
}, 100);
119+
documentObserver = new MutationObserver(module.event.documentChanged);
120+
observer = new MutationObserver(module.event.changed);
121+
documentObserver.observe(document, {
122+
childList : true,
123+
subtree : true
117124
});
118125
observer.observe(element, {
119126
childList : true,
120127
subtree : true
121128
});
122-
observer.observe(context, {
129+
observer.observe($context[0], {
123130
childList : true,
124131
subtree : true
125132
});
@@ -171,6 +178,25 @@ $.fn.sticky = function(parameters) {
171178
},
172179

173180
event: {
181+
changed: function(mutations) {
182+
clearTimeout(module.timer);
183+
module.timer = setTimeout(function() {
184+
module.verbose('DOM tree modified, updating sticky menu', mutations);
185+
module.refresh();
186+
}, 100);
187+
},
188+
documentChanged: function(mutations) {
189+
[].forEach.call(mutations, function(mutation) {
190+
if(mutation.removedNodes) {
191+
[].forEach.call(mutation.removedNodes, function(node) {
192+
if(node == element || $(node).find(element).length > 0) {
193+
module.debug('Element removed from DOM, tearing down events');
194+
module.destroy();
195+
}
196+
});
197+
}
198+
});
199+
},
174200
load: function() {
175201
module.verbose('Page contents finished loading');
176202
requestAnimationFrame(module.refresh);
@@ -643,7 +669,7 @@ $.fn.sticky = function(parameters) {
643669
},
644670

645671
reset: function() {
646-
module.debug('Reseting elements position');
672+
module.debug('Resetting elements position');
647673
module.unbind();
648674
module.unfix();
649675
module.resetCSS();
@@ -688,7 +714,7 @@ $.fn.sticky = function(parameters) {
688714
}
689715
},
690716
debug: function() {
691-
if(settings.debug) {
717+
if(!settings.silent && settings.debug) {
692718
if(settings.performance) {
693719
module.performance.log(arguments);
694720
}
@@ -699,7 +725,7 @@ $.fn.sticky = function(parameters) {
699725
}
700726
},
701727
verbose: function() {
702-
if(settings.verbose && settings.debug) {
728+
if(!settings.silent && settings.verbose && settings.debug) {
703729
if(settings.performance) {
704730
module.performance.log(arguments);
705731
}
@@ -710,8 +736,10 @@ $.fn.sticky = function(parameters) {
710736
}
711737
},
712738
error: function() {
713-
module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
714-
module.error.apply(console, arguments);
739+
if(!settings.silent) {
740+
module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
741+
module.error.apply(console, arguments);
742+
}
715743
},
716744
performance: {
717745
log: function(message) {
@@ -845,6 +873,7 @@ $.fn.sticky.settings = {
845873
name : 'Sticky',
846874
namespace : 'sticky',
847875

876+
silent : false,
848877
debug : false,
849878
verbose : true,
850879
performance : true,
@@ -888,7 +917,7 @@ $.fn.sticky.settings = {
888917

889918
error : {
890919
container : 'Sticky element must be inside a relative container',
891-
visible : 'Element is hidden, you must call refresh after element becomes visible',
920+
visible : 'Element is hidden, you must call refresh after element becomes visible. Use silent setting to surpress this warning in production.',
892921
method : 'The method you called is not defined.',
893922
invalidContext : 'Context specified does not exist',
894923
elementSize : 'Sticky element is larger than its container, cannot create sticky.'
@@ -904,4 +933,4 @@ $.fn.sticky.settings = {
904933

905934
};
906935

907-
})( jQuery, window, document );
936+
})( jQuery, window, document );

sticky.min.css

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
/*!
2-
* # Semantic UI 2.1.7 - Sticky
2+
* # Semantic UI 2.2.0 - Sticky
33
* http://github.com/semantic-org/semantic-ui/
44
*
55
*
6-
* Copyright 2015 Contributors
76
* Released under the MIT license
87
* http://opensource.org/licenses/MIT
98
*

0 commit comments

Comments
 (0)