Giter Site home page Giter Site logo

Comments (3)

wmichaelfeltman avatar wmichaelfeltman commented on July 18, 2024

Have the same issue with Angular 1.5 and Angular Material 1.0.5 and the latest md-data-table.

Error: $rootScope:infdig
Infinite $digest Loop
10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations: [[{"msg":"fn: function (){return g.width}","newVal":"135px","oldVal":"137px"},{"msg":"fn: function (){return g.width}","newVal":"406px","oldVal":"412px"},{"msg":"fn: function (){return g.width}","newVal":"174px","oldVal":"177px"},{"msg":"fn: function (){return g.width}","newVal":"103px","oldVal":"105px"},{"msg":"fn: function (){return g.width}","newVal":"109px","oldVal":"111px"},{"msg":"fn: function (){return g.width}","newVal":"143px","oldVal":"145px"},{"msg":"fn: function (){return g.width}","newVal":"174px","oldVal":"177px"},{"msg":"fn: function (){return g.width}","newVal":"112px","oldVal":"114px"},{"msg":"fn: function (){return g.width}","newVal":"176px","oldVal":"180px"},{"msg":"fn: function (){return g.width}","newVal":"171px","oldVal":"173px"}],[{"msg":"fn: function (){return g.width}","newVal":"132px","oldVal":"135px"},{"msg":"fn: function (){return g.width}","newVal":"400px","oldVal":"406px"},{"msg":"fn: function (){return g.width}","newVal":"171px","oldVal":"174px"},{"msg":"fn: function (){return g.width}","newVal":"101px","oldVal":"103px"},{"msg":"fn: function (){return g.width}","newVal":"107px","oldVal":"109px"},{"msg":"fn: function (){return g.width}","newVal":"140px","oldVal":"143px"},{"msg":"fn: function (){return g.width}","newVal":"171px","oldVal":"174px"},{"msg":"fn: function (){return g.width}","newVal":"109px","oldVal":"112px"},{"msg":"fn: function (){return g.width}","newVal":"174px","oldVal":"176px"},{"msg":"fn: function (){return g.width}","newVal":"168px","oldVal":"171px"}],[{"msg":"fn: function (){return g.width}","newVal":"130px","oldVal":"132px"},{"msg":"fn: function (){return g.width}","newVal":"394px","oldVal":"400px"},{"msg":"fn: function (){return g.width}","newVal":"168px","oldVal":"171px"},{"msg":"fn: function (){return g.width}","newVal":"99px","oldVal":"101px"},{"msg":"fn: function (){return g.width}","newVal":"104px","oldVal":"107px"},{"msg":"fn: function (){return g.width}","newVal":"138px","oldVal":"140px"},{"msg":"fn: function (){return g.width}","newVal":"168px","oldVal":"171px"},{"msg":"fn: function (){return g.width}","newVal":"107px","oldVal":"109px"},{"msg":"fn: function (){return g.width}","newVal":"170px","oldVal":"174px"},{"msg":"fn: function (){return g.width}","newVal":"165px","oldVal":"168px"}],[{"msg":"fn: function (){return g.width}","newVal":"127px","oldVal":"130px"},{"msg":"fn: function (){return g.width}","newVal":"387px","oldVal":"394px"},{"msg":"fn: function (){return g.width}","newVal":"165px","oldVal":"168px"},{"msg":"fn: function (){return g.width}","newVal":"96px","oldVal":"99px"},{"msg":"fn: function (){return g.width}","newVal":"102px","oldVal":"104px"},{"msg":"fn: function (){return g.width}","newVal":"135px","oldVal":"138px"},{"msg":"fn: function (){return g.width}","newVal":"164px","oldVal":"168px"},{"msg":"fn: function (){return g.width}","newVal":"105px","oldVal":"107px"},{"msg":"fn: function (){return g.width}","newVal":"167px","oldVal":"170px"},{"msg":"fn: function (){return g.width}","newVal":"163px","oldVal":"165px"}],[{"msg":"fn: function (){return g.width}","newVal":"125px","oldVal":"127px"},{"msg":"fn: function (){return g.width}","newVal":"381px","oldVal":"387px"},{"msg":"fn: function (){return g.width}","newVal":"162px","oldVal":"165px"},{"msg":"fn: function (){return g.width}","newVal":"94px","oldVal":"96px"},{"msg":"fn: function (){return g.width}","newVal":"100px","oldVal":"102px"},{"msg":"fn: function (){return g.width}","newVal":"132px","oldVal":"135px"},{"msg":"fn: function (){return g.width}","newVal":"161px","oldVal":"164px"},{"msg":"fn: function (){return g.width}","newVal":"102px","oldVal":"105px"},{"msg":"fn: function (){return g.width}","newVal":"164px","oldVal":"167px"},{"msg":"fn: function (){return g.width}","newVal":"160px","oldVal":"163px"}]]

Eventually the app recovers and everything works as expected, but obviously that's not ideal.

from fixed-table-header.

wmichaelfeltman avatar wmichaelfeltman commented on July 18, 2024

Commenting out
scope.$watch(cells, updateCells);
Almost solves the problem. It suppresses the errors, the header is still fixed and it eliminates some annoying jumping around of column sizes.
This introduces 2 new issues: 1. The column headers are not over the columns and 2. There's some blank space between the column headers and the first row.

Obviously the solution is to call updateCells at a later juncture or perhaps to debounce it. I'm looking into these options.

Update: replacing scope.$watch(cells, updateCells);
with simply updateCells();
works in my application.

from fixed-table-header.

mcblum avatar mcblum commented on July 18, 2024

That didn't work for me for some reason, so I went this route. It's not pretty:

function updateCells() {
                if(processing) {
                    return false;
                }

                processing = true;

                $timeout(() => {
                    let cells = {
                        clone: getCells(header.clone),
                        original: getCells(header.original)
                    };

                    cells.clone.forEach(function (clone, index) {
                        if (clone.data('isClone')) {
                            return;
                        }

                        // prevent duplicating watch listeners
                        clone.data('isClone', true);

                        let cell = cells.original[index];
                        let style = $window.getComputedStyle(cell[0]);

                        let getWidth = function () {
                            return style.width;
                        };

                        let setWidth = function () {
                            marginTop(height());
                            clone.css({minWidth: style.width, maxWidth: style.width});
                        };

                        let listener = scope.$watch(getWidth, setWidth);

                        $window.addEventListener('resize', setWidth);

                        clone.on('$destroy', function () {
                            listener();
                            $window.removeEventListener('resize', setWidth);
                        });

                        cell.on('$destroy', function () {
                            clone.remove();
                        });
                    });

                    processing = false;
                }, 500);
            }

from fixed-table-header.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.