-
-
Notifications
You must be signed in to change notification settings - Fork 594
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 - Pointer over/out event fixes #448
MouseTracker - Pointer over/out event fixes #448
Conversation
if ( this.element.style[ "touch-action" ] !== undefined ) { | ||
this.element.style[ "touch-action" ] = "none"; | ||
} else if ( this.element.style[ "-ms-touch-action" ] !== undefined ) { | ||
this.element.style[ "-ms-touch-action" ] = "none"; |
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.
Shouldn’t this be this.element.style.msTouchAction
? Found this here: http://blogs.msdn.com/b/thebeebs/archive/2012/01/11/with-vendor-prefixes-what-is-the-javascript-equivalent-of-ms.aspx
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.
Hi Daniel, I thought so too, and I thought I found that in the IE docs, but now I'm going to look again!
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.
👍
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.
Well I can't find the example of course :) So what's the proper way to do this? I'd much rather use the dot syntax over the key string syntax, which means I chose that way for a reason I wish I could remember. My only worry is cross-browser compatibility, and currently both ways work on the only two browsers that have touch-action implemented: IE 10/11 and Chrome (latest). Thanks!
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.
Can you try this.element.style.touchAction
and this.element.style.msTouchAction
? Then again, I’d recommend creating a helper function that auto-prefixes vendor specific CSS properties, e.g. https://github.com/peutetre/vendor-prefix.
Then again, if it works, maybe just leave it and sorry for the intrusion 😉
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.
Fixed :)
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.
Nice! Re: code snippet. Here’s another one I learned from our dear friend (and my former mentor) @iangilman: If you got three or more copies, consider extracting it 😉
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.
He may make me do it now, even though I slipped it through review before. Thanks. ;)
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.
Fixed, before he even saw it :)
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.
👍
} else if ( typeof element.style.msTouchAction !== 'undefined' ) { | ||
element.style.msTouchAction = 'none'; | ||
} | ||
}, |
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.
👍 Well done, sir 😄
I just noticed a possible bug that this PR introduces. Setting |
@dom96 What kind of issues? |
@msalsbery the viewport gets stuck at the corners of the image. |
@dom96 I can't see anything on Windows 8.1 IE or Firefox. On the demo site or using those builds separately? OS and browser? MouseTracker only processes browser events and calls common event callbacks so results in the viewport should be identical with mouse or touch. |
@msalsbery separately. On Windows 7 with Firefox. I'll see if i can On Wednesday, August 6, 2014, Mark Salsbery notifications@github.com
|
@dom96 Try setting visibilityRatio on the viewer to something like 0.25. Flick is only enabled by default for true browser touch events, so if the tablet browser converts touch events to legacy mouse events then you have to manually enable it as you've seen. Thanks for the testing and feedback! |
Looks good to me. Great to see all of the testing on the various issues! @msalsbery could you add changelog for it? (Usually I don't ask contributors to do so, but this is a big enough patch, you might as well). Also, do any tests need updating? I'll hold off on merging until we've heard back from @dom96. |
@iangilman Will-do on the changelog. Tested the tests, no changes requiring test updates. Tested on: |
@dom96 I see with mouse flick gesture enabled you can drag the image outside the viewport and it stays out of sight. Is that what you're referring to? That's a bug, fixing... |
@msalsbery that might be it. It didn't really stay out of sight for me though. My viewport was at the very edge of the image, and then I tried panning in the opposite direction (away from the corner) at which point the 'flick' feature seems to have moved it back to the corner. The issue is a bit intermittent, and after a while of trying to pan in the opposite direction it does get unstuck. |
…/releasePointer() functions
@dom96 I wasn't able to reproduce any unexpected behavior, but I've fixed it so you can't drag the image out of view when flick gesture is enabled (demo site updated with new OpenSeadragon builds). Hopefully your issue was related to that. |
@iangilman New commits, changelog updated |
@msalsbery unfortunately that doesn't fix it. I can reproduce it in your demo site but it's very subtle. If you pan to a corner and then gently flick away from it, it will pan back to its original position. From what I can tell this is more prominent with custom tiles sources, or perhaps larger images. I tried a number of different settings and changing to a custom tile source seems to have the biggest effect. I have tried my custom tile source in your demo page too and I can reproduce it. The |
@dom96 That is as-designed (or as implemented anyway), the dreaded Viewport.applyConstraints() function. It shouldn't happen if the image is zoomed larger than the viewport. I've never liked its behavior but every time I go in to change it I bail out. MouseTracker just handles browser events and passes them on to attached callbacks, so it's not relevant to this patch. |
@dom96 Additionally, your flick settings are pretty aggressive, especially for the mouse device. I tried those settings originally when trying to work out reasonable defaults, but had to find a fairly dead compromise because of the applyConstraints behavior (that's why it's now flickMinSpeed: 120, flickMomentum: 0.25). There's two other settings that come into play here: springStiffness and animationTime. These affect the "spring" physics that dampen the kinetic flick movement. Instead of pushing the flickMomentum setting up, you can try increasing the spring animation time and/or decreasing the spring stiffness. When it seems to stick in the corner, it's actually taking the computed target based on the flick velocity and momentum setting, then trying to pan to that target. With the large momentum setting, the pan target is off the viewport so applyConstraints() brings it back in. The resulting appearance is it sticks. @iangilman called me out on it when I originally added the flick gesture with more aggressive settings :) |
Lovely... looks like this is ready to merge, assuming you're happy, @msalsbery. |
@iangilman Go for it, thanks! |
MouseTracker - Pointer over/out event fixes
Fixes #152, #404, #420, #427