Skip to content

Commit

Permalink
DP-20241 Remove space above the sticky table header (#1226)
Browse files Browse the repository at this point in the history
* test edit

* adjust vertical placement of the sticky table header when no sticky TOC

* add changelog for DP-20241

* clean up comments
  • Loading branch information
ygannett authored Oct 23, 2020
1 parent ecb8f54 commit 8771258
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
6 changes: 6 additions & 0 deletions changelogs/DP-20241.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Changed:
- project: Patternlab
component: ResponsiveTable
description: Remove extra space above the sticky table header. (#1226)
issue: DP-20241
impact: Minor
Original file line number Diff line number Diff line change
Expand Up @@ -130,17 +130,11 @@ export default (function (window, document, $) {
// This calculates the additional offset that a table sticky header should drop down.
function getAdditionalOffset() {
let additionalOffset = 0;
if (document.documentElement.clientWidth <= 825) {
const $jsStickyHeader = $(".js-sticky-header");
if ($jsStickyHeader) {
additionalOffset += $jsStickyHeader.height();
}
}
if ($(".js-scroll-anchors")[0] &&
document.documentElement.clientWidth <= 765) {
additionalOffset += $(".js-scroll-anchors").height();
}
if (document.documentElement.classList.contains('stickyTOC')) {
if (document.documentElement.classList.contains("stickyTOC")) {
if (document.documentElement.clientWidth <= 841) {
additionalOffset += 75;
}
Expand Down Expand Up @@ -168,10 +162,14 @@ export default (function (window, document, $) {
if (!rt.headerStuck && elementTop < stuckTop && tableBottom > stuckBottom) {
responsiveTables[rt.index].headerStuck = true;
rt.$stickyHeader.css("opacity", 1);
rt.$stickyHeader.css("-webkit-box-shadow", "");
rt.$stickyHeader.css("box-shadow", "");
}
else if (rt.headerStuck && (elementTop > stuckTop || tableBottom < stuckBottom)) {
responsiveTables[rt.index].headerStuck = false;
rt.$stickyHeader.css("opacity", 0);
rt.$stickyHeader.css("-webkit-box-shadow", "none");
rt.$stickyHeader.css("box-shadow", "none");
}
}

Expand Down

0 comments on commit 8771258

Please sign in to comment.