dattn / dnd-grid

A vuejs grid with draggable and resizable boxes
307 stars 48 forks source link

exposing some events #13

Open kevinlvhsl opened 6 years ago

kevinlvhsl commented 6 years ago

Would you consider exposing some events to external eavesdropping? In order for developers to be more flexible in controlling component details

dattn commented 6 years ago

Can you give some examples of events ?

Should it be possible to prevent the default behavior ? For example stop moving a box.

All ideas are welcome, but must be well planned.

apooslr commented 6 years ago

It might be helpful to have eventlisteners for when a box has been resized or moved. To access the previous and current cordinated of the box etc.

dattn commented 6 years ago

Events have been implemented by @stanogurnik. Previous and current coordinates are not yet passed to the callbacks.

stanogurnik commented 6 years ago

Current/updated coordinates are passed in the events, so what you can do, is to keep coordinates in upper level of component in state, so when event is fired, you will have previous and current state.

I don't think both current and previous coordinates should be passed to every event. I can think several scenarios when previous coordinates can change (eg. server update) during user action (dragging etc.) and you want to handle this at app level

tyrauber commented 4 years ago

@stanogurnik How does one listen for the resize:end event? I am assuming its $on('resize:end', function(opts){}), but what is $on on? It isn't on the vue instance (this), nor the dnd-box instance, or library? How does one listen to these events?

Edit: For future reference, I haven't figured out how to programmatically listen to events, but adding an event handler does work:
<dnd-grid-box boxId="box-1" v-on:resizeEnd="resize('box-1', $event)">