Zholen
Zholen

Reputation: 1790

How can I detect resizeStop event on Kendo UI Window?

The title explains it all...

I need to perform a custom action when I know a user has finished resizing, but from what I can find in the Kendo UI documentation there is no event for this accessible to me other that 'resize' which I cannot use as is.

Perhaps i just missed the event?

if not:

Is there a way to use the 'resize' event to determine that a user has stopped resizing?

Upvotes: 0

Views: 1895

Answers (2)

Jon P Smith
Jon P Smith

Reputation: 2439

Have you considered using underscore.js debounce? I have used it successfully to only trigger then change after the resize events have stopped coming for a certain period (in the case below 300ms). This does add a small delay to captureing the end, but if like me you just want to store the final size then that works fine. Here is the version of the code above but using underscore debounce:

  var wndw = $(element).kendoWindow({
            // .....
            resize: _.debounce( this.hasResized, 300)
            // .....
        }).data('kendoWindow');

  //This is called at the end of a resize operation (using _.debounce)
  function hasResized (args) {
        // ** Your code here **
  };

Hope that helps.

Upvotes: 0

Zholen
Zholen

Reputation: 1790

So here's my answer thus far:

Mine differs slightly due to architectural needs, but here's a general solution

var isResizing = false;
var wndw = $(element).kendoWindow({
                // .....
                resize: OnResize,
                // .....
            }).data('kendoWindow');

function onResize() {
    isResizing = true;
}

$('body').on('mouseup', '.k-window', function() {
    if(isResizing){
        // **Your 'Stopped' code here**
        isResizing = false;
    }
});

Upvotes: 1

Related Questions