question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Grid height activating scroll intermittently

See original GitHub issue

Hi there! I’ve run across a possible bug that happens when the grid heigh is on the threshold that the browser defines for showing/hiding the scrollbar: intermittently scroll

I have colWidth is set to ‘auto’ and rowHeight is ‘match’.

This happens when for example the grid has four rows, but if it had a fifth the grid height it would be on the browser scrollbar overflow threshold.

It seems there are two watches that are triggering other’s, always updating their size. as a workaround I commented the line

function updateHeight() {
    $elem.css('height', (gridster.gridHeight * gridster.curRowHeight) + (gridster.outerMargin ? gridster.margins[0] : -gridster.margins[0]) + 'px');
}

This workaround is not great because then the grid has no real heigh…

Issue Analytics

  • State:open
  • Created 8 years ago
  • Reactions:1
  • Comments:9

github_iconTop GitHub Comments

2reactions
andrey-sklcommented, Jan 29, 2016

So I have researched a workaround for that. The main Idea is reducing my app container right margin with scroll width when it appears. So scroll appearing doesnt change actual document height and gridster doesnt goes to this infinite loop of resizing.

There is a directive for scrollbar width detecting I’m using. So I created a directive which reacts on gridster resizes and add/remove margin shift if needed.

import scrollbarWidth from 'scrollbar-width';

...
  .directive('dshGridScrollCompensator', function () {
    return {
      restrict: 'A',
      link: function (scope, iElement) {
        var element = iElement[0];
        var scrollWidth = scrollbarWidth();
        var defaultMarginRight = window.getComputedStyle(element).marginRight;
        console.log('scroll bar width', scrollWidth);

        scope.$on('gridster-resized', () => {
          var hasOverflow = document.body.offsetHeight < document.body.scrollHeight;

          if (hasOverflow) {
            var compensatedMargin = parseInt(defaultMarginRight) - scrollWidth;
            element.style.marginRight = compensatedMargin + 'px';
          } else {
            element.style.marginRight = defaultMarginRight;
          }
        });
      }
    };
  });

I applied this directive on my application container div which has margins 32px by default. So now when scroll appears it reduces to 17px.

Tested on latest master (ManifestWebDesign/angular-gridster#281de99) but should work on any version.

0reactions
andrewjb123commented, Aug 25, 2017

as a temporary work around i simply applied:

overflow-y: scroll

to the grid - this makes the y scroll bar appear always, which stops the scroll bar showing and hiding which affects the alignment of the tiles.

not ideal as the y scroll always shows, but it solved a headache for me

Read more comments on GitHub >

github_iconTop Results From Across the Web

Telerik Web Forms Resizing Grid with Scrolling when Data is ...
Resizing Grid with Scrolling when Data is Less Than Scroll Height. Sometimes your application may reduce the records that RadGrid displays by some...
Read more >
Auto-placement in grid layout - CSS: Cascading Style Sheets
In this next example I have created a grid with three row tracks of 200 pixels height. I am auto-placing by column and...
Read more >
ag-Grid Row Models: Infinite Scrolling
The grid will have an 'auto extending' vertical scroll. That means as the scroll reaches the bottom position, the grid will extend the...
Read more >
How to auto increase Grid header height as per dynamic ...
Applying a style to enable scrolling on the content element would be the “easy” way to do it. But I don't know if...
Read more >
Content Jumping (and How To Avoid It) | CSS-Tricks
A few seconds after initial visit the headings (and sometimes ... To fix it, I used the browser's DevTools to measure the height...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found