stuyam / pressure

:point_down::boom: JavaScript library for handling Force Touch, 3D Touch, and Pointer Pressure.
https://pressurejs.com
MIT License
2.92k stars 97 forks source link

When should the prevent Default be set? #36

Closed stuyam closed 8 years ago

stuyam commented 8 years ago

I originally set the preventDefault css and other things on first touch, but then most of the time that means the first click or touch will not have those things applied. Should prevent default be applies immediately?

I currently apply it on first click to first determine if pressure is supported or not first. But maybe that doesn't make the most sense and maybe it should be set immediately?

Also should the defaults be separated on mobile vs desktop?

stuyam commented 8 years ago

Added in his commit in v2.0.0 https://github.com/stuyam/pressure/commit/75fd0603e2ef74349953b7f240605dc2eb32247b

stuyam commented 8 years ago

Leave event.preventDefault() up to the developer outside the library. The only thing I can tell it does it prevent the highlight box in Chrome on iOS. However is has some consequences, for example on iOS it makes it so you can not scroll when your finger is touching the element that's event is prevented default. That is why I leave it up to the developer base on their needs for their specific implementation.

The peek & pop and other actions are prevented by applying css with the preventSelect option in pressure. https://github.com/stuyam/pressure/commit/2c11127ca0a3af1da991352a72a01a213dedecbe