fixed-table-header icon indicating copy to clipboard operation
fixed-table-header copied to clipboard

Reduce watcher by using ResizeObserver

Open antsfiles opened this issue 7 years ago • 0 comments

I found out that 'getWitht' is CPU consuming if there is a lot of $digest. So instead of using $watch, ResizeObserver in chrome is a better choice.

                    if (ResizeObserver) {
                        //window.console.log("ResizeObserver exists", ResizeObserver);
                        new ResizeObserver((outputsize) => {
                            getWidth();
                            setWidth();
                        }).observe(cell[0]);
                    } else {
                        //window.console.log("ResizeObserver does not exists", ResizeObserver);
                        var listener = scope.$watch(getWidth, setWidth);
                    }

Also, "scope.$watch(cells, updateCells);" is not need, I think, if the number of cells in header does not change. It can be replace directly by "updateCells();"

antsfiles avatar Jan 17 '19 09:01 antsfiles