dist/jcanvas-handles.js
function (layer) {
			var parent = layer._parent;

			if (parent.width + (layer.dx * layer._px) < parent.minWidth) {
				parent.width = parent.minWidth;
				layer.dx = 0;
			}
			if (parent.height + (layer.dy * layer._py) < parent.minHeight) {
				parent.height = parent.minHeight;
				layer.dy = 0;
			}

			if (!parent.resizeFromCenter) {
				// Optionally constrain proportions
				if (parent.constrainProportions) {
					if (layer._py === 0) {
						// Manage handles whose y is at layer's center
						parent.height = parent.width / parent.aspectRatio;
					} else {
						// Manage every other handle
						parent.width = parent.height * parent.aspectRatio;
						layer.dx = layer.dy * parent.aspectRatio * layer._py * layer._px;
					}
				}
				// Optionally resize rectangle from corner
				if (parent.fromCenter) {
					parent.width += layer.dx * layer._px;
					parent.height += layer.dy * layer._py;
				} else {
					// This is simplified version based on math. Also you can write this using an if statement for each handle
					parent.width += layer.dx * layer._px;
					if (layer._px !== 0) {
						parent.x += layer.dx * ((1 - layer._px) && (1 - layer._px) / Math.abs((1 - layer._px)));
					}
					parent.height += layer.dy * layer._py;
					if (layer._py !== 0) {
						parent.y += layer.dy * ((1 - layer._py) && (1 - layer._py) / Math.abs((1 - layer._py)));
					}
				}
				// Ensure diagonal handle does not move
				if (parent.fromCenter) {
					if (layer._px !== 0) {
						parent.x += layer.dx / 2;
					}
					if (layer._py !== 0) {
						parent.y += layer.dy / 2;
					}
				}
			} else {
				// Otherwise, resize rectangle from center
				parent.width += layer.dx * layer._px * 2;
				parent.height += layer.dy * layer._py * 2;
				// Optionally constrain proportions
				if (parent.constrainProportions) {
					if (layer._py === 0) {
						// Manage handles whose y is at layer's center
						parent.height = parent.width / parent.aspectRatio;
					} else {
						// Manage every other handle
						parent.width = parent.height * parent.aspectRatio;
					}
				}
			}
			updateRectHandles(parent);
			$(this).triggerLayerEvent(parent, 'handlemove');
		}
function (layer) {
			var parent = layer._parent;

			if (parent.width + (layer.dx * layer._px) < parent.minWidth) {
				parent.width = parent.minWidth;
				layer.dx = 0;
			}
			if (parent.height + (layer.dy * layer._py) < parent.minHeight) {
				parent.height = parent.minHeight;
				layer.dy = 0;
			}

			if (!parent.resizeFromCenter) {
				// Optionally constrain proportions
				if (parent.constrainProportions) {
					if (layer._py === 0) {
						// Manage handles whose y is at layer's center
						parent.height = parent.width / parent.aspectRatio;
					} else {
						// Manage every other handle
						parent.width = parent.height * parent.aspectRatio;
						layer.dx = layer.dy * parent.aspectRatio * layer._py * layer._px;
					}
				}
				// Optionally resize rectangle from corner
				if (parent.fromCenter) {
					parent.width += layer.dx * layer._px;
					parent.height += layer.dy * layer._py;
				} else {
					// This is simplified version based on math. Also you can write this using an if statement for each handle
					parent.width += layer.dx * layer._px;
					if (layer._px !== 0) {
						parent.x += layer.dx * ((1 - layer._px) && (1 - layer._px) / Math.abs((1 - layer._px)));
					}
					parent.height += layer.dy * layer._py;
					if (layer._py !== 0) {
						parent.y += layer.dy * ((1 - layer._py) && (1 - layer._py) / Math.abs((1 - layer._py)));
					}
				}
				// Ensure diagonal handle does not move
				if (parent.fromCenter) {
					if (layer._px !== 0) {
						parent.x += layer.dx / 2;
					}
					if (layer._py !== 0) {
						parent.y += layer.dy / 2;
					}
				}
			} else {
				// Otherwise, resize rectangle from center
				parent.width += layer.dx * layer._px * 2;
				parent.height += layer.dy * layer._py * 2;
				// Optionally constrain proportions
				if (parent.constrainProportions) {
					if (layer._py === 0) {
						// Manage handles whose y is at layer's center
						parent.height = parent.width / parent.aspectRatio;
					} else {
						// Manage every other handle
						parent.width = parent.height * parent.aspectRatio;
					}
				}
			}
			updateRectHandles(parent);
			$(this).triggerLayerEvent(parent, 'handlemove');
		}
function ( layer ) { var parent = layer . _parent ; if ( parent . width + ( layer . dx * layer . _px ) < parent . minWidth ) { parent . width = parent . minWidth ; layer . dx = 0 ; } if ( parent . height + ( layer . dy * layer . _py ) < parent . minHeight ) { parent . height = parent . minHeight ; layer . dy = 0 ; } if ( ! parent . resizeFromCenter ) { // Optionally constrain proportions if ( parent . constrainProportions ) { if ( layer . _py === 0 ) { // Manage handles whose y is at layer's center parent . height = parent . width / parent . aspectRatio ; } else { // Manage every other handle parent . width = parent . height * parent . aspectRatio ; layer . dx = layer . dy * parent . aspectRatio * layer . _py * layer . _px ; } } // Optionally resize rectangle from corner if ( parent . fromCenter ) { parent . width += layer . dx * layer . _px ; parent . height += layer . dy * layer . _py ; } else { // This is simplified version based on math. Also you can write this using an if statement for each handle parent . width += layer . dx * layer . _px ; if ( layer . _px !== 0 ) { parent . x += layer . dx * ( ( 1 - layer . _px ) && ( 1 - layer . _px ) / Math . abs ( ( 1 - layer . _px ) ) ) ; } parent . height += layer . dy * layer . _py ; if ( layer . _py !== 0 ) { parent . y += layer . dy * ( ( 1 - layer . _py ) && ( 1 - layer . _py ) / Math . abs ( ( 1 - layer . _py ) ) ) ; } } // Ensure diagonal handle does not move if ( parent . fromCenter ) { if ( layer . _px !== 0 ) { parent . x += layer . dx / 2 ; } if ( layer . _py !== 0 ) { parent . y += layer . dy / 2 ; } } } else { // Otherwise, resize rectangle from center parent . width += layer . dx * layer . _px * 2 ; parent . height += layer . dy * layer . _py * 2 ; // Optionally constrain proportions if ( parent . constrainProportions ) { if ( layer . _py === 0 ) { // Manage handles whose y is at layer's center parent . height = parent . width / parent . aspectRatio ; } else { // Manage every other handle parent . width = parent . height * parent . aspectRatio ; } } } updateRectHandles ( parent ) ; $ ( this ) . triggerLayerEvent ( parent , 'handlemove' ) ; }
Resize rectangle when dragging a handle
Resize rectangle when dragging a handle