MCPcopy Create free account
hub / github.com/devforth/painterro / handleMouseMove

Method handleMouseMove

js/selecter.js:336–434  ·  view source on GitHub ↗
(event)

Source from the content-addressed store, hash-verified

334 }
335
336 handleMouseMove(event) {
337 if (!this.area.activated) {
338 return;
339 }
340 if (this.area.moving) {
341 let newLeft = (event.clientX - this.main.elLeft() - this.area.xHandle)
342 + this.main.scroller.scrollLeft;
343 if (newLeft < 0) {
344 newLeft = 0;
345 } else if (newLeft + this.area.rect.clientWidth > this.area.el.clientWidth - 2) {
346 newLeft = this.area.el.clientWidth - this.area.rect.clientWidth - 2;
347 }
348 const hDelta = newLeft - this.left;
349 this.setLeft(newLeft);
350 this.setRight(this.right - hDelta);
351
352 let newTop = (event.clientY - this.main.elTop() - this.area.yHandle)
353 + this.main.scroller.scrollTop;
354 if (newTop < 0) {
355 newTop = 0;
356 } else if (newTop + this.area.rect.clientHeight > this.area.el.clientHeight - 2) {
357 newTop = this.area.el.clientHeight - this.area.rect.clientHeight - 2;
358 }
359 const vDelta = newTop - this.top;
360 this.setTop(newTop);
361 this.setBottom(this.bottom - vDelta);
362 this.reCalcCropperCords();
363 } else {
364 let resizing = false;
365 if (this.area.resizingL) {
366 resizing = true;
367 const absLeft = this.fixCropperLeft(event.clientX + this.main.scroller.scrollLeft);
368 this.setLeft(absLeft - this.main.elLeft());
369 this.reCalcCropperCords();
370 }
371 if (this.area.resizingR) {
372 resizing = true;
373 const absRight = this.fixCropperRight(event.clientX + this.main.scroller.scrollLeft);
374 this.setRight(
375 (this.area.el.clientWidth + this.main.elLeft()) - absRight);
376 this.reCalcCropperCords();
377 }
378 if (this.area.resizingT) {
379 resizing = true;
380 const absTop = this.fixCropperTop(event.clientY + this.main.scroller.scrollTop);
381 this.setTop(absTop - this.main.elTop());
382 this.reCalcCropperCords();
383 }
384 if (this.area.resizingB) {
385 resizing = true;
386 const absBottom = this.fixCropperBottom(event.clientY + this.main.scroller.scrollTop);
387 this.setBottom(
388 (this.area.el.clientHeight + this.main.elTop()) - absBottom);
389 this.reCalcCropperCords();
390 }
391 if (this.imagePlaced && !(event.ctrlKey || event.shiftKey)) {
392 if (this.area.resizingT) {
393 if (this.area.resizingL) {

Callers

nothing calls this directly

Calls 15

setLeftMethod · 0.95
setRightMethod · 0.95
setTopMethod · 0.95
setBottomMethod · 0.95
reCalcCropperCordsMethod · 0.95
fixCropperLeftMethod · 0.95
fixCropperRightMethod · 0.95
fixCropperTopMethod · 0.95
fixCropperBottomMethod · 0.95
leftKeepRatioMethod · 0.95
rightKeepRatioMethod · 0.95
topKeepRatioMethod · 0.95

Tested by

no test coverage detected