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

Method zoomImage

js/main.js:950–985  ·  view source on GitHub ↗
({ wheelDelta, clientX, clientY }, forceWheenDelta, forceZoomForce)

Source from the content-addressed store, hash-verified

948 return handled;
949 }
950 zoomImage({ wheelDelta, clientX, clientY }, forceWheenDelta, forceZoomForce) {
951 let whD = wheelDelta;
952 if (forceWheenDelta !== undefined) {
953 whD = forceWheenDelta;
954 }
955 let minFactor = 1;
956 if (this.size.w > this.wrapper.documentClientWidth) {
957 minFactor = Math.min(minFactor, this.wrapper.documentClientWidth / this.size.w);
958 }
959 if (this.size.h > this.wrapper.documentClientHeight) {
960 minFactor = Math.min(minFactor, this.wrapper.documentClientHeight / this.size.h);
961 }
962 if (!this.zoom && this.zoomFactor > minFactor) {
963 this.zoomFactor = minFactor;
964 }
965 let zoomForce = 0.2;
966 if (forceZoomForce !== undefined) {
967 zoomForce = forceZoomForce;
968 }
969
970 this.zoomFactor += Math.sign(whD) * zoomForce;
971 if (this.zoomFactor < minFactor) {
972 this.zoom = false;
973 this.zoomFactor = minFactor;
974 } else {
975 this.zoom = true;
976 }
977 this.adjustSizeFull();
978 this.select.adjustPosition();
979 if (this.zoom) {
980 this.scroller.scrollLeft = (this.curCord[0] / this.getScale()) -
981 (clientX - this.wrapper.documentOffsetLeft);
982 this.scroller.scrollTop = (this.curCord[1] / this.getScale()) -
983 (clientY - this.wrapper.documentOffsetTop);
984 }
985 }
986 initEventHandlers() {
987 this.documentHandlers = {
988 mousedown: (e) => {

Callers 2

constructorMethod · 0.95
initEventHandlersMethod · 0.95

Calls 3

adjustSizeFullMethod · 0.95
getScaleMethod · 0.95
adjustPositionMethod · 0.80

Tested by

no test coverage detected