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

Method initEventHandlers

js/main.js:986–1189  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

984 }
985 }
986 initEventHandlers() {
987 this.documentHandlers = {
988 mousedown: (e) => {
989 if (this.shown) {
990 if (this.worklog.empty &&
991 (e.target.className.indexOf('ptro-crp-el') !== -1 ||
992 e.target.className.indexOf('ptro-icon') !== -1 ||
993 e.target.className.indexOf('ptro-named-btn') !== -1)) {
994 this.clearBackground(); // clear initText
995 }
996 if (this.colorPicker.handleMouseDown(e) !== true) {
997 this.handleToolEvent('handleMouseDown', e);
998 }
999 }
1000 },
1001 touchstart: (e) => {
1002 if (e.touches.length === 1) {
1003 e.clientX = e.changedTouches[0].clientX;
1004 e.clientY = e.changedTouches[0].clientY;
1005 this.documentHandlers.mousedown(e);
1006 } else if (e.touches.length === 2) {
1007 const fingersDist = distance({
1008 x: e.touches[0].clientX,
1009 y: e.touches[0].clientY,
1010 }, {
1011 x: e.touches[1].clientX,
1012 y: e.touches[1].clientY,
1013 });
1014 this.lastFingerDist = fingersDist;
1015 }
1016 },
1017 touchend: (e) => {
1018 e.clientX = e.changedTouches[0].clientX;
1019 e.clientY = e.changedTouches[0].clientY;
1020 this.documentHandlers.mouseup(e);
1021 },
1022 touchmove: (e) => {
1023 if (e.touches.length === 1) {
1024 e.clientX = e.touches[0].clientX;
1025 e.clientY = e.touches[0].clientY;
1026 this.documentHandlers.mousemove(e);
1027 } else if (e.touches.length === 2) {
1028 const fingersDist = distance({
1029 x: e.touches[0].clientX,
1030 y: e.touches[0].clientY,
1031 }, {
1032 x: e.touches[1].clientX,
1033 y: e.touches[1].clientY,
1034 });
1035
1036 const center = {
1037 x: (e.touches[0].clientX + e.touches[1].clientX) / 2,
1038 y: (e.touches[0].clientY + e.touches[1].clientY) / 2,
1039 };
1040
1041 e.clientX = center.x;
1042 e.clientY = center.y;
1043

Callers 1

constructorMethod · 0.95

Calls 15

clearBackgroundMethod · 0.95
handleToolEventMethod · 0.95
elLeftMethod · 0.95
elTopMethod · 0.95
getScaleMethod · 0.95
zoomImageMethod · 0.95
handleClipCopyEventMethod · 0.95
getBtnElMethod · 0.95
saveMethod · 0.95
openFileMethod · 0.95
adjustSizeFullMethod · 0.95
syncToolElementMethod · 0.95

Tested by

no test coverage detected