fix position of pointer in brush tool and eraser pointer

This commit is contained in:
Casper Lamboo 2018-05-09 13:22:23 +02:00
parent b0c0063039
commit ac2256d2c5
2 changed files with 4 additions and 2 deletions

View File

@ -1,6 +1,7 @@
import { Vector } from 'cal'; import { Vector } from 'cal';
import transposeEvents from '../utils/transposeEvents.js'; import transposeEvents from '../utils/transposeEvents.js';
import { PIXEL_RATIO } from '../constants/general.js'; import { PIXEL_RATIO } from '../constants/general.js';
import { convertEvent } from '../utils/pointerUtils.js';
// import createDebug from 'debug'; // import createDebug from 'debug';
// const debug = createDebug('d3d:design:EraserPointer'); // const debug = createDebug('d3d:design:EraserPointer');
@ -28,7 +29,7 @@ export default class EraserPointer {
pointerMove(event) { pointerMove(event) {
this.showMouse = event.pointerType === 'mouse'; this.showMouse = event.pointerType === 'mouse';
if (this.erasing || this.showMouse) { if (this.erasing || this.showMouse) {
this.mousePosition.set(event.clientX, event.clientY); this.mousePosition.copy(convertEvent(event.target, event));
if (this.onChanged) this.onChanged(); if (this.onChanged) this.onChanged();
} }
} }

View File

@ -1,6 +1,7 @@
import BaseTool from './BaseTool.js'; import BaseTool from './BaseTool.js';
import { Vector } from 'cal'; import { Vector } from 'cal';
import { PIXEL_RATIO } from '../../constants/general.js'; import { PIXEL_RATIO } from '../../constants/general.js';
import { convertEvent } from '../../utils/pointerUtils.js';
// import createDebug from 'debug'; // import createDebug from 'debug';
// const debug = createDebug('d3d:2d:tool:eraser'); // const debug = createDebug('d3d:2d:tool:eraser');
export default class BrushTool extends BaseTool { export default class BrushTool extends BaseTool {
@ -14,7 +15,7 @@ export default class BrushTool extends BaseTool {
pointerMove(event) { pointerMove(event) {
this.showMouse = event.pointerType === 'mouse'; this.showMouse = event.pointerType === 'mouse';
if (this.showMouse) { if (this.showMouse) {
this.mousePosition.set(event.clientX, event.clientY); this.mousePosition.copy(convertEvent(event.target, event));
this.renderRequest(); this.renderRequest();
} }
} }