|
@@ -36,17 +36,8 @@
|
|
<!-- <img src="@/assets/images/wakeup/ai-rabit.png" />-->
|
|
<!-- <img src="@/assets/images/wakeup/ai-rabit.png" />-->
|
|
<!-- </div>-->
|
|
<!-- </div>-->
|
|
<!-- </div>-->
|
|
<!-- </div>-->
|
|
- <div class="container">
|
|
|
|
- <div
|
|
|
|
- class="draggable"
|
|
|
|
- draggable="true"
|
|
|
|
- @dragstart="dragStart"
|
|
|
|
- @dragover.prevent
|
|
|
|
- @drop="drop"
|
|
|
|
- >
|
|
|
|
- 拖拽我
|
|
|
|
- </div>
|
|
|
|
- </div>
|
|
|
|
|
|
+<!-- <div id="draggable" style="width: 100px; height: 100px; background-color: red; position: absolute; top: 0; left: 0;">Drag me!</div>-->
|
|
|
|
+ <div id="draggable" style="width: 100px; height: 100px; background-color: red; position: absolute;">拖拽我</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
@@ -101,58 +92,32 @@
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // onMounted(() => {
|
|
|
|
+ //
|
|
|
|
+ // })
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
- setHeadinfo()
|
|
|
|
- })
|
|
|
|
-
|
|
|
|
- import { reactive, onMounted } from 'vue';
|
|
|
|
-
|
|
|
|
- const position = reactive({ x: 100, y: 10 });
|
|
|
|
- let isDragging = false;
|
|
|
|
- let originX, originY;
|
|
|
|
-
|
|
|
|
- const startDrag = (e) => {
|
|
|
|
- console.log("e",e);
|
|
|
|
- // let chartDiv = document.getElementById("ring-chart");
|
|
|
|
-
|
|
|
|
- isDragging = true;
|
|
|
|
- originX = e.clientX - position.x;
|
|
|
|
- originY = e.clientY - position.y;
|
|
|
|
- document.addEventListener('touchmove', onMouseMove);
|
|
|
|
- document.addEventListener('touchend', stopDrag);
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- const onMouseMove = (e) => {
|
|
|
|
- if (isDragging) {
|
|
|
|
- position.x = e.clientX - originX;
|
|
|
|
- position.y = e.clientY - originY;
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- const stopDrag = () => {
|
|
|
|
- isDragging = false;
|
|
|
|
- document.removeEventListener('touchmove', onMouseMove);
|
|
|
|
- document.removeEventListener('touchend', stopDrag);
|
|
|
|
- };
|
|
|
|
- const draggableBox = ref(null);
|
|
|
|
- let startX = 0;
|
|
|
|
- let startY = 0;
|
|
|
|
- let currentX = 0;
|
|
|
|
- let currentY = 0;
|
|
|
|
- const handleTouchStart = (event) => {
|
|
|
|
- startX = event.touches[0].clientX - draggableBox.value.offsetLeft;
|
|
|
|
- startY = event.touches[0].clientY - draggableBox.value.offsetTop;
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- const handleTouchMove = (event) => {
|
|
|
|
- currentX = event.touches[0].clientX - startX;
|
|
|
|
- currentY = event.touches[0].clientY - startY;
|
|
|
|
- draggableBox.value.style.transform = `translate3D(${currentX}px, ${currentY}px, 0)`;
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- const handleTouchEnd = () => {
|
|
|
|
- // 可以添加触摸结束后的处理逻辑,比如设置一个最终的拖拽位置等
|
|
|
|
- };
|
|
|
|
|
|
+ setHeadinfo()
|
|
|
|
+ // let startPosX, startPosY, startTouchX, startTouchY;
|
|
|
|
+ //
|
|
|
|
+ // $('#draggable').on('touchstart', function(e) {
|
|
|
|
+ // startPosX = $(this).position().left;
|
|
|
|
+ // startPosY = $(this).position().top;
|
|
|
|
+ // startTouchX = e.originalEvent.touches[0].pageX;
|
|
|
|
+ // startTouchY = e.originalEvent.touches[0].pageY;
|
|
|
|
+ // });
|
|
|
|
+ //
|
|
|
|
+ // $('#draggable').on('touchmove', function(e) {
|
|
|
|
+ // e.preventDefault(); // 阻止默认的滚动行为
|
|
|
|
+ // const touchX = e.originalEvent.touches[0].pageX;
|
|
|
|
+ // const touchY = e.originalEvent.touches[0].pageY;
|
|
|
|
+ // const deltaX = touchX - startTouchX;
|
|
|
|
+ // const deltaY = touchY - startTouchY;
|
|
|
|
+ // $(this).css({
|
|
|
|
+ // left: startPosX + deltaX,
|
|
|
|
+ // top: startPosY + deltaY,
|
|
|
|
+ // });
|
|
|
|
+ // });
|
|
|
|
+ });
|
|
</script>
|
|
</script>
|
|
|
|
|
|
|
|
|