Skip to content

Commit 2cb4688

Browse files
Updated component to version 2.2.11
1 parent d2b64f1 commit 2cb4688

File tree

8 files changed

+59
-18
lines changed

8 files changed

+59
-18
lines changed

RELEASE-NOTES.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
### Version 2.2.11 - July 11, 2017
2+
3+
- **Sticky** - Fix issue where sticky would cause page to shift when `context` height was determined by sticky's height in `position: static;` [#3430](https://github.com/Semantic-Org/Semantic-UI/issues/3430)
4+
- **Sticky** - Sticky now includes a new setting `setSize` to determine whether it should set content size on stick to the size before sticking (fixed content uses different positioning system) [#4360](https://github.com/Semantic-Org/Semantic-UI/issues/4360)
5+
- **Sticky** - Fixed edge case where using `offset` setting, sticky element would not internally scroll if the rail contents (without the offset setting) would fit on screen
6+
- **Sticky** - Fixed an issue where `ui sticky` used with a percentage based width would not resize properly if the content size of container changed when "stuck" [#4360](https://github.com/Semantic-Org/Semantic-UI/issues/4360)
7+
18
### Version 2.2.5 - October, 27, 2016
29

310
- **Sticky** - Adds `container` setting. This can be used to specify the offsetParent of the sticky element and avoid having to calculate on initialization (improving performance)

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.2.10"
18+
"version": "2.2.11"
1919
}

index.js

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* # Semantic UI 2.2.10 - Sticky
2+
* # Semantic UI 2.2.11 - Sticky
33
* http://github.com/semantic-org/semantic-ui/
44
*
55
*
@@ -287,7 +287,8 @@ module.exports = function(parameters) {
287287
context.offset.left += scrollContext.left;
288288
}
289289
module.cache = {
290-
fits : ( element.height < scrollContext.height ),
290+
fits : ( (element.height + settings.offset) <= scrollContext.height),
291+
sameHeight : (element.height == context.height),
291292
scrollContext : {
292293
height : scrollContext.height
293294
},
@@ -306,7 +307,7 @@ module.exports = function(parameters) {
306307
}
307308
};
308309
module.set.containerSize();
309-
module.set.size();
310+
310311
module.stick();
311312
module.debug('Caching element positions', module.cache);
312313
}
@@ -375,6 +376,11 @@ module.exports = function(parameters) {
375376
elementScroll: function(scroll) {
376377
delete module.elementScroll;
377378
},
379+
minimumSize: function() {
380+
$container
381+
.css('min-height', '')
382+
;
383+
},
378384
offset: function() {
379385
$module.css('margin-top', '');
380386
}
@@ -468,6 +474,7 @@ module.exports = function(parameters) {
468474
cachedPosition = scroll || $scroll.scrollTop(),
469475
cache = module.cache,
470476
fits = cache.fits,
477+
sameHeight = cache.sameHeight,
471478
element = cache.element,
472479
scrollContext = cache.scrollContext,
473480
context = cache.context,
@@ -487,8 +494,7 @@ module.exports = function(parameters) {
487494
doesntFit = !fits,
488495
elementVisible = (element.height !== 0)
489496
;
490-
491-
if(elementVisible) {
497+
if(elementVisible && !sameHeight) {
492498

493499
if( module.is.initialPosition() ) {
494500
if(scroll.top >= context.bottom) {
@@ -615,6 +621,9 @@ module.exports = function(parameters) {
615621

616622
fixTop: function() {
617623
module.debug('Fixing element to top of page');
624+
if(settings.setSize) {
625+
module.set.size();
626+
}
618627
module.set.minimumSize();
619628
module.set.offset();
620629
$module
@@ -633,6 +642,9 @@ module.exports = function(parameters) {
633642

634643
fixBottom: function() {
635644
module.debug('Sticking element to bottom of page');
645+
if(settings.setSize) {
646+
module.set.size();
647+
}
636648
module.set.minimumSize();
637649
module.set.offset();
638650
$module
@@ -664,6 +676,7 @@ module.exports = function(parameters) {
664676
unfix: function() {
665677
if( module.is.fixed() ) {
666678
module.debug('Removing fixed position on element');
679+
module.remove.minimumSize();
667680
module.remove.offset();
668681
$module
669682
.removeClass(className.fixed)
@@ -899,7 +912,11 @@ _module.exports.settings = {
899912
// Offset to adjust scroll when attached to bottom of screen
900913
bottomOffset : 0,
901914

902-
jitter : 5, // will only set container height if difference between context and container is larger than this number
915+
// will only set container height if difference between context and container is larger than this number
916+
jitter : 5,
917+
918+
// set width of sticky element when it is fixed to page (used to make sure 100% width is maintained if no fixed size set)
919+
setSize : true,
903920

904921
// Whether to automatically observe changes with Mutation Observers
905922
observeChanges : false,

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.2.10",
3+
"version": "2.2.11",
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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* # Semantic UI 2.2.10 - Sticky
2+
* # Semantic UI 2.2.11 - Sticky
33
* http://github.com/semantic-org/semantic-ui/
44
*
55
*

sticky.js

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* # Semantic UI 2.2.10 - Sticky
2+
* # Semantic UI 2.2.11 - Sticky
33
* http://github.com/semantic-org/semantic-ui/
44
*
55
*
@@ -286,7 +286,8 @@ $.fn.sticky = function(parameters) {
286286
context.offset.left += scrollContext.left;
287287
}
288288
module.cache = {
289-
fits : ( element.height < scrollContext.height ),
289+
fits : ( (element.height + settings.offset) <= scrollContext.height),
290+
sameHeight : (element.height == context.height),
290291
scrollContext : {
291292
height : scrollContext.height
292293
},
@@ -305,7 +306,7 @@ $.fn.sticky = function(parameters) {
305306
}
306307
};
307308
module.set.containerSize();
308-
module.set.size();
309+
309310
module.stick();
310311
module.debug('Caching element positions', module.cache);
311312
}
@@ -374,6 +375,11 @@ $.fn.sticky = function(parameters) {
374375
elementScroll: function(scroll) {
375376
delete module.elementScroll;
376377
},
378+
minimumSize: function() {
379+
$container
380+
.css('min-height', '')
381+
;
382+
},
377383
offset: function() {
378384
$module.css('margin-top', '');
379385
}
@@ -467,6 +473,7 @@ $.fn.sticky = function(parameters) {
467473
cachedPosition = scroll || $scroll.scrollTop(),
468474
cache = module.cache,
469475
fits = cache.fits,
476+
sameHeight = cache.sameHeight,
470477
element = cache.element,
471478
scrollContext = cache.scrollContext,
472479
context = cache.context,
@@ -486,8 +493,7 @@ $.fn.sticky = function(parameters) {
486493
doesntFit = !fits,
487494
elementVisible = (element.height !== 0)
488495
;
489-
490-
if(elementVisible) {
496+
if(elementVisible && !sameHeight) {
491497

492498
if( module.is.initialPosition() ) {
493499
if(scroll.top >= context.bottom) {
@@ -614,6 +620,9 @@ $.fn.sticky = function(parameters) {
614620

615621
fixTop: function() {
616622
module.debug('Fixing element to top of page');
623+
if(settings.setSize) {
624+
module.set.size();
625+
}
617626
module.set.minimumSize();
618627
module.set.offset();
619628
$module
@@ -632,6 +641,9 @@ $.fn.sticky = function(parameters) {
632641

633642
fixBottom: function() {
634643
module.debug('Sticking element to bottom of page');
644+
if(settings.setSize) {
645+
module.set.size();
646+
}
635647
module.set.minimumSize();
636648
module.set.offset();
637649
$module
@@ -663,6 +675,7 @@ $.fn.sticky = function(parameters) {
663675
unfix: function() {
664676
if( module.is.fixed() ) {
665677
module.debug('Removing fixed position on element');
678+
module.remove.minimumSize();
666679
module.remove.offset();
667680
$module
668681
.removeClass(className.fixed)
@@ -898,7 +911,11 @@ $.fn.sticky.settings = {
898911
// Offset to adjust scroll when attached to bottom of screen
899912
bottomOffset : 0,
900913

901-
jitter : 5, // will only set container height if difference between context and container is larger than this number
914+
// will only set container height if difference between context and container is larger than this number
915+
jitter : 5,
916+
917+
// set width of sticky element when it is fixed to page (used to make sure 100% width is maintained if no fixed size set)
918+
setSize : true,
902919

903920
// Whether to automatically observe changes with Mutation Observers
904921
observeChanges : false,

sticky.min.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* # Semantic UI 2.2.10 - Sticky
2+
* # Semantic UI 2.2.11 - Sticky
33
* http://github.com/semantic-org/semantic-ui/
44
*
55
*

0 commit comments

Comments
 (0)