Skip to content

Commit

Permalink
contextual init for sticky, also only bind if there are elements that…
Browse files Browse the repository at this point in the history
… need events
  • Loading branch information
nikolaswise committed Aug 25, 2015
1 parent edaeeaa commit c794535
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/js/calcite-web.js
Original file line number Diff line number Diff line change
Expand Up @@ -544,8 +544,8 @@
// │ Sticky │
// └────────┘
// sticks things to the window
calcite.sticky = function () {
var elements = findElements('.js-sticky');
calcite.sticky = function (domNode) {
var elements = findElements('.js-sticky', domNode);

var stickies = elements.map(function (el) {
var offset = el.offsetTop;
Expand Down Expand Up @@ -588,8 +588,10 @@
});
};

calcite.addEvent(window, 'scroll', scrollHandler);
calcite.addEvent(window, 'resize', resize);
if (elements) {
calcite.addEvent(window, 'scroll', scrollHandler);
calcite.addEvent(window, 'resize', resize);
}
};

// ┌───────────┐
Expand Down

0 comments on commit c794535

Please sign in to comment.