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

MouseTracker original events in handlers #215

Merged
merged 15 commits into from
Sep 24, 2013
Merged

MouseTracker original events in handlers #215

merged 15 commits into from
Sep 24, 2013

Conversation

msalsbery
Copy link
Member

Implemented "Expose original event in handlers" (#23) for MouseTracker

Added OpenSeadragon.getElementOffset() method. Element-relative mouse
coordinates should be correct even if the element and/or page is
scrolled (#131)

Implemented "Expose original event in handlers" (#23) for MouseTracker

Added OpenSeadragon.getElementOffset() method. Element-relative mouse
coordinates should be correct even if the element and/or page is
scrolled (#131)
@houseofyin
Copy link
Contributor

Would it make sense to extend the event tests to verify the new features?

inTo( _this, $.ButtonState.HOVER );
}
},

focusHandler: function( tracker, position, buttonDownElement, buttonDownAny ) {
this.enterHandler( tracker, position, buttonDownElement, buttonDownAny );
// TODO: This didn't match handler signature in MouseTracker. Investigate!
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this and the other similar cases, I suspect the mismatch wasn't noticed because the extra parameters had not been used. However, that's just a hunch on my part.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They were used by passing them to different handlers however. I removed the commented code and it should work like it did, but it needs to be fixed in my opinion.

@msalsbery
Copy link
Member Author

New commits - cleaned up distracting whitespace changes, cleaned up comments mentioned by houseofyin.

Bug fixes.  Event handler methods shouldn't be called directly in
theory...
Pass original touch events to handlers.
@@ -127,7 +138,7 @@
* Are we currently tracking mouse events.
* @property {Boolean} capturing
* Are we curruently capturing mouse events.
* @property {Boolean} buttonDown
* @property {Boolean} buttonDownElement
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This name makes it seem like it's an element rather than a flag. That's a tricky one to come up with a good name for, though. Maybe stick with buttonDown?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe standardize on insideElementPress?

@iangilman
Copy link
Member

Wow, this is quite the patch! As you see I had a bunch of comments and questions, but I think in general it's going in the right direction. I agree that this patch needs tests, especially since it's such a major change.

On the whitespace front, sounds like you should tell your IDE to mellow out! I use Sublime Text for what it's worth, and I'm very happy with it.

Thanks @houseofyin for pitching in on the review! And of course thanks @msalsbery for rolling up your sleeves and dig into this!

@msalsbery
Copy link
Member Author

The white space changes are all unintentional. I'm not itching to make any changes there :) I turned on auto spacing for non empty parenthesis to match existing code style, but my IDE's removal of white space and auto indenting blocks causes the most problems since I don't notice it happening then have to make a thousand manual changes...frustrating. Definitely needs to chill .)

I agree with all the comments and I will fix them all. Just wanted to note that I left all names and logic intact this first pass intentionally to lessen confusion except for the mousedowninelement flag name that was inconsistent and the mousemove mousemovewindow mousemoveie stuff that was necessary to keep existing consistency when I added a mousemove handler that didn't exist before. I personally use naming like onMouseMoveCaptured and onMouseMove to differentiate between captured and non captured handlers, but I tried to stick with existing convention here. Seems based on your comments we are on the same page and I can be a bit more confident in making changes that make sense.

The shift shiftKey duplication was I believe because the native event uses one name and another was being used. I know I had a good reason at the time :) I will reevaluate that one and fix it.

Touch events are all converted to mouse events which is why you weren't seeing where we extract the touch event. It's there though, just happens right at the touch event handler and was never used past that point. Now the original touch event moves through to the MouseTracker subscriber handlers.

Documentation: I'm still not up on how that gets generated from the code comments and I don't know where to look to see the generated documentation so I left it as is with a rough shell of my changes... Help! :)

@houseofyin
Copy link
Contributor

I think the code changes look good. There still look to be some unneeded while space changes, but I'll defer to @iangilman as to whether that is a problem from a code management perspective.

@iangilman
Copy link
Member

@houseofyin, thanks for looking it over!

I'm okay with the current state of whitespace changes in this patch, but I do look forward to fewer whitespace changes in future patches. ;-)

@msalsbery, your next steps all sound good. What do you think about adding the tests and breaking change documentation to this patch and doing the rest in follow-up patches?

@msalsbery
Copy link
Member Author

your next steps all sound good. What do you think about adding the tests and breaking change documentation to this patch and doing the rest in follow-up patches?

Yes definitely separate patch(es).

@msalsbery
Copy link
Member Author

What's the convention on spaces in non-empty () and []? I personally have never used leading and trailing spaces there and don't find it reads any better than I'm used to. Just my opinion.

@houseofyin
Copy link
Contributor

Should there be a code formatter integrated with grunt to enforce whatever style is chosen?

@msalsbery
Copy link
Member Author

In changelog.txt, what version number should the change be documented under?

@iangilman
Copy link
Member

The codebase currently uses "inner white space" for non-empty () and [], thus:

if ( foo ) {
    var a = [ "boo", "baz" ];
}

I personally don't care for that, and this is the only project I've worked on that has had this style, so I don't think it's all that common. I believe @thatcher is the one who started using that style and he's been stepping back from contributing lately (though he may come back!).

So, as long as we have that style I feel we should remain consistent to it. If we all agree we want to change it, we should do it for the entire project all at once.

@houseofyin we do currently have a few code style rules in our linter, but nothing terribly extreme. The problem with doing it at the linter level is that it's easy to forget about and then your patch doesn't pass the tests or whatever. A stronger approach would be to add some sort of rule in Grunt that actually modifies the source code, but that sounds like a dangerous path to start down. Another approach would be to include whatever style enforcement options that are possible in the .sublime-project file for users of Sublime Text, and likewise for whatever other IDEs people use.

@iangilman
Copy link
Member

@msalsbery we'll likely release 0.9.131 before landing this patch. Document the changes under a new 1.0.0 section at the top.

@iangilman
Copy link
Member

There are a number of spots in this patch where the inner white space has been removed from square brackets... perhaps you should revert that aspect of the change?

Also, I'm curious which browsers and devices you've been able to test on.

@msalsbery
Copy link
Member Author

I test on IE 10, Chrome, Safari Windows, and Firefox...all fairly current or current versions. Will be testing on iOS Safari iPhone/iPad in next few days. That's my available test platforms at the moment.

I'll go through and fix whitespace.

@iangilman
Copy link
Member

Sounds like a great set of test platforms. I've got an Android here as well, so I can try there.

@msalsbery
Copy link
Member Author

New commit - unit tests for MouseTracker.

Sorry for the delay...got sidetracked implementing a Durandal version upgrade with lots of breaking changes. Fun :)

@msalsbery
Copy link
Member Author

New commit - changelog.txt update

Whitespace fixes on un-empty [] brackets
@msalsbery
Copy link
Member Author

New commit - whitespace fixes on un-empty []

changelog.txt fixed issue reference numbers (#23) (#215)
@msalsbery
Copy link
Member Author

New commit - changelog.txt issue number fix (#215 to #23)

@msalsbery
Copy link
Member Author

New commit - hopefully the last changelog.txt fix

@iangilman
Copy link
Member

Looks great! I think that's it, right? Please merge in the latest master (looks like there are conflicts) and then I'll merge this pull request.

I'm going to publish what we currently have before merging. Then we should do any other planned breaking changes (such as #200) before we publish this. @msalsbery can you take care of #200?

@msalsbery
Copy link
Member Author

Yes I'll take care of all the changes mentioned in #200

@msalsbery
Copy link
Member Author

I'm not showing any conflicts with the Master branch...

"This branch is 15 commits ahead and 0 commits behind master"

@iangilman
Copy link
Member

Your master or openseadragon/openseadragon's master? Have you pulled the latest into your fork?

@iangilman iangilman merged commit 5335048 into openseadragon:master Sep 24, 2013
@iangilman
Copy link
Member

Anyway, I went ahead and merged (after fixing the conflict... it was just the changelog file). Congratulations on landing an excellent patch!

@msalsbery
Copy link
Member Author

Cool thanks! Next time there's a conflict I'll try to find where to merge it back in to mine. Thanks for doing that.

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.

3 participants