-
Notifications
You must be signed in to change notification settings - Fork 224
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
DragInteraction callbacks for dragstart, drag, and dragend #743
Conversation
Sweet, I retriggered the build (saucelabs, our cross-browser CI solution, is kind of flaky), aim to CR later today |
@@ -9,7 +9,9 @@ export module Interaction { | |||
public location = [0,0]; | |||
private constrainX: (n: number) => number; | |||
private constrainY: (n: number) => number; | |||
public callbackToCall: (dragInfo: any) => any; | |||
public ondragstart: (dragInfo: any) => any; | |||
public ondrag: (dragInfo: any) => any; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you line these up pretty please :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy to know that y'all care about coding style. If there's anything more let me know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw, i meant space align so the interfaces line up
the implementation looks good to me, i think that enabling the user to put in seperate callbacks for the different events (start/drag/end) makes sense and is better than sneakily indicating it with some sort of flag. although @jtlan should take a look since he's been working on interactions and refactoring them going forward. re api design / interfaces, i think there's room for discussion. i'm not super excited by the interface inconsistency ( see also #631 |
As per suggestions, |
So, looks good and could probably merge in present form, but I feel like we can still make the API surface cleaner: |
Not sure I understand the API suggestions for The |
So, |
Alright, files have been updated. A lot was removed from Also, as you've said, this introduces API changes. I couldn't find examples/tutorials or other pages where a DragBox is used and needs to be updated. If I've missed something let me know. |
|
Curious, why did you decide to change from returning two tuples instead of 4 labeled points? |
The |
* Adds a callback to be called when the AreaInteraction triggers. | ||
* Adds a callback to be called when dragging starts. | ||
* | ||
* @param {(a: SelectionArea) => any} cb The function to be called. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless I'm mistaken the param here does not match the underlying code, your callback does not take in selectionAreas, rather it takes in ICoord's.
If this is in fact an error, please fix it in all instances (I see it repeated below).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are not mistaken. The jsdoc is incorrect/inaccurate
Yes only using one is a good point... Then I would prefer not to have lowerLeft upperRight. If I remember my Cocos then it's usually more common to have the location of the interaction, so for dragEnd you'd have a callback (dragEndLocation: ICoord, dragStartLocation: ICoord). I don't really like the bottomLeft/upperRight since it loses information, the callback has no knowledge of the drag direction/which corners created the drag. |
Hold up, what's a good argument for top left/ bottom right? we were doing stuff like this:
because we already have this interface:
|
Fent - sorry, you happen to be touching the least mature / most controversial part of our API, so this PR is going very slowly compared to the complexity of the changes :) OK, so I don't think bottomLeft / topRight is the best for a generic So maybe we should standardize on just 2 points, |
I agree with not losing information. But I think |
Yeah that makes sense to me. |
@@ -9,7 +9,9 @@ export module Interaction { | |||
public location = [0,0]; | |||
private constrainX: (n: number) => number; | |||
private constrainY: (n: number) => number; | |||
public callbackToCall: (dragInfo: any) => any; | |||
public ondragstart: (origin: ICoord) => void; | |||
public ondrag: (upperLeft: ICoord, lowerRight: ICoord) => void; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
git diff is showing this as a tab I believe. If this is a tab, I think single-space is preferred for consistency
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, strange. It shows it as spaces.
I have vim set up so that it uses spaces for everything except golang. would be odd if it decided to insert a tab here.
Please ignore the fact that it's failing travis, and CR it |
It seems that Travis won't give the environment variables to pull requests from forked repositories. This probably explains why it's failing. I'll try to see if I can disable running saucelabs for external pull requests in the meantime. |
Looking into this slightly I see this Travis CI: Configuring your build Which would confirm @lewin 's guess if our environment variable are secure. If this is the case, I'm perfectly fine with letting this go through. |
To specify for QEs, please QE this. If it gets a QE+1, we can merge it in and Travis should theoretically not crash on us |
Conflicts: plottable.d.ts plottable.js test/tests.js
Yay it passed |
public callbackToCall: (dragInfo: any) => any; | ||
public ondragstart: (startLocation: Point) => void; | ||
public ondrag: (startLocation: Point, endLocation: Point) => void; | ||
public ondragend: (startLocation: Point, endLocation: Point) => void; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry to keep extending this pr, but can you doc these variables?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there an example somewhere on how they should be documented?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually, a choice that's more consistent with our codebase would be to privatize/protect these variables. there's no need for them to be public/package exported since there is already a function point for getting/setting these. if the variables were referenced from other Plottable classes, then the appropriate action would be to _name them, however since they seem to be used only in this class we should mark them private. then there is no need to document them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, good catch.
-1 until doced. I'll +1 after doc This still can be QE-reviewed. Please review it when you can. |
Removing -1 for clarity. Will readd +1 after documentation is added |
I take back what I said above. QE should review this anyways, but I don't want the lack of -1 to mean that it should be +1'ed above or that there should be no more code submitted. |
-1: When you go here: http://jsfiddle.net/v4vrN/1/ and change the second script line to: , this example no longer works. Maybe I'm just doing something wrong here, but I'm not positive that there isn't a bug involving window.onload. |
@simoneschaffer, this PR contains breaking changes to the API, so it's expected that the old jsfiddle will break. here is a JSFiddle that uses the new API and verifies that it functions correctly: |
Conflicts: plottable.d.ts
Ah, yes, this looks awesome -- thanks for clearing my confusion, too, @danmane! GIL. |
Merge on build pass |
Merge conflict again :( |
Conflicts: plottable.js
DragInteraction callbacks for dragstart, drag, and dragend
Working towards #365, and realized I needed this.
This takes care of #630 too.