@libraz/mejiro-react 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +9 -4
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -80,6 +80,7 @@ function MejiroPageView({
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
// src/useImageOverlay.ts
|
|
83
|
+
import { moveImageOverlayRect, resizeImageOverlayRect } from "@libraz/mejiro";
|
|
83
84
|
import { useCallback, useRef, useState } from "react";
|
|
84
85
|
function useImageOverlay(layout, spreadIdx, onUpdate, options) {
|
|
85
86
|
const defW = options?.defaultWidth ?? 120;
|
|
@@ -119,9 +120,11 @@ function useImageOverlay(layout, spreadIdx, onUpdate, options) {
|
|
|
119
120
|
const onOverlayPointerDown = useCallback(
|
|
120
121
|
(e) => {
|
|
121
122
|
e.preventDefault();
|
|
123
|
+
const current = rectRef.current;
|
|
124
|
+
if (!current) return;
|
|
122
125
|
const startX = e.clientX;
|
|
123
126
|
const startY = e.clientY;
|
|
124
|
-
const start = { ...
|
|
127
|
+
const start = { ...current };
|
|
125
128
|
const target = e.currentTarget;
|
|
126
129
|
target.setPointerCapture(e.nativeEvent.pointerId);
|
|
127
130
|
target.classList.add("dragging");
|
|
@@ -129,7 +132,7 @@ function useImageOverlay(layout, spreadIdx, onUpdate, options) {
|
|
|
129
132
|
const onMove = (me) => {
|
|
130
133
|
const dx = me.clientX - startX;
|
|
131
134
|
const dy = me.clientY - startY;
|
|
132
|
-
const r =
|
|
135
|
+
const r = moveImageOverlayRect(start, dx, dy);
|
|
133
136
|
cancelAnimationFrame(rafId);
|
|
134
137
|
rafId = requestAnimationFrame(() => {
|
|
135
138
|
setImageRect(r);
|
|
@@ -150,9 +153,11 @@ function useImageOverlay(layout, spreadIdx, onUpdate, options) {
|
|
|
150
153
|
(e) => {
|
|
151
154
|
e.preventDefault();
|
|
152
155
|
e.stopPropagation();
|
|
156
|
+
const current = rectRef.current;
|
|
157
|
+
if (!current) return;
|
|
153
158
|
const startX = e.clientX;
|
|
154
159
|
const startY = e.clientY;
|
|
155
|
-
const start = { ...
|
|
160
|
+
const start = { ...current };
|
|
156
161
|
const target = e.currentTarget;
|
|
157
162
|
target.setPointerCapture(e.nativeEvent.pointerId);
|
|
158
163
|
target.parentElement?.classList.add("dragging");
|
|
@@ -160,7 +165,7 @@ function useImageOverlay(layout, spreadIdx, onUpdate, options) {
|
|
|
160
165
|
const onMove = (me) => {
|
|
161
166
|
const dx = me.clientX - startX;
|
|
162
167
|
const dy = me.clientY - startY;
|
|
163
|
-
const r =
|
|
168
|
+
const r = resizeImageOverlayRect(start, dx, dy);
|
|
164
169
|
cancelAnimationFrame(rafId);
|
|
165
170
|
rafId = requestAnimationFrame(() => {
|
|
166
171
|
setImageRect(r);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libraz/mejiro-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "React components for mejiro vertical text rendering",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"build": "tsup"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@libraz/mejiro": "^0.
|
|
32
|
+
"@libraz/mejiro": "^0.4.0"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"react": ">=18"
|