Skip to content

Commit

Permalink
Remove o.marginTop from calculations as it is not needed.
Browse files Browse the repository at this point in the history
  • Loading branch information
liviucmg committed Aug 29, 2016
1 parent 353fc39 commit 072ea1d
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions js/theia-sticky-sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@
}

// Get existing top and bottom margins and paddings
o.marginTop = parseInt(o.sidebar.css('margin-top'));
o.marginBottom = parseInt(o.sidebar.css('margin-bottom'));
o.paddingTop = parseInt(o.sidebar.css('padding-top'));
o.paddingBottom = parseInt(o.sidebar.css('padding-bottom'));
Expand Down Expand Up @@ -179,14 +178,14 @@
var position = 'static';

// If the user has scrolled down enough for the sidebar to be clipped at the top, then we can consider changing its position.
if (scrollTop >= o.container.offset().top + (o.paddingTop + o.marginTop - o.options.additionalMarginTop)) {
if (scrollTop >= o.sidebar.offset().top + (o.paddingTop - o.options.additionalMarginTop)) {
// The top and bottom offsets, used in various calculations.
var offsetTop = o.paddingTop + o.marginTop + options.additionalMarginTop;
var offsetTop = o.paddingTop + options.additionalMarginTop;
var offsetBottom = o.paddingBottom + o.marginBottom + options.additionalMarginBottom;

// All top and bottom positions are relative to the window, not to the parent elemnts.
var containerTop = o.container.offset().top;
var containerBottom = o.container.offset().top + getClearedHeight(o.container);
var containerTop = o.sidebar.offset().top;
var containerBottom = o.sidebar.offset().top + getClearedHeight(o.container);

// The top and bottom offsets relative to the window screen top (zero) and bottom (window height).
var windowOffsetTop = 0 + options.additionalMarginTop;
Expand All @@ -200,7 +199,7 @@
windowOffsetBottom = $(window).height() - o.marginBottom - o.paddingBottom - options.additionalMarginBottom;
}

var staticLimitTop = containerTop - scrollTop + o.paddingTop + o.marginTop;
var staticLimitTop = containerTop - scrollTop + o.paddingTop;
var staticLimitBottom = containerBottom - scrollTop - o.paddingBottom - o.marginBottom;

var top = o.stickySidebar.offset().top - scrollTop;
Expand Down

0 comments on commit 072ea1d

Please sign in to comment.