How can I detect resizeStop event on Kendo UI Window?

跟風遠走 提交于 2019-12-12 03:38:40

问题


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?


回答1:


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;
    }
});



回答2:


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.



来源:https://stackoverflow.com/questions/13983352/how-can-i-detect-resizestop-event-on-kendo-ui-window

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!