|
@@ -23,6 +23,10 @@
|
|
|
|
|
|
<script>
|
|
|
let dragging = false;
|
|
|
+let dragData = {
|
|
|
+ left:"",
|
|
|
+ top: "",
|
|
|
+};
|
|
|
import throttle from "@/utils/throttle";
|
|
|
export default {
|
|
|
data() {
|
|
@@ -49,24 +53,25 @@ export default {
|
|
|
//在vue自定义指令中添加该指令
|
|
|
directives: {
|
|
|
move(el) {
|
|
|
- // 根据不同参数默认展示不同区域
|
|
|
- const url = window.location.href;
|
|
|
- let params = {};
|
|
|
- const reg = /[?&]+([^=&]+)=([^&]*)/gi;
|
|
|
- let match;
|
|
|
-
|
|
|
- while ((match = reg.exec(url)) !== null) {
|
|
|
- const key = match[1];
|
|
|
- const value = decodeURIComponent(match[2]);
|
|
|
- params[key] = value;
|
|
|
- }
|
|
|
- if(params.id === 'PAN'){
|
|
|
- el.style.left = "0px";
|
|
|
- el.style.top = "-538px";
|
|
|
- }else{
|
|
|
- el.style.left = "0px";
|
|
|
- el.style.top = "0px";
|
|
|
+
|
|
|
+ setTimeout(() => {
|
|
|
+ // 图片缩小时图片位置问题
|
|
|
+ let imgHeight = el.children[0].children[0].offsetHeight;
|
|
|
+ if(imgHeight < -dragData.top *1.5){ // 当位置小于图片高度时,表示图片被缩放到了屏幕外
|
|
|
+ el.style.top = "20%";
|
|
|
+ el.style.left = "50%";
|
|
|
}
|
|
|
+ console.log("666",el);
|
|
|
+ }, 500);
|
|
|
+
|
|
|
+ // 防止放大缩小时图片位置问题
|
|
|
+ if(dragData.left != "" || dragData.top != ""){
|
|
|
+ el.style.left = dragData.left + "px";
|
|
|
+ el.style.top = dragData.top + "px";
|
|
|
+ }else{
|
|
|
+ el.style.left = "50%";
|
|
|
+ el.style.top = "90px";
|
|
|
+ }
|
|
|
//鼠标拖拽功能
|
|
|
el.onmousedown = function (e) {
|
|
|
// 阻止点击事件冒泡
|
|
@@ -82,8 +87,17 @@ export default {
|
|
|
let event = ev || window.event;
|
|
|
let moveX = event.clientX - startX,
|
|
|
moveY = event.clientY - startY;
|
|
|
- el.style.left = moveX + "px";
|
|
|
- el.style.top = moveY + "px";
|
|
|
+ // el.style.left = moveX + "px";
|
|
|
+ // el.style.top = moveY + "px";
|
|
|
+ if(dragData.left != "" || dragData.top != ""){
|
|
|
+ el.style.left = dragData.left + "px";
|
|
|
+ el.style.top = dragData.top + "px";
|
|
|
+ }else{
|
|
|
+ el.style.left = moveX + "px";
|
|
|
+ el.style.top = moveY + "px";
|
|
|
+ }
|
|
|
+ dragData.left = moveX;
|
|
|
+ dragData.top = moveY;
|
|
|
}),
|
|
|
500
|
|
|
);
|
|
@@ -93,6 +107,12 @@ export default {
|
|
|
dragging = true;
|
|
|
document.onmousemove = null;
|
|
|
};
|
|
|
+ console.log(dragData)
|
|
|
+ // 解决放大缩小时图片位置问题
|
|
|
+ if(dragData.left != "" || dragData.top != ""){
|
|
|
+ el.style.left = dragData.left + "px";
|
|
|
+ el.style.top = dragData.top + "px";
|
|
|
+ }
|
|
|
};
|
|
|
},
|
|
|
},
|
|
@@ -173,6 +193,7 @@ body{
|
|
|
left: "calc(100% - 1300px)";
|
|
|
bottom: "calc(100% - 500px)";
|
|
|
z-index: 99;
|
|
|
+ transform: translate(-50%, 0);
|
|
|
}
|
|
|
|
|
|
|