kutlugsahin / smooth-dnd

drag and drop library for javascript
MIT License
599 stars 147 forks source link

onMouseDown could be more robust #12

Open nevf opened 6 years ago

nevf commented 6 years ago

smooth-dnd adds event listeners when the module is loaded. Functions like onMouseDown() can raise an exception if SmoothDnD() hasn't been called and you drag an element wrapped in <div class="smooth-dnd-draggable-wrapper"> because container will be undefined.

It might be better to only add the global event listeners the first time SmoothDnD() is called, or check container is set in onMouseDown()

I have to wrap my dnd elements because they are created dynamically and smooth-dnd doesn't support this as per my issue https://github.com/kutlugsahin/smooth-dnd/issues/10