xieziyu / angular2-draggable

Angular directive (for version >= 2.x ) that makes the DOM element draggable and resizable
https://xieziyu.github.io/angular2-draggable/
294 stars 103 forks source link

Ability to reset position #30

Open ctrl-brk opened 6 years ago

ctrl-brk commented 6 years ago

Hi. I'm using this beautiful directive with ngx-bootstrap modals. The issue is that if you open the modal (which opens at its default kind of centered position), drag it, close and open again it opens at the last dragged position not at default. Would be nice to be able to reset drag position so modals always open at their default.

xieziyu commented 6 years ago

Thanks for your suggestion. The feature would be considered.

catchshyam commented 6 years ago

@xieziyu I see that you have implemented the feature in master. Would it be possible to provide a release with this feature.

xieziyu commented 6 years ago

@catchshyam Do you mean [trackPosition] ? It has been released in v1.1.0

catchshyam commented 6 years ago

@xieziyu The latest release I see is v1.1.0-beta.0.

And I think trackPosition is not included in that release. https://github.com/xieziyu/angular2-draggable/blob/v1.1.0-beta.0/lib/src/directive/angular-draggable.directive.ts

xieziyu commented 6 years ago

Ah you are right. I didn't publish the v1.1.0 release. Thank you very much @catchshyam

catchshyam commented 6 years ago

@xieziyu thank you for the release. Actually the feature was not exactly what I had in mind.

I have a floating modal which appears on a predefined position (let's call it original position) when user hovers on a particular element (lets call it hover target). Once the modal appears, user can drag and move the modal around on the screen (this is where I use this awesome directive). User can close the modal any time by clicking on the modal close button. After closing, if the user hovers again on the hover target, the modal should appear again at original position.

Now the issue is, once the user drags the modal, closes it and tries to open for the second time,

So what I am really looking for is an API to reset the drag position (which I will call when the user closes the modal). I will probably clone and make the changes. If you think the feature makes sense, let me know and I can make a pull request.

Thank you.

xieziyu commented 6 years ago

released this API in v1.2.0

catchshyam commented 6 years ago

Thank you @xieziyu . Works really well.