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

App-level support for passive gesture touch listeners #4829

Merged
merged 3 commits into from
Sep 11, 2017

Conversation

dfreedm
Copy link
Member

@dfreedm dfreedm commented Sep 7, 2017

Apps can set Polymer.passiveTouchGestures to true to force all touch listeners for gestures to use passive event handlers.
This may improve scrolling performance, at the cost of being unable to control scrolling with gestureEvent.preventDefault().
Instead, elements must use Polymer.Gestures.setTouchAction(node, 'direction')

This PR overrules #4724

Fixes #4667
Fixes #3787
Fixes #3604

@dfreedm
Copy link
Member Author

dfreedm commented Sep 7, 2017

Hmm, looks like closure linting is broken on travis now :(

Copy link
Contributor

@TimvdLippe TimvdLippe left a comment

Choose a reason for hiding this comment

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

Tested this yesterday with LightHouse and inspected your smoke test. This seems to be working!

*
* @memberof Polymer
*/
Polymer.passiveTouchGestures = Polymer.passiveTouchGestures || false;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be a function for forward compatibility

window.addEventListener('test', null, opts);
window.removeEventListener('test', null, opts);
} catch(e) {}
})();

// decide whether to use {passive: true} for gestures listening for touch events
let PASSIVE_TOUCH = Boolean(HAS_NATIVE_TA && SUPPORTS_PASSIVE && Polymer.passiveTouchGestures);
Copy link
Contributor

Choose a reason for hiding this comment

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

passiveTouchGestures should be a function for forward compat.

Clean up event listener options inside gestures that use passive touch
@sorvell sorvell merged commit 4a2d427 into master Sep 11, 2017
@sorvell sorvell deleted the optional-passive-gestures branch September 11, 2017 22:03
@dfreedm
Copy link
Member Author

dfreedm commented Sep 11, 2017

This will ship as Polymer 2.1

dfreedm added a commit that referenced this pull request Sep 11, 2017
dfreedm added a commit that referenced this pull request Sep 12, 2017
@matthew-dean
Copy link

This is labelled as being related to touch gestures, but will this also allow this.listen to support passive scroll event listeners? Since this closes #3604 it suggests this is the case, but is that true? This seems related to just toggling an app-wide default for gestures, and not supporting component-level listeners to individually set passive event listeners, correct?

@matthew-dean
Copy link

Just to re-iterate, I think this incorrectly closes #3604 and #3604 should be re-opened.

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

Successfully merging this pull request may close these issues.

5 participants