To change the overlay position when changing the image size, you must modify the method for resetting the image size. The code in the source file is as follows:
mxGraph.prototype.resizeCells = function(cells, bounds) { this.model.beginUpdate(); try { this.cellsResized(cells, bounds); this.fireEvent(new mxEventObject(mxEvent.RESIZE_CELLS, 'cells', cells, 'bounds', bounds)); } finally { this.model.endUpdate(); } return cells;};
In this method, we need to change the position of overlay. First, we need to obtain the overlays of the current image. When creating overlay, We can customize some attributes of overlay, such as index, in this way, it is easier to locate a specific overlay and change its location based on the conditions.
MxGraph. prototype. resizeCells = function (cells, bounds) {this. model. beginUpdate (); try {this. cellsResized (cells, bounds); this. fireEvent (new mxEventObject (mxEvent. RESIZE_CELLS, 'cells ', cells, 'bounds', bounds); var _ this = this; $. each (cells, function (I, item) {var overlays = _ this. getCellOverlays (item); $. each (overlays, function (j, overlay) {if (overlay. tooltip = 'radiation fig') {if (ylCommon. isAllowEdit () {overlay. offset. x = item. geometry. width-35;} else {overlay. offset. x = item. geometry. width-15 ;}} if(overlay.image.src.indexOf('lock.png ')> 0) {overlay. offset. x = item. geometry. width-15 ;}}) ;}) ;}finally {this. model. endUpdate ();} return cells ;};