Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resizing elements triggers window resize event repeatedly #774

Closed
Metal101 opened this issue Sep 12, 2017 · 4 comments
Closed

Resizing elements triggers window resize event repeatedly #774

Metal101 opened this issue Sep 12, 2017 · 4 comments

Comments

@Metal101
Copy link

Metal101 commented Sep 12, 2017

Hello,

I'm having an issue when resizing elements via dragging. The window's resize event appears to be triggered repeatedly for every mouse movement, causing some slow down in my application. I have replicated this on a gridstack demo page by logging to console on window resize.

http://gridstackjs.com/demo/responsive.html

Do you know if there is a workaround for this please?

@radiolips
Copy link
Member

Hey, @Metal101 ! Try out lodash's debounce method.

http://jsfiddle.net/rifat/ZDPaV/

and

https://lodash.com/docs/#debounce

Let me know if there's anything more I can help with!

@ashw1984
Copy link

hi @radiolips. this solution is only ok if you are writing everything from scratch. if i have an existing application 100's of handlers on windows resize are you expecting all of these to be re-written. Ultimately the window isn't resizing so surely this event should not be triggered. Are you able to re-open this bug?

@Metal101
Copy link
Author

@ashw1984 has directed me to this page.

https://stackoverflow.com/questions/7494378/jquery-ui-resizable-fire-window-resize-event

It's suggested you catch the element resize event and stop propagation before it bubbles up to the window event.

@radiolips
Copy link
Member

This is a jquery-ui "bug," not a gridstack bug. We're working to move away from jquery-ui, but in the meantime, you can check event.target as the SO mentions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants