Skip to content

Commit

Permalink
Only preventDefaults IF they support pressure
Browse files Browse the repository at this point in the history
If they do not support pressure, it should not be setting css
properties on the element
  • Loading branch information
stuyam committed Feb 5, 2016
1 parent a861ae4 commit 4cb10e1
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 28 deletions.
12 changes: 3 additions & 9 deletions dist/jquery.pressure.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,11 @@ var Element = (function () {
this.element = element;
this.block = block;
this.type = options.hasOwnProperty('only') ? options.only : null;
this.cssPrevention(options);
this.options = options;
this.routeEvents();
}

_createClass(Element, [{
key: 'cssPrevention',
value: function cssPrevention(options) {
if (!options.hasOwnProperty('preventDefault') || options.preventDefault !== false) {
this.element.style.webkitUserSelect = "none";
}
}
}, {
key: 'routeEvents',
value: function routeEvents() {
// if on desktop and requesting Force Touch or not requesting 3D Touch
Expand Down Expand Up @@ -264,6 +256,7 @@ var Adapter3DTouch = (function (_Adapter) {
value: function preventDefault3DTouch() {
if (this.element.options.hasOwnProperty('preventDefault') === false || this.element.options.preventDefault !== false) {
this.el.style.webkitTouchCallout = "none";
this.el.style.webkitUserSelect = "none";
}
}
}]);
Expand Down Expand Up @@ -398,8 +391,9 @@ var AdapterForceTouch = (function (_Adapter2) {
// prevent the default force touch action for bound elements
this.add('webkitmouseforcewillbegin', function (event) {
if (Support.forPressure) {
if (!_this11.element.options.hasOwnProperty('preventDefault') || _this11.element.options.preventDefault !== false) {
if (_this11.element.options.hasOwnProperty('preventDefault') === false || _this11.element.options.preventDefault !== false) {
event.preventDefault();
_this11.el.style.webkitUserSelect = "none";
}
}
});
Expand Down
2 changes: 1 addition & 1 deletion dist/jquery.pressure.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 3 additions & 9 deletions dist/pressure.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,11 @@ var Element = (function () {
this.element = element;
this.block = block;
this.type = options.hasOwnProperty('only') ? options.only : null;
this.cssPrevention(options);
this.options = options;
this.routeEvents();
}

_createClass(Element, [{
key: 'cssPrevention',
value: function cssPrevention(options) {
if (!options.hasOwnProperty('preventDefault') || options.preventDefault !== false) {
this.element.style.webkitUserSelect = "none";
}
}
}, {
key: 'routeEvents',
value: function routeEvents() {
// if on desktop and requesting Force Touch or not requesting 3D Touch
Expand Down Expand Up @@ -266,6 +258,7 @@ var Adapter3DTouch = (function (_Adapter) {
value: function preventDefault3DTouch() {
if (this.element.options.hasOwnProperty('preventDefault') === false || this.element.options.preventDefault !== false) {
this.el.style.webkitTouchCallout = "none";
this.el.style.webkitUserSelect = "none";
}
}
}]);
Expand Down Expand Up @@ -400,8 +393,9 @@ var AdapterForceTouch = (function (_Adapter2) {
// prevent the default force touch action for bound elements
this.add('webkitmouseforcewillbegin', function (event) {
if (Support.forPressure) {
if (!_this11.element.options.hasOwnProperty('preventDefault') || _this11.element.options.preventDefault !== false) {
if (_this11.element.options.hasOwnProperty('preventDefault') === false || _this11.element.options.preventDefault !== false) {
event.preventDefault();
_this11.el.style.webkitUserSelect = "none";
}
}
});
Expand Down
Loading

0 comments on commit 4cb10e1

Please sign in to comment.