angular-ui / ui-calendar

A complete AngularJS directive for the Arshaw FullCalendar.
http://angular-ui.github.io/ui-calendar/
MIT License
1.49k stars 729 forks source link

Performance Issues when switching between views/rendering #414

Open peterver opened 8 years ago

peterver commented 8 years ago

I've noticed a significant performance issue that isn't present in the original fullcalendar, after some debugging on my own fork of ui-calendar i've found the culprit to be the following function :

var wrapFunctionWithScopeApply = function (functionToWrap) {
                return function () {
                    // This may happen outside of angular context, so create one if outside.
                    if ($scope.$root.$$phase) {
                        return functionToWrap.apply(this, arguments);
                    }

                    var args = arguments;
                    var that = this;
                    return $scope.$root.$apply(
                        function () {
                            return functionToWrap.apply(that, args);
                        }
                    );
                };
            };

I was about to start working on a fix for this but would like to ask if anyone knows as to why this is being done?

Scope applies are executed on every change by this logic ( which angular should handle by itself ), but after commenting out this part i noticed my calendar renders to be 500ms ( up to a second ! ) faster.

I'm going to look into this during the weekend :] so if anyone can provide me some info on why this is being done? ^.^

njcoutinho commented 6 years ago

Hey @peterver did you manage to fix this in your branch?