Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove jQuery dependency #55

Merged
merged 1 commit into from
Jan 4, 2015
Merged

Conversation

sh3rndon
Copy link
Contributor

This is my first fork/pull, so I'm not sure I'm doing this right.

I like this module, but have a jQuery-free app so replaced the jQuery code that was getting dom element dimensions and offset with a private function (_privoffset) in ngDrag and ngDrop directives. I don't like duplication of this function, but not sure of the cleanest way to DRY this up. My hope is that someone else will do it the right way.

Summary of changes

  • removed dependency on jQuery
  • inject $window and $document instead of creating local vars for them
  • prevent duplicate drop events when element has both ng-drag and ng-drop behavior
  • don't move the drag element in the initial press, wait till dragging starts
  • don't clobber margin of drag element when moving it

- inject $window and $document instead of creating local vars for them
- prevent duplicate drop events when element has both ng-drag and ng-drop behavior
- don't move the drag element in the initial press, wait till dragging starts
- don't clobber margin of drag element when moving it
@bobber205
Copy link
Contributor

This is a wonderful PR :) 👍

@fatlinesofcode
Copy link
Owner

Looks good thanks, does it work ok in angular 1.3?

fatlinesofcode added a commit that referenced this pull request Jan 4, 2015
Remove jQuery dependency
@fatlinesofcode fatlinesofcode merged commit fd48114 into fatlinesofcode:master Jan 4, 2015
@jtrotoux
Copy link
Contributor

jtrotoux commented Jan 9, 2015

Sorry, but these lines of code do not work on my project.
The property "touches" is not defined (chrome desktop & tablet)

//_mx = (evt.pageX || evt.touches[0].pageX);
//_my = (evt.pageY || evt.touches[0].pageY);
_mx = (evt.pageX || evt.originalEvent.touches[0].pageX); // ? why ?
_my = (evt.pageY || evt.originalEvent.touches[0].pageY); // ? why ?

@sh3rndon
Copy link
Contributor Author

sh3rndon commented Jan 9, 2015

Sorry I missed those. 'originalEvent' is a jQuery-ism I think. I don't
remember how I got rid of them, set a break point on that line and
investigate evt and the other passed parameters to see how you get at the
real event. The two commented lines might be exactly what you need.

On Fri, Jan 9, 2015 at 4:28 AM, J.Trotoux notifications@github.com wrote:

Sorry, but these lines of code do not work on my project.
The property "touches" is not defined (chrome desktop & tablet)

//_mx = (evt.pageX || evt.touches[0].pageX);
//_my = (evt.pageY || evt.touches[0].pageY);
_mx = (evt.pageX || evt.originalEvent.touches[0].pageX); // ? why ?
_my = (evt.pageY || evt.originalEvent.touches[0].pageY); // ? why ?


Reply to this email directly or view it on GitHub
#55 (comment)
.

@jtrotoux
Copy link
Contributor

jtrotoux commented Jan 9, 2015

I did comment the 2 lines to confirm the problem was here. http://caniuse.com/#feat=touch
The 2 lines at the bottom work well :
_mx = (evt.pageX || evt.originalEvent.touches[0].pageX);
_my = (evt.pageY || evt.originalEvent.touches[0].pageY);

arashsoft added a commit to arashsoft/ngDraggable that referenced this pull request Jan 9, 2015
@arashsoft
Copy link

I added .originalEvent and it works.

@guidokessels
Copy link

👍 It'd be great not to have to include jQuery just for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants