Odd behavior using jQuery draggable AND resizable with jquery collision 1.0.1

I use:

Jquery-1.6.2 jquery-u-1.8.16 collision 1.0.1

... create a web application for drawing blocks. I have a grid table that has selection cells. Above this layer are the "tents." When the tent moves or changes, I want the overlapping cells in the table below to have special classes applied to them, so I started using collision 1.0.1.

It seemed to have exactly the desired effect, however, when you drag the selection and THEN resize it - the cells below no longer reflect the collisions from the step above until you drag the chassis again. If you create a new selection and just change its size, the collision is calculated exactly, it only goes wrong after dragging.

There is a demo at http://accessibledesign.net/block_painter/client/ (just drag the selection area)

The yellow cells reflect the collision with the selection above.

I conducted extensive testing and can confirm that the volatile tents themselves have all the correct properties, the error seems to be related to the collision function:

$("#grid td.ui-selected").removeClass("ui-selected"); hits = DATA.elems.curMarquee.collision($("#grid td.col")) hits.addClass("ui-selected"); 

This code runs at the β€œstop” of the resizable or drag and drop - and runs at the right time.

+2
source share
1 answer

This is a bug in the jquery-ui-draggable-collision module, actually. Or, more specifically, it was not intended to handle "resizable" yet - it will be in a future version. If you don't need drag-and-drop stuff, deleting should fix the problem.

However, if you need it, at the moment there is a workaround. Before calling $("#target").collision(".obstacles") do:

 $("#target").removeData("jqueryCollisionCoordinates") $("#target").removeData("jqueryUiDraggableCollisionRecentPosition") $(".obstacles").removeData("jqueryCollisionCoordinates") $(".obstacles").removeData("jqueryUiDraggableCollisionRecentPosition") 

And that will remove all the internal caching that it does so that it recounts the collision from scratch, instead of using the previous version, which has not yet been updated.

Note. If you can submit a request for fixing errors on the sourceforge page, please, and a link to this page, I will eventually correct it in order to work correctly, and you will receive a message when I do this. You can also add your website to the review, and I will try to take into account the use of hosted users when making changes. Thanks!

Also note: it may not be necessary to say this, but it does not depend on this work after version 1.0.1. Also, do not use futz with the contents of these internal components, otherwise it may be damaged in future versions - this is not a public API.

+2
source

All Articles