1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-01-11 18:24:43 +02:00

Desktop: Fixes #1273: Trying to improve accuracy of sidebar resizing

This commit is contained in:
Laurent Cozic 2019-02-27 22:44:10 +00:00
parent 0957298cb8
commit 33f7b680bc
2 changed files with 10 additions and 8 deletions

View File

@ -87,7 +87,7 @@ class NoteTextViewerComponent extends React.Component {
// In particular it means that background images and colours won't be printed (printBackground property will be ignored)
// return this.webviewRef_.current.getWebContents().print({});
this.webviewRef_.current.getWebContents().executeJavaScript("window.print()")
return this.webviewRef_.current.getWebContents().executeJavaScript("window.print()")
}
openDevTools() {

View File

@ -1,4 +1,5 @@
const React = require("react");
const electron = require('electron');
class VerticalResizer extends React.PureComponent {
@ -31,16 +32,16 @@ class VerticalResizer extends React.PureComponent {
document.addEventListener('dragover', this.document_onDragOver)
event.dataTransfer.dropEffect= 'none';
const cursor = electron.screen.getCursorScreenPoint();
this.setState({
drag: {
startX: event.nativeEvent.clientX,
lastX: event.nativeEvent.clientX,
startX: cursor.x,
lastX: cursor.x,
}
});
console.info('START', event.nativeEvent);
if (this.props.onDragStart) this.props.onDragStart({});
}
@ -49,10 +50,11 @@ class VerticalResizer extends React.PureComponent {
// that we should ignore, because it's sometimes use to put the dragged element
// back to its original position (if there was no valid drop target), which we don't want.
// Also if clientX, screenX, etc. are 0, it's also the last event and we want to ignore these buggy values.
const e = event.nativeEvent;
if (!e.buttons || (!e.clientX && !e.clientY && !e.screenX && !e.screenY)) return;
// const e = event.nativeEvent;
// if (!e.buttons || (!e.clientX && !e.clientY && !e.screenX && !e.screenY)) return;
const newX = event.nativeEvent.clientX;
const cursor = electron.screen.getCursorScreenPoint();
const newX = cursor.x;
const delta = newX - this.state.drag.lastX;
if (!delta) return;