nikitasnv / vue-resizable

VueResizable component
https://nikitasnv.github.io/vue-resizable/
MIT License
224 stars 46 forks source link

drag can not be disabled #3

Closed mazoqui closed 4 years ago

mazoqui commented 4 years ago

Hi thank you for sharing your wonderful job.

I'm using it on a component editor, it will not work as expected, because I need to switch beeting editing and viewer mode. Resize functionality is working as expected: By setting an empty array to the "active" prop and it disabled resizing.

It seems that you are listening for changes on dragSelector and calling setupDragElements properly, although you are not removing previously added "drag-el" class.

It means that, once enabled, drag functionality can not be disabled by reseting the dragSelector to undefined.

//fixed version: setupDragElements(selector) { let nodeList = this.$el.getElementsByClassName("drag-el"); while (nodeList.length) nodeList[0].classList.remove("drag-el"); nodeList = this.$el.querySelectorAll(selector); nodeList.forEach((el) => { el.classList.add("drag-el"); }); this.dragElements = Array.prototype.slice.call(nodeList); },

Thank you once again for sharing it

nikitasnv commented 4 years ago

fixed in 382c68528a76685948bc70ffc7fdda29fb70c74e , thanks!