Skip to content

Commit

Permalink
Updated component to version 2.1.6
Browse files Browse the repository at this point in the history
  • Loading branch information
Semantic-Pusher-Robot committed Nov 6, 2015
1 parent a5af980 commit 07dc9c4
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 49 deletions.
5 changes: 5 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
### Version 2.1.5 - Nov 1, 2015

- **Sticky** - Fixes bug where sticky would stick at incorrect times when using a different scroll container than `body` and scrollTop is not 0 on page load.
- **Sticky** - Fixed issue where pressing home/end button would cause sticky to break due to internal logic not allowing immediate jump from bottom attached to top attached, experienced most likely when pressing "home" or "end" key [#3011](https://github.com/Semantic-Org/Semantic-UI/issues/3011)

#### Bugs

- **Sticky** - Sticky now sets width and height with `!important` to avoid inheritance issues in some cases **Thanks @lauri-elevant** [#2710](https://github.com/Semantic-Org/Semantic-UI/issues/2710)
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
"framework"
],
"license": "MIT",
"version": "2.1.4"
"version": "2.1.6"
}
62 changes: 41 additions & 21 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* # Semantic UI 2.1.4 - Sticky
* # Semantic UI 2.1.6 - Sticky
* http://github.com/semantic-org/semantic-ui/
*
*
Expand Down Expand Up @@ -224,8 +224,8 @@ module.exports = function(parameters) {
},
positions: function() {
var
window = {
height: $window.height()
scrollContext = {
height : $scroll.height()
},
element = {
margin: {
Expand All @@ -237,17 +237,28 @@ module.exports = function(parameters) {
height : $module.outerHeight()
},
context = {
offset : $context.offset(),
height : $context.outerHeight()
offset : $context.offset(),
height : $context.outerHeight()
},
container = {
height: $container.outerHeight()
}
;
if( !module.is.standardScroll() ) {
module.debug('Non-standard scroll. Removing scroll offset from element offset');

scrollContext.top = $scroll.scrollTop();
scrollContext.left = $scroll.scrollLeft();

element.offset.top += scrollContext.top;
context.offset.top += scrollContext.top;
element.offset.left += scrollContext.left;
context.offset.left += scrollContext.left;
}
module.cache = {
fits : ( element.height < window.height ),
window: {
height: window.height
fits : ( element.height < scrollContext.height ),
scrollContext : {
height : scrollContext.height
},
element: {
margin : element.margin,
Expand Down Expand Up @@ -307,9 +318,9 @@ module.exports = function(parameters) {
scroll = scroll || $scroll.scrollTop();
var
element = module.cache.element,
window = module.cache.window,
scrollContext = module.cache.scrollContext,
delta = module.get.scrollChange(scroll),
maxScroll = (element.height - window.height + settings.offset),
maxScroll = (element.height - scrollContext.height + settings.offset),
elementScroll = module.get.currentElementScroll(),
possibleScroll = (elementScroll + delta)
;
Expand Down Expand Up @@ -398,6 +409,9 @@ module.exports = function(parameters) {
},

is: {
standardScroll: function() {
return ($scroll[0] == window);
},
top: function() {
return $module.hasClass(className.top);
},
Expand All @@ -424,14 +438,14 @@ module.exports = function(parameters) {
cache = module.cache,
fits = cache.fits,
element = cache.element,
window = cache.window,
scrollContext = cache.scrollContext,
context = cache.context,
offset = (module.is.bottom() && settings.pushing)
? settings.bottomOffset
: settings.offset,
scroll = {
top : cachedPosition + offset,
bottom : cachedPosition + offset + window.height
bottom : cachedPosition + offset + scrollContext.height
},
direction = module.get.direction(scroll.top),
elementScroll = (fits)
Expand Down Expand Up @@ -505,16 +519,22 @@ module.exports = function(parameters) {
}
}
else if( module.is.bottom() ) {
if(settings.pushing) {
if(module.is.bound() && scroll.bottom <= context.bottom ) {
module.debug('Fixing bottom attached element to bottom of browser.');
module.fixBottom();
}
if( scroll.top <= element.top ) {
module.debug('Jumped from bottom fixed to top fixed, most likely used home/end button');
module.setInitialPosition();
}
else {
if(module.is.bound() && (scroll.top <= context.bottom - element.height) ) {
module.debug('Fixing bottom attached element to top of browser.');
module.fixTop();
if(settings.pushing) {
if(module.is.bound() && scroll.bottom <= context.bottom ) {
module.debug('Fixing bottom attached element to bottom of browser.');
module.fixBottom();
}
}
else {
if(module.is.bound() && (scroll.top <= context.bottom - element.height) ) {
module.debug('Fixing bottom attached element to top of browser.');
module.fixTop();
}
}
}
}
Expand Down Expand Up @@ -885,4 +905,4 @@ _module.exports.settings = {

};

})( require("jquery"), window , document );
})( require("jquery"), window, document );
2 changes: 1 addition & 1 deletion package.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Package.describe({
name : 'semantic:ui-sticky',
summary : 'Semantic UI - Sticky: Single component release',
version : '2.1.4',
version : '2.1.6',
git : 'git://github.com/Semantic-Org/UI-Sticky.git',
});

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "semantic-ui-sticky",
"version": "2.1.4",
"version": "2.1.6",
"title": "Semantic UI - Sticky",
"description": "Single component release of sticky",
"homepage": "http://www.semantic-ui.com",
Expand Down
2 changes: 1 addition & 1 deletion sticky.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* # Semantic UI 2.1.4 - Sticky
* # Semantic UI 2.1.6 - Sticky
* http://github.com/semantic-org/semantic-ui/
*
*
Expand Down
62 changes: 41 additions & 21 deletions sticky.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* # Semantic UI 2.1.4 - Sticky
* # Semantic UI 2.1.6 - Sticky
* http://github.com/semantic-org/semantic-ui/
*
*
Expand Down Expand Up @@ -223,8 +223,8 @@ $.fn.sticky = function(parameters) {
},
positions: function() {
var
window = {
height: $window.height()
scrollContext = {
height : $scroll.height()
},
element = {
margin: {
Expand All @@ -236,17 +236,28 @@ $.fn.sticky = function(parameters) {
height : $module.outerHeight()
},
context = {
offset : $context.offset(),
height : $context.outerHeight()
offset : $context.offset(),
height : $context.outerHeight()
},
container = {
height: $container.outerHeight()
}
;
if( !module.is.standardScroll() ) {
module.debug('Non-standard scroll. Removing scroll offset from element offset');

scrollContext.top = $scroll.scrollTop();
scrollContext.left = $scroll.scrollLeft();

element.offset.top += scrollContext.top;
context.offset.top += scrollContext.top;
element.offset.left += scrollContext.left;
context.offset.left += scrollContext.left;
}
module.cache = {
fits : ( element.height < window.height ),
window: {
height: window.height
fits : ( element.height < scrollContext.height ),
scrollContext : {
height : scrollContext.height
},
element: {
margin : element.margin,
Expand Down Expand Up @@ -306,9 +317,9 @@ $.fn.sticky = function(parameters) {
scroll = scroll || $scroll.scrollTop();
var
element = module.cache.element,
window = module.cache.window,
scrollContext = module.cache.scrollContext,
delta = module.get.scrollChange(scroll),
maxScroll = (element.height - window.height + settings.offset),
maxScroll = (element.height - scrollContext.height + settings.offset),
elementScroll = module.get.currentElementScroll(),
possibleScroll = (elementScroll + delta)
;
Expand Down Expand Up @@ -397,6 +408,9 @@ $.fn.sticky = function(parameters) {
},

is: {
standardScroll: function() {
return ($scroll[0] == window);
},
top: function() {
return $module.hasClass(className.top);
},
Expand All @@ -423,14 +437,14 @@ $.fn.sticky = function(parameters) {
cache = module.cache,
fits = cache.fits,
element = cache.element,
window = cache.window,
scrollContext = cache.scrollContext,
context = cache.context,
offset = (module.is.bottom() && settings.pushing)
? settings.bottomOffset
: settings.offset,
scroll = {
top : cachedPosition + offset,
bottom : cachedPosition + offset + window.height
bottom : cachedPosition + offset + scrollContext.height
},
direction = module.get.direction(scroll.top),
elementScroll = (fits)
Expand Down Expand Up @@ -504,16 +518,22 @@ $.fn.sticky = function(parameters) {
}
}
else if( module.is.bottom() ) {
if(settings.pushing) {
if(module.is.bound() && scroll.bottom <= context.bottom ) {
module.debug('Fixing bottom attached element to bottom of browser.');
module.fixBottom();
}
if( scroll.top <= element.top ) {
module.debug('Jumped from bottom fixed to top fixed, most likely used home/end button');
module.setInitialPosition();
}
else {
if(module.is.bound() && (scroll.top <= context.bottom - element.height) ) {
module.debug('Fixing bottom attached element to top of browser.');
module.fixTop();
if(settings.pushing) {
if(module.is.bound() && scroll.bottom <= context.bottom ) {
module.debug('Fixing bottom attached element to bottom of browser.');
module.fixBottom();
}
}
else {
if(module.is.bound() && (scroll.top <= context.bottom - element.height) ) {
module.debug('Fixing bottom attached element to top of browser.');
module.fixTop();
}
}
}
}
Expand Down Expand Up @@ -884,4 +904,4 @@ $.fn.sticky.settings = {

};

})( jQuery, window , document );
})( jQuery, window, document );
2 changes: 1 addition & 1 deletion sticky.min.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* # Semantic UI 2.1.4 - Sticky
* # Semantic UI 2.1.6 - Sticky
* http://github.com/semantic-org/semantic-ui/
*
*
Expand Down
Loading

0 comments on commit 07dc9c4

Please sign in to comment.