# HG changeset patch # User Harris Baptiste # Date 1469535972 -7200 # Node ID 7257527afd4ab507cffb96ec9bcb3469530ff635 # Parent d1cdbbfff73fe0d06382d8e5a5b82d67c3597f64 new zoom viewport diff -r d1cdbbfff73f -r 7257527afd4a src/iconolab/static/iconolab/css/iconolab.css --- a/src/iconolab/static/iconolab/css/iconolab.css Fri Jul 22 17:33:48 2016 +0200 +++ b/src/iconolab/static/iconolab/css/iconolab.css Tue Jul 26 14:26:12 2016 +0200 @@ -7,6 +7,11 @@ .form-drawing-wrapper .selected {border: 1px solid orange; color: white; background-color: orange} .showPointer {cursor: pointer;} +.zoom-action-list {padding-left:21px;} +.zoomTarget-wrapper { padding: 0px;} +#zoomTarget, .cut-canvas {border: 1px solid #C3C3C3; padding-top: 2px; padding-bottom: 2px} + +.no-padding {padding-left: 0; padding-right: 0;} .annotation-content{ margin-top: 15px; margin-bottom: 15px; diff -r d1cdbbfff73f -r 7257527afd4a src/iconolab/static/iconolab/js/iconolab-bundle/src/components/cutout/snapsvg-zoom.js --- a/src/iconolab/static/iconolab/js/iconolab-bundle/src/components/cutout/snapsvg-zoom.js Fri Jul 22 17:33:48 2016 +0200 +++ b/src/iconolab/static/iconolab/js/iconolab-bundle/src/components/cutout/snapsvg-zoom.js Tue Jul 26 14:26:12 2016 +0200 @@ -6,13 +6,21 @@ constructor (params) { this.zoomFactor = 0.1 || params.zoomFactor; this.paper = params.paper; - var width = parseInt(this.paper.select(".main-image").attr("width")); - var height = parseInt(this.paper.select(".main-image").attr("height")); - this.viewport = {width: width, height: height}; + this.MIN_SIZE = 40; + this.imageWidth = parseInt(this.paper.select(".main-image").attr("width")); + this.imageHeight = parseInt(this.paper.select(".main-image").attr("height")); + + this.viewport = { + width: parseInt(this.paper.attr("width")), + height: parseInt(this.paper.attr("height")) + }; + this.scale = 1; + this.paper.attr({stroke: 2, "fill": "blue" }); this.disableDrag = false; - this.currentViewBox = [0, 0, this.viewport.width, this.viewport.height]; + this.imgMinSize = Math.min(this.imageWidth, this.imageHeight); this.lastPosition = []; + this.updateViewBox([0 , 0, this.imageWidth, this.imageHeight], false); } testShowCenter (cx, cy) { @@ -33,23 +41,20 @@ zoomIn () { /* current center */ + if ( this.scale === 9) { this.scale--; return; } var currentCenterX = this.currentViewBox[0] + (this.currentViewBox[2] / 2); var currentCenterY = this.currentViewBox[1] + (this.currentViewBox[3] / 2); var scaleFactor = this.zoomFactor * this.scale; - var viewBoxW = this.viewport.width - (this.viewport.width * scaleFactor); - var viewBoxH = this.viewport.height - (this.viewport.height * scaleFactor); + var viewBoxW = this.imgMinSize - (this.imgMinSize * scaleFactor); + var viewBoxH = viewBoxW; - if (viewBoxW <= 0 && viewBoxH <=0) { - return false; - } - this.currentViewBox[0] = currentCenterX - viewBoxW / 2; this.currentViewBox[1] = currentCenterY - viewBoxH / 2; this.currentViewBox[2] = viewBoxW; this.currentViewBox[3] = viewBoxH; + this.scale ++; this.updateViewBox(); - this.scale ++; } updateViewBox (currentViewBox, notify) { @@ -71,6 +76,9 @@ }, "zoomFactor": this.getZoomFactor(), "viewport": this.viewport, + "currentScale": this.scale, + "imageSize": {width: this.imageWidth, height: this.imageHeight}, + "minSize": Math.min(this.imageWidth, this.imageHeight), "currentViewBox": this.currentViewBox.slice() }); } @@ -129,33 +137,31 @@ reset () { this.scale = 1; - this.currentViewBox = [0, 0, this.viewport.width, this.viewport.height]; + this.currentViewBox = [0, 0, this.imageWidth, this.imageHeight]; this.updateViewBox(); } zoomOut () { - if (this.scale === 1) { return false; } - + if (this.scale == 1) { + return false; + } + var currentCenterX = this.currentViewBox[0] + (this.currentViewBox[2] / 2); var currentCenterY = this.currentViewBox[1] + (this.currentViewBox[3] / 2); + var scaleFactor = this.zoomFactor * (this.scale - 1); - var viewBoxW = this.currentViewBox[2] + (this.viewport.width * this.zoomFactor); - var viewBoxH = this.currentViewBox[3] + (this.viewport.height * this.zoomFactor); - if (viewBoxW >= this.viewport.width || viewBoxW >= this.viewport.height) { - return false; - } + var viewBoxW = this.imgMinSize - (this.imgMinSize * scaleFactor); + var viewBoxH = viewBoxW; + var topX = currentCenterX - viewBoxW / 2; var topY = currentCenterY - viewBoxH / 2; - /* fix size */ - this.currentViewBox[0] = topX; + this.currentViewBox[0] = topX; //deal with X and Y this.currentViewBox[1] = topY; this.currentViewBox[2] = viewBoxW; this.currentViewBox[3] = viewBoxH; - + this.updateViewBox(); this.scale--; - this.updateViewBox(); - } } diff -r d1cdbbfff73f -r 7257527afd4a src/iconolab/static/iconolab/js/iconolab-bundle/src/components/cutout/svgboard.js --- a/src/iconolab/static/iconolab/js/iconolab-bundle/src/components/cutout/svgboard.js Fri Jul 22 17:33:48 2016 +0200 +++ b/src/iconolab/static/iconolab/js/iconolab-bundle/src/components/cutout/svgboard.js Tue Jul 26 14:26:12 2016 +0200 @@ -524,21 +524,20 @@ cutCanvas.css({ - position: 'absolute', + /*position: 'absolute', top: '0px', - left: '15px', + left: '15px',*/ marginLeft: 'auto', marginRight: 'auto', - width: mainImage.attr('width'), - height: mainImage.attr('height'), - //viewBox: '0 0 100 100' + width: 850, + height: 850 }); /* fix the container size */ - jQuery(config.wrapperId).css({ + /*jQuery(config.wrapperId).css({ width: mainImage.attr('width'), height: parseInt(mainImage.attr('height')) + 5 - }); + });*/ if (typeof config.readOnly === 'boolean' && config.readOnly === true) { readOnly = true; diff -r d1cdbbfff73f -r 7257527afd4a src/iconolab/static/iconolab/js/iconolab-bundle/src/components/utils/index.js --- a/src/iconolab/static/iconolab/js/iconolab-bundle/src/components/utils/index.js Fri Jul 22 17:33:48 2016 +0200 +++ b/src/iconolab/static/iconolab/js/iconolab-bundle/src/components/utils/index.js Tue Jul 26 14:26:12 2016 +0200 @@ -1,11 +1,12 @@ import EventEmitter from 'event-emitter' var eventEmitter = EventEmitter({}); + var generateId = (function () { var cpt = 0; var defautPrefix = "item_"; return function (prefix) { - prefix = (typeof prefix === 'string') ? prefix : defautPrefix; + prefix = (typeof prefix === "string") ? prefix : defautPrefix; cpt = cpt + 1; return prefix + cpt; } diff -r d1cdbbfff73f -r 7257527afd4a src/iconolab/static/iconolab/js/iconolab-bundle/src/components/zoomview/Zoomview.vue --- a/src/iconolab/static/iconolab/js/iconolab-bundle/src/components/zoomview/Zoomview.vue Fri Jul 22 17:33:48 2016 +0200 +++ b/src/iconolab/static/iconolab/js/iconolab-bundle/src/components/zoomview/Zoomview.vue Tue Jul 26 14:26:12 2016 +0200 @@ -3,21 +3,26 @@