Browse Source

评卷图片放大缩小bug修改

luoshi 6 years ago
parent
commit
4398bc8e8e

+ 6 - 2
stmms-web/src/main/webapp/static/mark-new/js/modules/single-image-view.js

@@ -91,7 +91,7 @@ SingleImageView.prototype.init = function() {
         self.markControl.trigger('image.reload.event');
         self.markControl.trigger('image.reload.event');
     });
     });
     this.imageControl.find('.zoom-fit-button').click(this, function(event) {
     this.imageControl.find('.zoom-fit-button').click(this, function(event) {
-        self.reloadImage();
+        self.reloadImage('fit');
         self.markControl.trigger('image.reload.event');
         self.markControl.trigger('image.reload.event');
     });
     });
 }
 }
@@ -116,7 +116,11 @@ SingleImageView.prototype.reloadImage = function(scaleAddon) {
     if (this.image != undefined) {
     if (this.image != undefined) {
         var scale = this.scale;
         var scale = this.scale;
         if (scaleAddon != undefined) {
         if (scaleAddon != undefined) {
-            scale += scaleAddon;
+        	if (scaleAddon=='fit') {
+        		scale = 1.0;
+        	} else {
+            	scale += scaleAddon;
+            }
         }
         }
         if (scale < 0.2) {
         if (scale < 0.2) {
             scale = 0.2;
             scale = 0.2;

+ 8 - 4
stmms-web/src/main/webapp/static/mark-track/js/modules/single-image-view.js

@@ -76,7 +76,7 @@ SingleImageView.prototype.init = function() {
         self.markControl.trigger('image.reload.event');
         self.markControl.trigger('image.reload.event');
     });
     });
     this.imageControl.find('.zoom-fit-button').click(this, function(event) {
     this.imageControl.find('.zoom-fit-button').click(this, function(event) {
-        self.reloadImage();
+        self.reloadImage('fit');
         self.markControl.trigger('image.reload.event');
         self.markControl.trigger('image.reload.event');
     });
     });
 }
 }
@@ -101,7 +101,11 @@ SingleImageView.prototype.reloadImage = function(scaleAddon) {
     if (this.image != undefined) {
     if (this.image != undefined) {
         var scale = this.scale;
         var scale = this.scale;
         if (scaleAddon != undefined) {
         if (scaleAddon != undefined) {
-            scale += scaleAddon;
+        	if (scaleAddon == 'fit') {
+        		scale = 1.0;
+        	} else {
+        		scale += scaleAddon;
+        	}
         }
         }
         if (scale < 0.2) {
         if (scale < 0.2) {
             scale = 0.2;
             scale = 0.2;
@@ -115,7 +119,7 @@ SingleImageView.prototype.reloadImage = function(scaleAddon) {
             this.scale = scale;
             this.scale = scale;
         }
         }
 
 
-        this.canvas.width = Math.min(this.container.width(), this.image.width) * this.image.scale;
+        this.canvas.width = Math.min(this.container.width(), this.image.width) * this.scale;
         this.canvas.height = this.canvas.width * this.image.height / this.image.width;
         this.canvas.height = this.canvas.width * this.image.height / this.image.width;
         this.ctx.drawImage(this.image, 0, 0, this.image.width, this.image.height, 0, 0, this.canvas.width, this.canvas.height);
         this.ctx.drawImage(this.image, 0, 0, this.image.width, this.image.height, 0, 0, this.canvas.width, this.canvas.height);
     }
     }
@@ -123,7 +127,7 @@ SingleImageView.prototype.reloadImage = function(scaleAddon) {
 
 
 SingleImageView.prototype.drawTag = function(tag) {
 SingleImageView.prototype.drawTag = function(tag) {
     if (tag != undefined && tag.positionX > 0 && tag.positionY > 0 && this.image != undefined) {
     if (tag != undefined && tag.positionX > 0 && tag.positionY > 0 && this.image != undefined) {
-        this.ctx.font = parseInt(60 * this.image.scale) + "px Arial";
+        this.ctx.font = parseInt(60 * this.scale) + "px Arial";
         this.ctx.fillStyle = 'red';
         this.ctx.fillStyle = 'red';
         this.ctx.fillText(tag.content, tag.positionX * this.canvas.width, tag.positionY * this.canvas.height);
         this.ctx.fillText(tag.content, tag.positionX * this.canvas.width, tag.positionY * this.canvas.height);
     }
     }