Skip to content

Commit

Permalink
Moved failOrShim to the parent adapter class
Browse files Browse the repository at this point in the history
  • Loading branch information
stuyam committed Mar 8, 2016
1 parent 6ff8660 commit fbf85aa
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 55 deletions.
30 changes: 12 additions & 18 deletions dist/jquery.pressure.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,17 @@ var Adapter = (function () {
value: function setDeepPressed(boolean) {
this.deepPressed = boolean;
}
}, {
key: 'failOrShim',
value: function failOrShim(event) {
Support.didFail();
// is the shim option set
if (Config.get('shim', this.element.options) === true) {
this.shim = new AdapterShim(this.element, event);
} else {
runClosure(this.block, 'unsupported', this.el);
}
}

// prevent the default action of text selection, "peak & pop", and force touch special feature

Expand Down Expand Up @@ -166,7 +177,6 @@ var Adapter3DTouch = (function (_Adapter) {
iter += 1;
setTimeout(this.supportCallback.bind(this), 10, iter, event);
} else if (this.pressed) {
Support.didFail();
this.failOrShim(event);
}
} else if (Support.forPressure || this.shim instanceof AdapterShim) {
Expand All @@ -175,16 +185,6 @@ var Adapter3DTouch = (function (_Adapter) {
this.failOrShim(event);
}
}
}, {
key: 'failOrShim',
value: function failOrShim(event) {
// is the shim option set
if (Config.get('shim', this.element.options) === true) {
this.shim = new AdapterShim(this.element, event);
} else {
runClosure(this.block, 'unsupported', this.el);
}
}
}, {
key: '$start',
value: function $start() {
Expand Down Expand Up @@ -320,13 +320,7 @@ var AdapterForceTouch = (function (_Adapter2) {
this.remove('webkitmouseforcewillbegin', this.forceTouchEnabled);
this.preventDefault(event);
} else {
Support.didFail();
// is the shim option set
if (Config.get('shim', this.element.options) === true) {
this.shim = new AdapterShim(this.element, event);
} else {
runClosure(this.block, 'unsupported', this.el);
}
this.failOrShim(event);
}
}
}, {
Expand Down
2 changes: 1 addition & 1 deletion dist/jquery.pressure.min.js

Large diffs are not rendered by default.

30 changes: 12 additions & 18 deletions dist/pressure.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,17 @@ var Adapter = (function () {
value: function setDeepPressed(boolean) {
this.deepPressed = boolean;
}
}, {
key: 'failOrShim',
value: function failOrShim(event) {
Support.didFail();
// is the shim option set
if (Config.get('shim', this.element.options) === true) {
this.shim = new AdapterShim(this.element, event);
} else {
runClosure(this.block, 'unsupported', this.el);
}
}

// prevent the default action of text selection, "peak & pop", and force touch special feature

Expand Down Expand Up @@ -171,7 +182,6 @@ var Adapter3DTouch = (function (_Adapter) {
iter += 1;
setTimeout(this.supportCallback.bind(this), 10, iter, event);
} else if (this.pressed) {
Support.didFail();
this.failOrShim(event);
}
} else if (Support.forPressure || this.shim instanceof AdapterShim) {
Expand All @@ -180,16 +190,6 @@ var Adapter3DTouch = (function (_Adapter) {
this.failOrShim(event);
}
}
}, {
key: 'failOrShim',
value: function failOrShim(event) {
// is the shim option set
if (Config.get('shim', this.element.options) === true) {
this.shim = new AdapterShim(this.element, event);
} else {
runClosure(this.block, 'unsupported', this.el);
}
}
}, {
key: '$start',
value: function $start() {
Expand Down Expand Up @@ -325,13 +325,7 @@ var AdapterForceTouch = (function (_Adapter2) {
this.remove('webkitmouseforcewillbegin', this.forceTouchEnabled);
this.preventDefault(event);
} else {
Support.didFail();
// is the shim option set
if (Config.get('shim', this.element.options) === true) {
this.shim = new AdapterShim(this.element, event);
} else {
runClosure(this.block, 'unsupported', this.el);
}
this.failOrShim(event);
}
}
}, {
Expand Down
2 changes: 1 addition & 1 deletion dist/pressure.min.js

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions src/adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ class Adapter{
this.deepPressed = boolean;
}

failOrShim(event){
Support.didFail();
// is the shim option set
if(Config.get('shim', this.element.options) === true){
this.shim = new AdapterShim(this.element, event);
} else {
runClosure(this.block, 'unsupported', this.el);
}
}

// prevent the default action of text selection, "peak & pop", and force touch special feature
preventDefault(event){
if(Config.get('preventDefault', this.element.options) === true){
Expand Down
10 changes: 0 additions & 10 deletions src/adapter_3d_touch.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class Adapter3DTouch extends Adapter{
iter += 1;
setTimeout(this.supportCallback.bind(this), 10, iter, event);
} else if(this.pressed){
Support.didFail();
this.failOrShim(event);
}
} else if(Support.forPressure || this.shim instanceof AdapterShim){
Expand All @@ -44,15 +43,6 @@ class Adapter3DTouch extends Adapter{
}
}

failOrShim(event){
// is the shim option set
if(Config.get('shim', this.element.options) === true){
this.shim = new AdapterShim(this.element, event);
} else {
runClosure(this.block, 'unsupported', this.el);
}
}

$start(){
// call 'start' when the touch goes down
this.add('touchstart', (event) => {
Expand Down
8 changes: 1 addition & 7 deletions src/adapter_force_touch.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,7 @@ class AdapterForceTouch extends Adapter{
this.remove('webkitmouseforcewillbegin', this.forceTouchEnabled);
this.preventDefault(event);
} else {
Support.didFail();
// is the shim option set
if(Config.get('shim', this.element.options) === true){
this.shim = new AdapterShim(this.element, event);
} else {
runClosure(this.block, 'unsupported', this.el);
}
this.failOrShim(event);
}
}

Expand Down

0 comments on commit fbf85aa

Please sign in to comment.