-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add passive option to touch event listeners. #680
Conversation
I like this, but:
|
Understood. Is this a usual warning to get: |
If you have jquery UI slider, then I can see that happening. Otherwise, no. |
This is happening when I run the grunt test. Even on Travis. Does this look better? I found a way to fallback using a quick functionality check. |
I don't actually know how effectively that would work, to be perfectly honest. |
The detection is the same used by a few libraries (like detect-it.js) so I have confidence in it, |
@@ -741,9 +741,21 @@ const windowIsDefined = (typeof window === "object"); | |||
this.touchmove = this._touchmove.bind(this); | |||
|
|||
if (this.touchCapable) { | |||
// Test for passive event support | |||
var supportsPassive = false; |
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 declare this variable with let
instead of var
to scope to nearest enclosing block?
// Test for passive event support | ||
var supportsPassive = false; | ||
try { | ||
var opts = Object.defineProperty({}, 'passive', { |
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 declare opts
with let
instead of var
to ensure it is only scoped within the try {}
block?
Great PR @crhallberg! In regards to the fallback check, I saw that Paul Irish himself recommends a similar technique, so I am cool with that. I left some feedback in the code so if you could incorporate that and ping me that would be much appreciated. Thanks! |
I resolved the conflict with the date change and converted my variables to |
Merged and published to v9.7.0. Thanks again for your contribution @crhallberg! |
Thanks for letting me! |
By adding a passive option to the
touchstart
andtouchmove
events we can let the browser know that we do not intend to ever cancel scroll events. I found no such cases in_touchstart
nor_touchmove
. This will prevent any scroll lag that may be caused by this library.More on passive event listeners
grunt test
in your Terminal within the bootstrap-slider repository directoryThere is also some trailing whitespace cleanup I can remove if you'd prefer.