diff --git a/src/Calendar.js b/src/Calendar.js index b23ba55..a875653 100644 --- a/src/Calendar.js +++ b/src/Calendar.js @@ -486,8 +486,11 @@ function Calendar(element, instanceOptions) { } - function windowResize() { - if (!ignoreWindowResize) { + function windowResize(ev) { + if ( + !ignoreWindowResize && + ev.target === window // so we don't process jqui "resize" events that have bubbled up + ) { if (currentView.start) { // view has already been rendered var uid = ++resizeUID; setTimeout(function() { // add a delay @@ -499,7 +502,7 @@ function Calendar(element, instanceOptions) { ignoreWindowResize--; } } - }, 200); + }, options.windowResizeDelay); }else{ // calendar must have been initialized in a 0x0 iframe that has just been resized lateRender(); diff --git a/src/defaults.js b/src/defaults.js index f0c6e41..ff85733 100644 --- a/src/defaults.js +++ b/src/defaults.js @@ -89,7 +89,8 @@ var defaults = { dropAccept: '*', - handleWindowResize: true + handleWindowResize: true, + windowResizeDelay: 200 // milliseconds before a rerender happens }; diff --git a/tests/automated/event-resize.js b/tests/automated/event-resize.js index e3a7043..c903e02 100644 --- a/tests/automated/event-resize.js +++ b/tests/automated/event-resize.js @@ -184,6 +184,29 @@ describe('eventResize', function() { } ); }); + + it('should not fire the windowResize handler', function(done) { // bug 1116 + options.windowResize = function() { }; + options.windowResizeDelay = 0; + spyOn(options, 'windowResize'); + init( + function() { + $('.fc-event .ui-resizable-handle') + .simulate('mouseover') // for our dumb optimization + .simulate('drag-n-drop', { + dy: 200, + interpolation: { + stepCount: 10, + duration: 100 + } + }); + }, + function() { // if an unintended rerender happened, won't get here anyway + expect(options.windowResize).not.toHaveBeenCalled(); + done(); + } + ); + }); }); describe('when resizing a timed event without an end', function() {