@tbib-image-viewer/react 0.1.5 → 0.1.6
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.css +74 -33
- package/dist/index.css.map +1 -1
- package/dist/index.js +19 -23
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +19 -23
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -265,50 +265,48 @@ var ImageToolbar = ({
|
|
|
265
265
|
totalImages
|
|
266
266
|
}) => {
|
|
267
267
|
const showSubtoolbar = activeTool === "pen" || activeTool === "highlighter" || activeTool === "laser";
|
|
268
|
-
const
|
|
269
|
-
const
|
|
268
|
+
const toolbarScrollRef = React2.useRef(null);
|
|
269
|
+
const subtoolbarScrollRef = React2.useRef(null);
|
|
270
270
|
const toolbarTouchState = React2.useRef({ isDown: false, startX: 0, scrollLeft: 0 });
|
|
271
271
|
const subtoolbarTouchState = React2.useRef({ isDown: false, startX: 0, scrollLeft: 0 });
|
|
272
272
|
const handleToolbarTouchStart = (e) => {
|
|
273
|
-
if (!
|
|
273
|
+
if (!toolbarScrollRef.current) return;
|
|
274
274
|
toolbarTouchState.current = {
|
|
275
275
|
isDown: true,
|
|
276
276
|
startX: e.touches[0].clientX,
|
|
277
|
-
scrollLeft:
|
|
277
|
+
scrollLeft: toolbarScrollRef.current.scrollLeft
|
|
278
278
|
};
|
|
279
279
|
};
|
|
280
280
|
const handleToolbarTouchMove = (e) => {
|
|
281
|
-
if (!toolbarTouchState.current.isDown || !
|
|
281
|
+
if (!toolbarTouchState.current.isDown || !toolbarScrollRef.current) return;
|
|
282
282
|
const dx = e.touches[0].clientX - toolbarTouchState.current.startX;
|
|
283
|
-
|
|
283
|
+
toolbarScrollRef.current.scrollLeft = toolbarTouchState.current.scrollLeft - dx;
|
|
284
284
|
};
|
|
285
285
|
const handleToolbarTouchEnd = () => {
|
|
286
286
|
toolbarTouchState.current.isDown = false;
|
|
287
287
|
};
|
|
288
288
|
const handleSubtoolbarTouchStart = (e) => {
|
|
289
|
-
if (!
|
|
289
|
+
if (!subtoolbarScrollRef.current) return;
|
|
290
290
|
subtoolbarTouchState.current = {
|
|
291
291
|
isDown: true,
|
|
292
292
|
startX: e.touches[0].clientX,
|
|
293
|
-
scrollLeft:
|
|
293
|
+
scrollLeft: subtoolbarScrollRef.current.scrollLeft
|
|
294
294
|
};
|
|
295
295
|
};
|
|
296
296
|
const handleSubtoolbarTouchMove = (e) => {
|
|
297
|
-
if (!subtoolbarTouchState.current.isDown || !
|
|
297
|
+
if (!subtoolbarTouchState.current.isDown || !subtoolbarScrollRef.current) return;
|
|
298
298
|
const dx = e.touches[0].clientX - subtoolbarTouchState.current.startX;
|
|
299
|
-
|
|
299
|
+
subtoolbarScrollRef.current.scrollLeft = subtoolbarTouchState.current.scrollLeft - dx;
|
|
300
300
|
};
|
|
301
301
|
const handleSubtoolbarTouchEnd = () => {
|
|
302
302
|
subtoolbarTouchState.current.isDown = false;
|
|
303
303
|
};
|
|
304
304
|
return /* @__PURE__ */ jsxs2("div", { className: "tbib-iv-toolbar-wrapper", children: [
|
|
305
|
-
/* @__PURE__ */ jsxs2(
|
|
306
|
-
"
|
|
305
|
+
/* @__PURE__ */ jsx2("header", { className: "tbib-iv-toolbar", role: "toolbar", "aria-label": "Image tools", children: /* @__PURE__ */ jsxs2(
|
|
306
|
+
"div",
|
|
307
307
|
{
|
|
308
|
-
ref:
|
|
309
|
-
className: "tbib-iv-toolbar",
|
|
310
|
-
role: "toolbar",
|
|
311
|
-
"aria-label": "Image tools",
|
|
308
|
+
ref: toolbarScrollRef,
|
|
309
|
+
className: "tbib-iv-toolbar-scroll",
|
|
312
310
|
onTouchStart: handleToolbarTouchStart,
|
|
313
311
|
onTouchMove: handleToolbarTouchMove,
|
|
314
312
|
onTouchEnd: handleToolbarTouchEnd,
|
|
@@ -498,14 +496,12 @@ var ImageToolbar = ({
|
|
|
498
496
|
] })
|
|
499
497
|
]
|
|
500
498
|
}
|
|
501
|
-
),
|
|
502
|
-
showSubtoolbar && /* @__PURE__ */ jsxs2(
|
|
499
|
+
) }),
|
|
500
|
+
showSubtoolbar && /* @__PURE__ */ jsx2("div", { className: "tbib-iv-subtoolbar", role: "region", "aria-label": "Tool customization", children: /* @__PURE__ */ jsxs2(
|
|
503
501
|
"div",
|
|
504
502
|
{
|
|
505
|
-
ref:
|
|
506
|
-
className: "tbib-iv-subtoolbar",
|
|
507
|
-
role: "region",
|
|
508
|
-
"aria-label": "Tool customization",
|
|
503
|
+
ref: subtoolbarScrollRef,
|
|
504
|
+
className: "tbib-iv-subtoolbar-scroll",
|
|
509
505
|
onTouchStart: handleSubtoolbarTouchStart,
|
|
510
506
|
onTouchMove: handleSubtoolbarTouchMove,
|
|
511
507
|
onTouchEnd: handleSubtoolbarTouchEnd,
|
|
@@ -569,7 +565,7 @@ var ImageToolbar = ({
|
|
|
569
565
|
] })
|
|
570
566
|
]
|
|
571
567
|
}
|
|
572
|
-
)
|
|
568
|
+
) })
|
|
573
569
|
] });
|
|
574
570
|
};
|
|
575
571
|
|