backdrop-contrib / tocbot

Builds a table of contents (TOC) from content headings.
GNU General Public License v2.0
2 stars 2 forks source link

Stop tocbot appearing over content on mobile #47

Closed yorkshire-pudding closed 2 years ago

yorkshire-pudding commented 2 years ago

On mobiles, Tocbots placed in sidebars appear on top of the content. Following discussion over #43 it was decided that to fix the immediate bug we should stop the tocbot block appearing over content.

43 will remain open to try to implement a pattern that allows that ToC to be used wherever the user is in the content.

olafgrabienski commented 2 years ago

Thanks for the PR! I've tested the change and found out it works only for screens at least 769px wide. To make it work for 768px (e.g. for iPads in portrait mode), I'd suggest to set position: relative without media query condition. Then add a min-width media query to set position: fixed.

olafgrabienski commented 2 years ago

This works for me:

.js-toc-block.is-position-fixed {
  position: relative !important;
}

@media (min-width: 48em) {
  .js-toc-block.is-position-fixed {
    position: fixed !important;
    top: 80px;
    max-width: 150px;
  }
}

Notes re this approach:

yorkshire-pudding commented 2 years ago

Thanks @olafgrabienski - that makes sense. PR updated

olafgrabienski commented 2 years ago

Thanks a lot, @yorkshire-pudding – I've merged the PR after the last changes.