Merge pull request #1050 from ONLYOFFICE/fix/fix-bugs-on-mobiles

Fix/fix bugs on mobiles
This commit is contained in:
Julia Radzhabova 2021-08-06 21:37:09 +03:00 committed by GitHub
commit eb5edfd2b5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 23 deletions

View file

@ -203,26 +203,21 @@ class SearchView extends Component {
onEditorTouchStart(e) {
this.startPoint = this.pointerPosition(e);
// console.log(this.startPoint);
}
onEditorTouchEnd(e) {
const endPoint = this.pointerPosition(e);
// console.log(endPoint);
if (this.searchbar.enabled) {
let distance;
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);
} else {
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) {
this.searchbar.disable();
}
@ -231,15 +226,10 @@ class SearchView extends Component {
pointerPosition(e) {
let out = {x:0, y:0};
if ( e.type == 'touchstart' || e.type == 'touchend' ) {
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' ) {
if ( e.type == 'pointerdown' || e.type == 'pointerup' || e.type == 'mousedown' || e.type == 'mouseup') {
out.x = e.pageX;
out.y = e.pageY;
}
return out;
}

View file

@ -11,8 +11,6 @@ const PreviewController = props => {
let _view, _touches, _touchStart, _touchEnd;
_view = $$('#pe-preview');
useEffect(() => {
const onDocumentReady = () => {
const api = Common.EditorApi.get();
@ -25,10 +23,10 @@ const PreviewController = props => {
show();
onDocumentReady();
_view = $$('#pe-preview');
_view.on('touchstart', onTouchStart);
_view.on('touchmove', onTouchMove);
_view.on('touchend', onTouchEnd);
_view.on('click', onClick);
return () => {
const api = Common.EditorApi.get();
@ -38,7 +36,6 @@ const PreviewController = props => {
_view.off('touchstart', onTouchStart);
_view.off('touchmove', onTouchMove);
_view.off('touchend', onTouchEnd);
_view.off('click', onClick);
};
}, []);
@ -82,15 +79,10 @@ const PreviewController = props => {
if (_touchEnd[0] - _touchStart[0] > 20)
api.DemonstrationPrevSlide();
else if (_touchStart[0] - _touchEnd[0] > 20)
else if (_touchStart[0] - _touchEnd[0] > 20 || (Math.abs(_touchEnd[0] - _touchStart[0]) < 1 && Math.abs(_touchEnd[1] - _touchStart[1]) < 1))
api.DemonstrationNextSlide();
};
const onClick = e => {
const api = Common.EditorApi.get();
api.DemonstrationNextSlide();
};
// API Handlers
const onEndDemonstration = () => {

View file

@ -146,7 +146,7 @@ const ToolbarController = inject('storeAppOptions', 'users', 'storeSpreadsheetIn
onRedo={onRedo}
disabledControls={disabledControls}
disabledEditControls={disabledEditControls || isObjectLocked || editFormulaMode || isEditCell}
disabledSearch={editFormulaMode}
disabledSearch={editFormulaMode || isEditCell}
disabledSettings={disabledSettings || editFormulaMode || isEditCell}
displayCollaboration={displayCollaboration}
disabledCollaboration={editFormulaMode || isEditCell}