Skip to content

Commit

Permalink
[feature] touch
Browse files Browse the repository at this point in the history
  • Loading branch information
WindLX committed Dec 10, 2023
1 parent cf55fd6 commit b40a1cb
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 5 deletions.
Binary file modified libmd_net.so
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "pap",
"private": true,
"version": "0.2.3",
"version": "0.2.4",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
9 changes: 8 additions & 1 deletion src/components/Markdown/MdBlock.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ function handleEdit() {
}
}
function handleTouchEdit(event: TouchEvent) {
if (!lock?.value && event.touches.length == 2) {
isEdit.value = true;
handleFocus();
}
}
function behaviorHandler(e: KeyboardEvent) {
const selection = window.getSelection();
const focusOffset = selection?.focusOffset;
Expand Down Expand Up @@ -242,7 +249,7 @@ onMounted(async () => {

<template>
<div v-if="block" class="md-block" :class="{ 'highlight': props.isHighlight }" @dblclick="handleEdit()"
:id="`md-block-${props.lineNum}`">
@touchstart="handleTouchEdit" :id="`md-block-${props.lineNum}`">
<span v-show="isEdit || props.isHighlight" class="line-num" :class="{ 'focus-num': isEdit }">
{{ props.lineNum }}
</span>
Expand Down
5 changes: 5 additions & 0 deletions src/components/Markdown/MdTip.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<script setup lang="ts"></script>

<template></template>

<style scoped></style>
12 changes: 9 additions & 3 deletions src/components/Net/NetNode.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ function handleClick() {
}
}
function handleTouchClick(event: TouchEvent) {
isDragging.value = true;
if (event.touches.length === 2 && props.isMd) {
emits('click')
}
}
watchEffect(() => {
pos.x = props.pos.x
pos.y = props.pos.y
Expand All @@ -66,9 +73,8 @@ watchEffect(() => {

<template>
<g @dblclick="handleClick" @click="isShowText = !isShowText" class="node" @mousedown="isDragging = true"
@mousemove="handleDrag" @mouseup="isDragging = false" @mouseover="isDragging = false"
@touchstart="isDragging = true" @touchmove="handleTouchDrag" @touchend="isDragging = false"
@touchcancel="isDragging = false">
@mousemove="handleDrag" @mouseup="isDragging = false" @mouseover="isDragging = false" @touchstart="handleTouchClick"
@touchmove="handleTouchDrag" @touchend="isDragging = false" @touchcancel="isDragging = false">
<circle :cx="pos.x" :cy="pos.y" :r="radius" :fill="color" />
<Transition name="fade">
<text v-show="isShowText" :x="pos.x" :y="pos.y" alignment-baseline="middle" text-anchor="middle" fill="#fff"
Expand Down

0 comments on commit b40a1cb

Please sign in to comment.