const drag = {
	/**
	 * 部件缩放中事件四角缩放
	 */
	scaleMove(e, item, data, allLineListData, designWidth, designHeight) {
		item.isShowLineV = false; //初始化默认不显示
		item.isShowLineH = false; //初始化默认不显示
		var minwwidth = 20
		var minwheight = 20
		if (item.type == 0 || item.type == 2) {
			minwwidth = 20
			minwheight = 20
		} else if (item.type == 1) {
			minwwidth = 20
			minwheight = 20
		}
		item.touchMoveX = e.touches[0].clientX; //记录移动后的x位置
		item.touchMoveY = e.touches[0].clientY; //记录移动后的y位置
		//属性
		item.active = false //辅助线
		item.activeguide = false //辅助线
		item.activescale = false // 旋转状态
		item.activehorn = true // 角状态
		item.activeedge = false // 边状态
		let width = item.touchMoveX - item.touchX //计算手指移动x轴距离
		let height = item.touchMoveY - item.touchY //计算手指移动y轴距离
		let c = Math.sqrt(Math.pow(width, 2) + Math.pow(height, 2)) //使用三角公式计算边c长度
		let angle = this.getAngle(width, height) //计算移动位置角度差
		let rad = (Math.PI / 180) * (angle - item.newRotate) //旋转角度转换公式
		let diffY = (Math.sin(rad) * c) //计算角度差x轴
		let diffX = (Math.cos(rad) * c) //计算角度差y轴
		item.elmX = item.lastElmX
		item.elmY = item.lastElmY
		item.elmW = item.lastElmW
		item.elmH = item.lastElmH
		let scale = item.elmW / item.elmH; //计算宽高比例
		let fixed;
		if (item.typetext == "left-top") {
			fixed = {
				x: 'right',
				y: 'bottom'
			}
			diffX = -diffX;
			item.elmW += diffX //计算高度
			item.elmH = item.elmW / scale; //计算宽度 对应比例
		} else if (item.typetext == "left-bottom") {
			fixed = {
				x: 'right',
				y: 'top'
			}
			diffX = -diffX
			item.elmW += diffX //计算高度
			item.elmH = item.elmW / scale; //计算宽度 对应比例
		} else if (item.typetext == "right-top") {
			fixed = {
				x: 'left',
				y: 'bottom'
			}
			item.elmW += diffX; //计算高度
			item.elmH = item.elmW / scale; //计算宽度 对应比例
		} else if (item.typetext == "right-bottom") {
			fixed = {
				x: 'left',
				y: 'top'
			}
			item.elmW += diffX; //计算高度
			item.elmH = item.elmW / scale; //计算宽度 对应比例
		}

		item.isDrag = true;
		if (item.elmW < minwwidth) {
			item.elmW = minwwidth //设置最小宽度
			item.elmH = item.elmW / scale; //计算高度对应比例
			if (item.type == 0 || item.type == 2) {
				item.isDrag = false; //设置四周部件操作控件
			}
		}

		if (item.elmH < minwheight) {
			item.elmH = minwheight; //设置最小高度
			item.elmW = item.elmH * scale; //计算宽度 对应比例
			if (item.type == 0 || item.type == 2) {
				item.isDrag = false; //设置四周部件操作控件
			}
		}

		if (item.elmW > 800) {
			item.elmW = 800 //设置最小宽度
			item.elmH = item.elmW / scale; //计算高度对应比例
		}

		if (item.elmH > 800) {
			item.elmH = 800 //设置最小宽度
			item.elmW = item.elmH * scale; //计算宽度 对应比例
		}

		let getNewData = this.fixedTo(item, fixed, item.newRotate) //计算对角差距数据
		item.elmX = getNewData.x; //赋值x轴新数据
		item.elmY = getNewData.y; //赋值y轴新数据
		item.left = item.elmX; //重新赋值左上角x位置
		item.top = item.elmY; //重新赋值左上角y位置
		item.width = item.elmW //重新设置宽度
		item.height = item.elmH //重新设置高度

		let newScale = item.elmH / item.lastElmH //计算新比例
		item.initialScale = item.lastInitialScale * newScale //乘以对应之前比例
		item.initialscaling = item.lastInitialscaling * newScale //乘以对应之前比例
		if (item.lastImageLeft < 0) { //判断是否图片有左右间距
			item.image_left = item.lastImageLeft * newScale
		} else {
			item.image_left = 0
		}
		if (item.lastImageTop < 0) { //判断是否图片有上下间距
			item.image_top = item.lastImageTop * newScale
		} else {
			item.image_top = 0
		}

		item.fontscale = (item.lastFontscale * newScale) //乘以对应之前比例
		item.font_size = (item.lastFontSize * newScale) //乘以对应之前比例
		item.lineheight = (item.lastLineheight * newScale) //乘以对应之前比例

		//记录中心位置
		item.centerPos = {
			x: item.left + item.width / 2,
			y: item.top + item.height / 2
		}

		item.x = item.centerPos.x;
		item.y = item.centerPos.y;

		item.edgestartX = e.touches[0].clientX; // 获取鼠标按下时光标x的值
		item.edgestartY = e.touches[0].clientY; // 获取鼠标按下时光标Y的值

		//计算圆角
		this.getConterScale(item)
	},

	//计算相差角度
	getAngle(x, y) {
		let theta = Math.atan2(y, x) // range (-PI, PI]
		theta = Math.round((180 / Math.PI) * theta) // rads to degs, range (-180, 180]
		if (theta < 0) theta = 360 + theta // range [0, 360)
		return theta
	},

	//计算位置
	fixedTo(item, fixed, rotate) {
		let rect = {
			top: item.elmY,
			right: item.elmX + item.elmW,
			bottom: item.elmY + item.elmH,
			left: item.elmX
		}
		let {
			x: fixedX,
			y: fixedY
		} = this.rotatedPoint(
			rect,
			rotate,
			fixed
		)
		let dX = item.fixedX - fixedX
		let dY = item.fixedY - fixedY
		return {
			x: item.elmX + dX,
			y: item.elmY + dY,
		}
	},

	/**
	 * @description: 记录按下数据
	 */
	recordPressDownData(item) {
		item.lastElmX = item.left; //记录按下x轴坐标
		item.lastElmY = item.top; //记录按下y轴坐标
		item.lastElmW = item.width; //记录按下宽度
		item.lastElmH = item.height; //记录按下高度
		item.lastInitialScale = item.initialScale; //记录按下比例
		item.lastInitialscaling = item.initialscaling; //记录按下比例
		item.lastImageLeft = item.image_left; //记录按下图片左距离
		item.lastImageTop = item.image_top; //记录按下图片上距离
		item.lastFontscale = item.fontscale; //记录按下字体比例
		item.lastFontSize = item.font_size; //记录按下字体大小
		item.lastLineheight = item.lineheight; //记录按下行高
		let rotate = Math.abs(item.angle) % 360 //计算角度
		if (item.angle < 0) {
			let multiple = Math.ceil(Math.abs(item.angle) / 360) //Math.ceil
			rotate = item.angle + multiple * 360
		}
		if (rotate == 360) {
			rotate = 0;
		}
		item.newRotate = rotate; //设置新旋转角度
		let fixed;
		if (item.typetext == "left-top") {
			fixed = {
				x: 'right',
				y: 'bottom'
			}
		} else if (item.typetext == "left-bottom" || item.typetext == "left") {
			fixed = {
				x: 'right',
				y: 'top'
			}
		} else if (item.typetext == "right-top" || item.typetext == "top") {
			fixed = {
				x: 'left',
				y: 'bottom'
			}
		} else if (item.typetext == "right-bottom" || item.typetext == "right" || item.typetext == "bottom") {
			fixed = {
				x: 'left',
				y: 'top'
			}
		}
		//记录对应坐标点坐标
		if (fixed != null) {
			//初始化盒子上下左右位置
			let rect = {
				top: item.top,
				right: item.left + item.width,
				bottom: item.top + item.height,
				left: item.left
			}
			let fixedCoordinate = this.rotatedPoint(rect, rotate, fixed)
			item.fixedX = fixedCoordinate.x //记录按下对角x轴坐标
			item.fixedY = fixedCoordinate.y //记录按下对角y轴坐标
		}
	},

	//计算旋转后坐标点
	rotatedPoint(rect, rotate, point) {
		let {
			top,
			right,
			bottom,
			left
		} = rect
		let rad = (Math.PI / 180) * rotate
		let cos = Math.cos(rad)
		let sin = Math.sin(rad)
		let originX = (right - left) / 2 + left
		let originY = (bottom - top) / 2 + top
		let x = rect[point.x]
		let y = rect[point.y]
		x -= originX
		y -= originY
		return {
			x: Math.floor((x * cos - y * sin + originX) * 10000) / 10000,
			y: Math.floor((x * sin + y * cos + originY) * 10000) / 10000,
		}
	},


	//四边伸缩
	edgeMove(e, item, data, allLineListData, designWidth, designHeight) {
		//修改属性状态
		item.active = true //辅助线
		item.activeguide = false //辅助线
		item.activescale = false // 旋转状态
		item.activehorn = false // 角状态
		item.activeedge = true // 边状态
		item.isShowLineV = false; //初始化默认不显示
		item.isShowLineH = false; //初始化默认不显示
		item.edgemoveX = e.touches[0].clientX; //手指移动后x轴位置
		item.edgemoveY = e.touches[0].clientY; //手指移动后y轴位置		
		let width = item.edgemoveX - item.edgestartX //计算手指移动x轴距离
		let height = item.edgemoveY - item.edgestartY //计算手指移动y轴距离
		let c = Math.sqrt(Math.pow(width, 2) + Math.pow(height, 2)) //使用三角公式计算边c长度
		let angle = this.getAngle(width, height) //计算移动位置角度差
		let rad = (Math.PI / 180) * (angle - item.newRotate) //旋转角度转换公式
		let diffY = (Math.sin(rad) * c) //计算角度差x轴
		let diffX = (Math.cos(rad) * c) //计算角度差y轴

		item.elmX = item.lastElmX
		item.elmY = item.lastElmY
		item.elmW = item.lastElmW
		item.elmH = item.lastElmH

		let fixed;
		if (item.typetext == "left") { //左
			fixed = {
				x: 'right',
				y: 'top'
			}
			item.elmW += diffX * (-1) //计算宽度
		} else if (item.typetext == "top") { //下
			fixed = {
				x: 'left',
				y: 'bottom'
			}
			item.elmH += diffY * (-1) //计算高度
		} else if (item.typetext == "right") { //右
			fixed = {
				x: 'left',
				y: 'top'
			}
			item.elmW += diffX * (1) //计算宽度
		} else if (item.typetext == "bottom") { //下
			fixed = {
				x: 'left',
				y: 'top'
			}
			item.elmH += diffY * (1) //计算高度
		}

		if (item.elmW < 20) {
			item.elmW = 20
		}
		if (item.elmH < 20) {
			item.elmH = 20
		}

		let getNewData = this.fixedTo(item, fixed, item.newRotate) //计算对角差距数据
		item.elmX = getNewData.x; //赋值x轴新数据
		item.elmY = getNewData.y; //赋值y轴新数据
		item.left = item.elmX; //重新赋值左上角x位置
		item.top = item.elmY; //重新赋值左上角y位置
		item.width = item.elmW //重新设置宽度
		item.height = item.elmH //重新设置高度

		let newScale = 1;
		if (item.typetext == "right") {
			let right = designWidth - (item.left + item.width);
			item.left = item.elmX; //重新赋值左上角x位置
			item.width = item.elmW //重新设置宽度
			newScale = item.elmW / item.lastElmW //计算新比例
			if (newScale > 1) { //开始放大处理
				let newWidthScale = Math.abs((item.elmW - item.lastElmW) / item.initialWidth);
				item.initialScale = item.lastInitialScale + newWidthScale //乘以对应之前比例
				item.initialscaling = item.lastInitialscaling + newWidthScale //乘以对应之前比例
			}

		} else if (item.typetext == "left") {
			newScale = item.elmW / item.lastElmW //计算新比例
			let distanceLeft = 0
			if (item.lastImageLeft > 0) {
				distanceLeft = 0;
			} else {
				distanceLeft = item.lastImageLeft + (item.elmW - item.lastElmW);
			}
			if (distanceLeft < 0) {
				item.image_left = distanceLeft;
			} else {
				item.image_left = 0;
				let newWidthScale = distanceLeft / item.initialWidth;
				item.initialScale = item.lastInitialScale + newWidthScale //乘以对应之前比例
				item.initialscaling = item.lastInitialscaling + newWidthScale //乘以对应之前比例
			}

		} else if (item.typetext == "top") {
			newScale = item.elmH / item.lastElmH //计算新比例
			let distanceTop = 0
			if (item.lastImageTop > 0) {
				distanceTop = 0;
			} else {
				distanceTop = item.lastImageTop + (item.elmH - item.lastElmH);
			}
			if (distanceTop < 0) {
				item.image_top = distanceTop;
			} else {
				item.image_top = 0;
				let newHeightScale = distanceTop / item.initialHeight;
				item.initialScale = item.lastInitialScale + newHeightScale //乘以对应之前比例
				item.initialscaling = item.lastInitialscaling + newHeightScale //乘以对应之前比例
			}

		} else if (item.typetext == "bottom") {
			let buttom = designHeight - (item.top + item.height);
			newScale = item.elmH / item.lastElmH //计算新比例
			if (newScale > 1) { //开始放大处理
				let newHeightScale = Math.abs((item.elmH - item.lastElmH) / item.initialHeight);
				item.initialScale = item.lastInitialScale + newHeightScale //乘以对应之前比例
				item.initialscaling = item.lastInitialscaling + newHeightScale //乘以对应之前比例
			}
		}
		item.left = item.elmX; //重新赋值左上角x位置
		item.top = item.elmY; //重新赋值左上角y位置
		item.left = item.elmX; //重新赋值左上角x位置
		item.top = item.elmY; //重新赋值左上角y位置
		item.width = item.elmW //重新设置宽度
		item.height = item.elmH //重新设置高度

		//记录中心位置
		item.centerPos = {
			x: item.left + item.width / 2,
			y: item.top + item.height / 2
		}

		item.x = item.centerPos.x;
		item.y = item.centerPos.y;

		//计算圆角
		this.getConterScale(item)
	},


	/**
	 * @description: 初始化targetObj的位置
	 */
	initPos(item) {
		if (item == null) {
			return
		}
		item.centerPos = {
			x: item.left + item.width / 2,
			y: item.top + item.height / 2
		}
		item.x = item.centerPos.x;
		item.y = item.centerPos.y;
		item.scaleone = item.width / item.height
		item.initCenterPos = item.centerPos
	},

	/**
	 * @description: 计算移动前坐标值
	 */
	getRotatedPoint(curPos, centerPos, angle) {
		let radian = Math.PI / 180 * angle;
		return {
			x: Math.floor((curPos.x - centerPos.x) * Math.cos(radian) - (curPos.y - centerPos.y) * Math.sin(radian) + centerPos.x),
			y: Math.floor((curPos.y - centerPos.y) * Math.cos(radian) + (curPos.x - centerPos.x) * Math.sin(radian) + centerPos.y)
		}
	},

	/**
	 * @description: 计算变换后的方框四个角的位置
	 */
	getTransferPosition(left, top, width, height, angle, center, item) {
		item.centerPos = {
			x: item.left + item.width / 2,
			y: item.top + item.height / 2
		}
		item.x = item.centerPos.x;
		item.y = item.centerPos.y;
	},

	/**
	 * 计算触摸点到圆心的距离
	 * @param centerX   圆心的 x 坐标
	 * @param centerY   圆心的 y 坐标
	 * @param x         手点击的 x 坐标
	 * @param y         手点击的 y 坐标
	 * @returns {number}
	 */
	computeDistance: function(centerX, centerY, x, y) {
		var diffX = x - centerX;
		var diffY = y - centerY;
		return Math.sqrt(diffX * diffX + diffY * diffY);
	},

	/**
	 * @description: 初始化targetObj的位置
	 */
	initPosscale(item) {
		item.fontscale = item.fontscale * item.scale
		item.font_size = item.font_size * item.scale
		item.lineheight = item.lineheight * item.scale
		item.left = item.left - (item.width * item.scale - item.width) / 2
		item.top = item.top - (item.height * item.scale - item.height) / 2
		item.width = item.width * item.scale
		item.height = item.height * item.scale
		item.initialWidth = item.initialWidth * item.scale
		item.initialHeight = item.initialHeight * item.scale
		item.image_top = item.image_top * item.scale
		item.image_left = item.image_left * item.scale
		//记录中心位置
		item.centerPos = {
			x: item.left + item.width / 2,
			y: item.top + item.height / 2
		}
		item.scaleone = item.width / item.height
		item.initCenterPos = item.centerPos
	},

	/**
	 * @description: 计算变换后的方框四个角的位置
	 */
	getTransferPositionangle(left, top, width, height, angle, center, item) {

	},

	/**
	 * 自创建新数据
	 */
	getNewDataInfo(item) {

		//记录中心位置
		item.centerPos = {
			x: item.left + item.width / 2,
			y: item.top + item.height / 2
		}

		item.x = item.centerPos.x;
		item.y = item.centerPos.y;

		item.startX = item.x;
		item.startY = item.y;

		let moveXDistance = item.startX + 0.01;
		let moveYDistance = item.startY + 0.01;

		item.moveX = moveXDistance;
		item.moveY = moveYDistance;

		//追加改动值
		item.left += item.moveX - item.startX; // x方向
		item.top += item.moveY - item.startY; // y方向

		item.x = item.left + item.width / 2;
		item.y = item.top + item.height / 2;

		item.xheart = item.left + (item.width) / 2 // 方块圆心
		item.yheart = item.top + (item.height) / 2 // 方块圆心
		item.heart_startX = moveXDistance; // 用于恢复startX数据
		item.heart_startY = moveYDistance; // 用于恢复startY数据

		let roat = Math.abs(item.angle) % 360
		if (item.angle < 0) {
			let multiple = Math.ceil(Math.abs(item.angle) / 360)
			roat = item.angle + multiple * 360
		}
		this.initPos(item)
	},


	/**
	 * 断是否吸取功能数据 
	 * item  选中对象
	 * allLineListData 所有数据集合
	 */
	getIshasDrawData(item, allLineListData) {
		//初始化选中对象左上角坐标位置
		var pos = {
			left: item.left,
			top: item.top
		};
		//初始化选中坐标数据
		var chosenGuides = {
			top: {
				dist: 5,
			},
			left: {
				dist: 5,
			}
		};
		//查询出来选择item坐标数据
		let selectLineListData = this.addallLineListDataXAndY(item)
		//循环对比坐标点寻找位置
		if (allLineListData != null && allLineListData.length > 0 && selectLineListData != null &&
			selectLineListData.length > 0) {
			allLineListData.forEach((guide, i) => {
				selectLineListData.forEach((elemGuide, i) => {
					if (guide.type == elemGuide.type) {
						var prop = guide.type == "h" ? "top" : "left";
						var d = Math.abs(elemGuide[prop] - guide[prop]);
						if (d < chosenGuides[prop].dist) {
							chosenGuides[prop].dist = d;
							chosenGuides[prop].offset = elemGuide[prop] - pos[prop];
							chosenGuides[prop].guide = guide;
						}
					}
				});
			});
		}
		return chosenGuides;
	},


	/**
	 * 图片拖动中事件
	 */
	dragMove(e, item, data, editor_top) {
		item.isShowLineV = false;
		item.isShowLineH = false;
		let mouseX = e.touches[0].clientX;
		let mouseY = e.touches[0].clientY;
		item.elmX = item.lastElmX
		item.elmY = item.lastElmY
		item.elmW = item.lastElmW
		item.elmH = item.lastElmH
		let diffX = mouseX - item.startX
		let diffY = mouseY - item.startY
		let dX = diffX
		let dY = diffY
		item.elmX += diffX
		item.elmY += diffY
		item.left = item.elmX
		item.top = item.elmY
		if (item.newRotate == 0) {
			if (item.left > (data.editorWidth / 2 - 5) && item.left < (data.editorWidth / 2 + 5)) {
				/* 辅助线左侧磁性吸附 */
				item.elmX = data.editorWidth / 2
			} else if (item.left > (data.editorWidth / 2 - item.width - 5) && item.left < (data.editorWidth / 2 - item.width + 5)) {
				/* 辅助线右侧磁性吸附 */
				item.elmX = data.editorWidth / 2 - item.width
			} else if (item.left > -5 && item.left < 5) {
				//裁剪区左边框磁性吸附
				item.elmX = 0
			} else if (item.left > data.editorWidth - item.width - 5 && item.left < data.editorWidth - item.width + 5) {
				// 裁剪区右边框磁性吸附
				item.elmX = data.editorWidth - item.width
			} else if (item.left > ((data.editorWidth - item.width) / 2 - 5) && item.left < ((data.editorWidth - item.width) / 2 + 5)) {
				/* 辅助线居中磁性吸附 */
				item.elmX = (data.editorWidth - item.width) / 2
				//wx.vibrateShort();
			}
		}

		if (item.newRotate == 0) {
			if (item.top > (editor_top - item.height - 5) && item.top < (editor_top - item.height + 5)) {
				/*辅助线下边框磁性吸附 */
				item.elmY = editor_top - item.height
			} else if (item.top > -5 && item.top < 5) {
				//裁剪区上边框磁性吸附
				item.elmY = 0
			} else if (item.top > data.editorHeight - item.height - 5 && item.top < data.editorHeight - item.height + 5) {
				//裁剪区下边框磁性吸附
				item.elmY = data.editorHeight - item.height
			} else if (item.top > (editor_top - (item.height / 2) - 5) && item.top < (editor_top - (item.height / 2) + 5)) {
				/*辅助线居中磁性吸附 */
				item.elmY = editor_top - (item.height / 2)
				//wx.vibrateShort();
			}
		}

		item.left = item.elmX
		item.top = item.elmY

		//记录中心位置
		item.centerPos = {
			x: item.left + item.width / 2,
			y: item.top + item.height / 2
		}
		item.x = item.centerPos.x;
		item.y = item.centerPos.y;
	},


	//添加所有参考线x轴y轴
	addallLineListDataXAndY(item) {
		if (item.angle != 0) {
			var center = {
				x: item.left + (item.width) / 2,
				y: item.top + (item.height) / 2
			};
			var topLeft = {
				x: item.left,
				y: item.top
			};
			var topRight = {
				x: item.left + item.width,
				y: item.top
			};
			var bottomleft = {
				x: item.left,
				y: item.top + item.height
			};
			var bottomRight = {
				x: item.left + item.width,
				y: item.top + item.height
			};
			var point1 = this.calNewPos(topLeft, center, item.angle);
			var point2 = this.calNewPos(topRight, center, item.angle);
			var point3 = this.calNewPos(bottomleft, center, item.angle);
			var point4 = this.calNewPos(bottomRight, center, item.angle);
			return [{
					type: "h",
					left: point1.x,
					top: point1.y
				}, {
					type: "h",
					left: point2.x,
					top: point2.y
				}, {
					type: "h",
					left: point3.x,
					top: point3.y
				}, {
					type: "h",
					left: point4.x,
					top: point4.y
				},
				{
					type: "v",
					left: point1.x,
					top: point1.y
				},
				{
					type: "v",
					left: point2.x,
					top: point2.y
				},
				{
					type: "v",
					left: point3.x,
					top: point3.y
				},
				{
					type: "v",
					left: point4.x,
					top: point4.y
				},
			];
		} else {
			return [{
					type: "h",
					left: item.left,
					top: item.top
				},
				{
					type: "h",
					left: item.left,
					top: item.top + item.height
				},
				{
					type: "v",
					left: item.left,
					top: item.top
				},
				{
					type: "v",
					left: item.left + item.width,
					top: item.top
				},
				{
					type: "h",
					left: item.left,
					top: item.top + (item.height) / 2
				},
				{
					type: "v",
					left: item.left + (item.width) / 2,
					top: item.top
				}
			]
		}
	},

	/* 通过旧坐标、旋转角度、圆心计算旋转后点的新坐标 */
	calNewPos(origin, center, angle) {
		// 计算
		let radian = Math.PI / 180 * angle;
		let newX = (origin.x - center.x) * Math.cos(radian) - (origin.y - center.y) *
			Math.sin(radian) + center.x;
		let newY = (origin.y - center.y) * Math.cos(radian) + (origin.x - center.x) *
			Math.sin(radian) + center.y;
		// 取10位小数
		newX = newX.toFixed(4)
		newY = newY.toFixed(4)
		return {
			x: newX,
			y: newY
		};
	},

	/**
	 * 拖动修改x轴y轴坐标中事件
	 */
	dragMoveUpdateXAndY(clientX, clientY, item) {
		let moveXDistance = item.startX + clientX;
		let moveYDistance = item.startY + clientY;

		item.moveX = moveXDistance; //移动x轴位置
		item.moveY = moveYDistance; //移动y轴位置

		item.left += item.moveX - item.startX; // x方向
		item.top += item.moveY - item.startY; // y方向
		item.x += item.moveX - item.startX; // 方块圆心
		item.y += item.moveY - item.startY; // 方块圆心

		// 磁性吸附部分
		item.xheart = item.left + (item.width) / 2 // 方块圆心
		item.yheart = item.top + (item.height) / 2 // 方块圆心
		item.heart_startX = moveXDistance; // 用于恢复startX数据
		item.heart_startY = moveYDistance; // 用于恢复startY数据

		this.initPos(item)

		item.startX = moveXDistance;
		item.startY = moveYDistance;

		// 恢复
		if (item.heart_startX != undefined) {
			item.startX = item.heart_startX;
			item.startY = item.heart_startY;
		}
		if (item.xheart != undefined) {
			item.x = item.xheart
			item.y = item.yheart
		}
	},

	//计算圆角缩放比例
	getConterScale(item) {
		let scale = 0;
		if (item.isFillet) {
			let imageWid = item.width
			let imageHei = item.height
			if (imageHei > imageWid) {
				scale = imageHei / 2;
			} else {
				scale = imageWid / 2;
			}
		}
		item.conterScale = scale;
	},

}

export default drag
