[mobile] Fix search
This commit is contained in:
parent
4f8c61b246
commit
d1c9c8525d
|
@ -203,26 +203,21 @@ class SearchView extends Component {
|
||||||
|
|
||||||
onEditorTouchStart(e) {
|
onEditorTouchStart(e) {
|
||||||
this.startPoint = this.pointerPosition(e);
|
this.startPoint = this.pointerPosition(e);
|
||||||
// console.log(this.startPoint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onEditorTouchEnd(e) {
|
onEditorTouchEnd(e) {
|
||||||
const endPoint = this.pointerPosition(e);
|
const endPoint = this.pointerPosition(e);
|
||||||
// console.log(endPoint);
|
|
||||||
|
|
||||||
if (this.searchbar.enabled) {
|
if (this.searchbar.enabled) {
|
||||||
let distance;
|
let distance;
|
||||||
|
|
||||||
if(this.startPoint) {
|
if(this.startPoint) {
|
||||||
distance = (!!this.startPoint.x || !!this.startPoint.y) ? 0 :
|
distance = (this.startPoint.x === undefined || this.startPoint.y === undefined) ? 0 :
|
||||||
Math.sqrt((endPoint.x -= this.startPoint.x) * endPoint.x + (endPoint.y -= this.startPoint.y) * endPoint.y);
|
Math.sqrt((endPoint.x -= this.startPoint.x) * endPoint.x + (endPoint.y -= this.startPoint.y) * endPoint.y);
|
||||||
} else {
|
} else {
|
||||||
distance = 0;
|
distance = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// const distance = (this.startPoint === undefined || this.startPoint === undefined) ? 0 :
|
|
||||||
// Math.sqrt((endPoint.x -= this.startPoint.x) * endPoint.x + (endPoint.y -= this.startPoint.y) * endPoint.y);
|
|
||||||
|
|
||||||
if (distance < 1) {
|
if (distance < 1) {
|
||||||
this.searchbar.disable();
|
this.searchbar.disable();
|
||||||
}
|
}
|
||||||
|
@ -231,15 +226,10 @@ class SearchView extends Component {
|
||||||
|
|
||||||
pointerPosition(e) {
|
pointerPosition(e) {
|
||||||
let out = {x:0, y:0};
|
let out = {x:0, y:0};
|
||||||
if ( e.type == 'touchstart' || e.type == 'touchend' ) {
|
if ( e.type == 'pointerdown' || e.type == 'pointerup' || e.type == 'mousedown' || e.type == 'mouseup') {
|
||||||
const touch = e.originalEvent.touches[0] || e.originalEvent.changedTouches[0];
|
|
||||||
out.x = touch.pageX;
|
|
||||||
out.y = touch.pageY;
|
|
||||||
} else if ( e.type == 'mousedown' || e.type == 'mouseup' ) {
|
|
||||||
out.x = e.pageX;
|
out.x = e.pageX;
|
||||||
out.y = e.pageY;
|
out.y = e.pageY;
|
||||||
}
|
}
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue