Skip to content

Commit

Permalink
Updated component to version 1.12.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Semantic-Pusher-Robot committed Apr 16, 2015
1 parent 3e08922 commit fe572c1
Show file tree
Hide file tree
Showing 9 changed files with 105 additions and 59 deletions.
4 changes: 4 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### Version 1.12.0 - April 13, 2015

- **Sticky** - Adds sticky module from `2.x` branch. Sticky elements now use pub/sub with drastically improved performance. Sticky elements that do not fit on page will now scroll at the same speed as the page is scrolled instead of slower.

### Version 1.11.7 - April 13, 2015

- **Sticky** - Fixes errant `console.log` statement appearing in source
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": "1.11.7"
"version": "1.12.0"
}
73 changes: 47 additions & 26 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* # Semantic UI 1.11.7 - Sticky
* # Semantic UI 1.12.0 - Sticky
* http://github.com/semantic-org/semantic-ui/
*
*
Expand Down Expand Up @@ -88,13 +88,18 @@ module.exports = function(parameters) {
},

destroy: function() {
module.verbose('Destroying previous module');
module.verbose('Destroying previous instance');
module.reset();
if(observer) {
observer.disconnect();
}
$window.off('resize' + eventNamespace, module.event.resize);
$scroll.off('scroll' + eventNamespace, module.event.scroll);
$window
.off('load' + eventNamespace, module.event.load)
.off('resize' + eventNamespace, module.event.resize)
;
$scroll
.off('scrollchange' + eventNamespace, module.event.scrollchange)
;
$module.removeData(moduleNamespace);
},

Expand All @@ -108,7 +113,7 @@ module.exports = function(parameters) {
module.timer = setTimeout(function() {
module.verbose('DOM tree modified, updating sticky menu');
module.refresh();
}, 20);
}, 100);
});
observer.observe(element, {
childList : true,
Expand Down Expand Up @@ -148,23 +153,36 @@ module.exports = function(parameters) {

bind: {
events: function() {
$window.on('resize' + eventNamespace, module.event.resize);
$scroll.on('scroll' + eventNamespace, module.event.scroll);
$window
.on('load' + eventNamespace, module.event.load)
.on('resize' + eventNamespace, module.event.resize)
;
// pub/sub pattern
$scroll
.off('scroll' + eventNamespace)
.on('scroll' + eventNamespace, module.event.scroll)
.on('scrollchange' + eventNamespace, module.event.scrollchange)
;
}
},

event: {
load: function() {
module.verbose('Page contents finished loading');
requestAnimationFrame(module.refresh);
},
resize: function() {
requestAnimationFrame(function() {
module.refresh();
module.stick();
});
module.verbose('Window resized');
requestAnimationFrame(module.refresh);
},
scroll: function() {
requestAnimationFrame(function() {
module.stick();
settings.onScroll.call(element);
$scroll.trigger('scrollchange' + eventNamespace, $scroll.scrollTop() );
});
},
scrollchange: function(event, scrollPosition) {
module.stick(scrollPosition);
settings.onScroll.call(element);
}
},

Expand All @@ -190,7 +208,7 @@ module.exports = function(parameters) {
},

save: {
scroll: function(scroll) {
lastScroll: function(scroll) {
module.lastScroll = scroll;
},
positions: function() {
Expand Down Expand Up @@ -269,21 +287,22 @@ module.exports = function(parameters) {
: Math.abs(parseInt($module.css('bottom'), 10)) || 0
;
},

elementScroll: function(scroll) {
scroll = scroll || $scroll.scrollTop();
var
element = module.cache.element,
window = module.cache.window,
delta = module.get.scrollChange(scroll),
maxScroll = (element.height - window.height + settings.offset),
currentScroll = module.get.currentElementScroll(),
possibleScroll = (currentScroll + delta),
elementScroll = module.get.currentElementScroll(),
possibleScroll = (elementScroll + delta),
elementScroll
;
if(module.cache.fits || possibleScroll < 0) {
elementScroll = 0;
}
else if (possibleScroll > maxScroll ) {
else if(possibleScroll > maxScroll ) {
elementScroll = maxScroll;
}
else {
Expand Down Expand Up @@ -314,8 +333,8 @@ module.exports = function(parameters) {
$container = $module.offsetParent();
}
else {
module.debug('Settings container size', module.cache.context.height);
if( Math.abs($container.height() - module.cache.context.height) > 5) {
module.debug('Context has padding, specifying exact height for container', module.cache.context.height);
$container.css({
height: module.cache.context.height
});
Expand Down Expand Up @@ -370,8 +389,9 @@ module.exports = function(parameters) {
}
},

stick: function() {
stick: function(scroll) {
var
cachedPosition = scroll || $scroll.scrollTop(),
cache = module.cache,
fits = cache.fits,
element = cache.element,
Expand All @@ -381,19 +401,21 @@ module.exports = function(parameters) {
? settings.bottomOffset
: settings.offset,
scroll = {
top : $scroll.scrollTop() + offset,
bottom : $scroll.scrollTop() + offset + window.height
top : cachedPosition + offset,
bottom : cachedPosition + offset + window.height
},
direction = module.get.direction(scroll.top),
elementScroll = module.get.elementScroll(scroll.top),
elementScroll = (fits)
? 0
: module.get.elementScroll(scroll.top),

// shorthand
doesntFit = !fits,
elementVisible = (element.height !== 0)
;

// save current scroll for next run
module.save.scroll(scroll.top);
module.save.lastScroll(scroll.top);

if(elementVisible) {

Expand Down Expand Up @@ -553,13 +575,12 @@ module.exports = function(parameters) {
module.unbind();
module.unfix();
module.resetCSS();
module.remove.offset();
},

resetCSS: function() {
$module
.css({
top : '',
bottom : '',
width : '',
height : ''
})
Expand Down Expand Up @@ -789,4 +810,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 : '1.11.7',
version : '1.12.0',
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": "1.11.7",
"version": "1.12.0",
"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 1.11.7 - Sticky
* # Semantic UI 1.12.0 - Sticky
* http://github.com/semantic-org/semantic-ui/
*
*
Expand Down
Loading

0 comments on commit fe572c1

Please sign in to comment.