@papyrus-sdk/ui-react-native 0.2.16 → 0.2.17

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 CHANGED
@@ -21293,6 +21293,24 @@ var resolveClampedScrollOffset = (offset, contentLength, viewportLength) => {
21293
21293
  Math.max(0, safeContentLength - safeViewportLength)
21294
21294
  );
21295
21295
  };
21296
+ var resolveDocumentSurfaceWidth = ({
21297
+ viewportWidth,
21298
+ contentWidth,
21299
+ horizontalPadding
21300
+ }) => {
21301
+ const safeViewportWidth = Number.isFinite(viewportWidth) && viewportWidth > 0 ? viewportWidth : 0;
21302
+ const safeContentWidth = Number.isFinite(contentWidth) && contentWidth > 0 ? contentWidth : 0;
21303
+ const safeHorizontalPadding = Number.isFinite(horizontalPadding) && horizontalPadding > 0 ? horizontalPadding : 0;
21304
+ return Math.max(
21305
+ safeViewportWidth,
21306
+ safeContentWidth + safeHorizontalPadding * 2
21307
+ );
21308
+ };
21309
+ var resolveGlobalHorizontalOffset = ({
21310
+ offsetX,
21311
+ surfaceWidth,
21312
+ viewportWidth
21313
+ }) => resolveClampedScrollOffset(offsetX, surfaceWidth, viewportWidth);
21296
21314
  var shouldSuppressPressAfterPinch = (lastPinchEndedAt, now = Date.now(), windowMs = PINCH_PRESS_SUPPRESSION_MS) => {
21297
21315
  if (typeof lastPinchEndedAt !== "number") return false;
21298
21316
  const elapsedMs = now - lastPinchEndedAt;
@@ -21437,8 +21455,6 @@ var buildSquigglyPath = (segments = 16) => {
21437
21455
  return path;
21438
21456
  };
21439
21457
  var SQUIGGLY_PATH = buildSquigglyPath();
21440
- var SELECTION_EDGE_THRESHOLD_PX = 48;
21441
- var SELECTION_EDGE_MAX_STEP_PX = 24;
21442
21458
  var SELECTION_AUTOSCROLL_INTERVAL_MS = 16;
21443
21459
  var PageRenderer = ({
21444
21460
  engine,
@@ -21447,17 +21463,15 @@ var PageRenderer = ({
21447
21463
  pageAspectRatio,
21448
21464
  PageViewComponent = import_engine_native.PapyrusPageView,
21449
21465
  availableWidth,
21466
+ pageViewportWidth: providedPageViewportWidth,
21450
21467
  horizontalPadding = 16,
21451
21468
  spacing = 24,
21452
21469
  onSelectionDragActiveChange,
21453
21470
  gestureScrollLockActive = false,
21454
21471
  lastPinchEndedAt = null,
21455
- onHorizontalScrollOffsetChange,
21456
- horizontalScrollRestore = null,
21457
21472
  requestSelectionVerticalAutoscroll
21458
21473
  }) => {
21459
21474
  const viewRef = (0, import_react.useRef)(null);
21460
- const pageScrollRef = (0, import_react.useRef)(null);
21461
21475
  const [layout, setLayout] = (0, import_react.useState)({ width: 0, height: 0 });
21462
21476
  const [pageSize, setPageSize] = (0, import_react.useState)(null);
21463
21477
  const { width: windowWidth } = (0, import_react_native.useWindowDimensions)();
@@ -21465,10 +21479,8 @@ var PageRenderer = ({
21465
21479
  const perfEnabled = isMobilePerfEnabled();
21466
21480
  const renderCountRef = (0, import_react.useRef)(0);
21467
21481
  const inkDrawingActiveRef = (0, import_react.useRef)(false);
21468
- const horizontalScrollOffsetRef = (0, import_react.useRef)(0);
21469
21482
  const selectionDragActiveRef = (0, import_react.useRef)(false);
21470
21483
  const selectionDragPointRef = (0, import_react.useRef)(null);
21471
- const lastAppliedHorizontalRestoreRef = (0, import_react.useRef)(null);
21472
21484
  const selectionAutoscrollIntervalRef = (0, import_react.useRef)(null);
21473
21485
  const rawTouchMoveLoggedAtRef = (0, import_react.useRef)(0);
21474
21486
  const currentInkStyleRef = (0, import_react.useRef)({
@@ -21732,10 +21744,7 @@ var PageRenderer = ({
21732
21744
  setInkPoints([]);
21733
21745
  inkPointsRef.current = [];
21734
21746
  }, [resolvedActiveTool]);
21735
- const pageViewportWidth = Math.max(
21736
- 0,
21737
- (availableWidth ?? windowWidth) - horizontalPadding * 2
21738
- );
21747
+ const viewportWidth = providedPageViewportWidth ?? availableWidth ?? windowWidth;
21739
21748
  const selectionEnabled = import_react_native.Platform.OS === "web" || isNative && shouldEnableSelectionDrag({
21740
21749
  activeTool: resolvedActiveTool,
21741
21750
  interactionMode: resolvedInteractionMode
@@ -21883,35 +21892,12 @@ var PageRenderer = ({
21883
21892
  stopSelectionAutoscroll();
21884
21893
  return;
21885
21894
  }
21886
- const visibleX = point.x - horizontalScrollOffsetRef.current;
21887
- const { dx } = getSelectionEdgeAutoscroll({
21888
- x: visibleX,
21889
- y: SELECTION_EDGE_THRESHOLD_PX,
21890
- width: pageViewportWidth,
21891
- height: SELECTION_EDGE_THRESHOLD_PX * 2,
21892
- threshold: SELECTION_EDGE_THRESHOLD_PX,
21893
- maxStep: SELECTION_EDGE_MAX_STEP_PX
21894
- });
21895
- let appliedDx = 0;
21896
- if (dx !== 0 && pageViewportWidth > 0) {
21897
- const maxOffsetX = Math.max(0, layout.width - pageViewportWidth);
21898
- const nextOffsetX = clamp3(
21899
- horizontalScrollOffsetRef.current + dx,
21900
- 0,
21901
- maxOffsetX
21902
- );
21903
- appliedDx = nextOffsetX - horizontalScrollOffsetRef.current;
21904
- if (appliedDx !== 0) {
21905
- horizontalScrollOffsetRef.current = nextOffsetX;
21906
- pageScrollRef.current?.scrollTo({ x: nextOffsetX, animated: false });
21907
- }
21908
- }
21909
21895
  const appliedDy = requestSelectionVerticalAutoscroll?.(point.absoluteY) ?? 0;
21910
- if (appliedDx === 0 && appliedDy === 0) {
21896
+ if (appliedDy === 0) {
21911
21897
  stopSelectionAutoscroll();
21912
21898
  return;
21913
21899
  }
21914
- const nextX = clamp3(point.x + appliedDx, 0, layout.width);
21900
+ const nextX = point.x;
21915
21901
  const nextY = clamp3(point.y + appliedDy, 0, layout.height);
21916
21902
  selectionDragPointRef.current = {
21917
21903
  absoluteY: point.absoluteY,
@@ -21922,7 +21908,6 @@ var PageRenderer = ({
21922
21908
  }, [
21923
21909
  layout.height,
21924
21910
  layout.width,
21925
- pageViewportWidth,
21926
21911
  requestSelectionVerticalAutoscroll,
21927
21912
  stopSelectionAutoscroll,
21928
21913
  updateSelectionRectFromPoint
@@ -22372,56 +22357,19 @@ var PageRenderer = ({
22372
22357
  const baseWidth = containerWidth * 0.92;
22373
22358
  const pageWidth = isNative ? baseWidth * zoom : baseWidth;
22374
22359
  const pageHeight = pageWidth / aspectRatio;
22375
- const hasActiveSelection = selectionRects.length > 0 || !!selectionBounds || isSelecting;
22376
- const scrollEnabled = isNative && zoom > 1 && !hasActiveSelection && !isInkDrawing && !gestureScrollLockActive;
22377
- (0, import_react.useEffect)(() => {
22378
- if (!horizontalScrollRestore) return;
22379
- if (lastAppliedHorizontalRestoreRef.current === horizontalScrollRestore.requestId) {
22380
- return;
22381
- }
22382
- const nextOffsetX = resolveClampedScrollOffset(
22383
- horizontalScrollRestore.offsetX,
22384
- pageWidth,
22385
- pageViewportWidth
22386
- );
22387
- lastAppliedHorizontalRestoreRef.current = horizontalScrollRestore.requestId;
22388
- horizontalScrollOffsetRef.current = nextOffsetX;
22389
- pageScrollRef.current?.scrollTo({ x: nextOffsetX, animated: false });
22390
- onHorizontalScrollOffsetChange?.(pageIndex, nextOffsetX);
22391
- }, [
22392
- horizontalScrollRestore,
22393
- onHorizontalScrollOffsetChange,
22394
- pageIndex,
22395
- pageViewportWidth,
22396
- pageWidth
22397
- ]);
22360
+ const pageFrameWidth = Math.max(
22361
+ viewportWidth,
22362
+ pageWidth + horizontalPadding * 2
22363
+ );
22398
22364
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
22399
- import_react_native.ScrollView,
22365
+ import_react_native.View,
22400
22366
  {
22401
- ref: pageScrollRef,
22402
- horizontal: true,
22403
- scrollEnabled,
22404
- showsHorizontalScrollIndicator: false,
22405
- onScroll: (event) => {
22406
- const nextOffsetX = event.nativeEvent.contentOffset?.x ?? 0;
22407
- horizontalScrollOffsetRef.current = nextOffsetX;
22408
- },
22409
- onScrollEndDrag: () => {
22410
- onHorizontalScrollOffsetChange?.(
22411
- pageIndex,
22412
- horizontalScrollOffsetRef.current
22413
- );
22414
- },
22415
- onMomentumScrollEnd: () => {
22416
- onHorizontalScrollOffsetChange?.(
22417
- pageIndex,
22418
- horizontalScrollOffsetRef.current
22419
- );
22420
- },
22421
- scrollEventThrottle: 16,
22422
- contentContainerStyle: [
22367
+ style: [
22423
22368
  styles.scrollContent,
22424
- { paddingHorizontal: horizontalPadding }
22369
+ {
22370
+ width: pageFrameWidth,
22371
+ paddingHorizontal: horizontalPadding
22372
+ }
22425
22373
  ],
22426
22374
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native_gesture_handler.GestureDetector, { gesture: contentGesture, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
22427
22375
  import_react_native.Pressable,
@@ -23122,7 +23070,7 @@ var styles = import_react_native.StyleSheet.create({
23122
23070
  borderRadius: 3
23123
23071
  }
23124
23072
  });
23125
- var arePageRendererPropsEqual = (previous, next) => previous.engine === next.engine && previous.pageIndex === next.pageIndex && previous.scale === next.scale && previous.PageViewComponent === next.PageViewComponent && previous.availableWidth === next.availableWidth && previous.horizontalPadding === next.horizontalPadding && previous.spacing === next.spacing && previous.onSelectionDragActiveChange === next.onSelectionDragActiveChange && previous.gestureScrollLockActive === next.gestureScrollLockActive && previous.lastPinchEndedAt === next.lastPinchEndedAt && previous.onHorizontalScrollOffsetChange === next.onHorizontalScrollOffsetChange && previous.horizontalScrollRestore?.requestId === next.horizontalScrollRestore?.requestId && previous.horizontalScrollRestore?.offsetX === next.horizontalScrollRestore?.offsetX && previous.requestSelectionVerticalAutoscroll === next.requestSelectionVerticalAutoscroll;
23073
+ var arePageRendererPropsEqual = (previous, next) => previous.engine === next.engine && previous.pageIndex === next.pageIndex && previous.scale === next.scale && previous.PageViewComponent === next.PageViewComponent && previous.availableWidth === next.availableWidth && previous.pageViewportWidth === next.pageViewportWidth && previous.horizontalPadding === next.horizontalPadding && previous.spacing === next.spacing && previous.onSelectionDragActiveChange === next.onSelectionDragActiveChange && previous.gestureScrollLockActive === next.gestureScrollLockActive && previous.lastPinchEndedAt === next.lastPinchEndedAt && previous.requestSelectionVerticalAutoscroll === next.requestSelectionVerticalAutoscroll;
23126
23074
  var PageRenderer_default = (0, import_react.memo)(PageRenderer, arePageRendererPropsEqual);
23127
23075
 
23128
23076
  // components/WebViewViewer.tsx
@@ -23274,8 +23222,8 @@ var MOBILE_CHROME_HIDE_DELTA = 28;
23274
23222
  var MOBILE_CHROME_SHOW_DELTA = 22;
23275
23223
  var MOBILE_CHROME_SHOW_DELAY_MS = 180;
23276
23224
  var MOBILE_CHROME_TOP_RESET = 16;
23277
- var SELECTION_EDGE_THRESHOLD_PX2 = 48;
23278
- var SELECTION_EDGE_MAX_STEP_PX2 = 24;
23225
+ var SELECTION_EDGE_THRESHOLD_PX = 48;
23226
+ var SELECTION_EDGE_MAX_STEP_PX = 24;
23279
23227
  var resolvePositiveInt = (value, fallback, min, max) => {
23280
23228
  if (typeof value !== "number" || !Number.isFinite(value)) return fallback;
23281
23229
  const rounded = Math.round(value);
@@ -23300,6 +23248,7 @@ var Viewer = ({
23300
23248
  const viewMode = (0, import_core3.useViewerStore)((state) => state.viewMode);
23301
23249
  const zoom = (0, import_core3.useViewerStore)((state) => state.zoom);
23302
23250
  const listRef = (0, import_react3.useRef)(null);
23251
+ const horizontalScrollRef = (0, import_react3.useRef)(null);
23303
23252
  const isDark = uiTheme === "dark";
23304
23253
  const { width: windowWidth } = (0, import_react_native3.useWindowDimensions)();
23305
23254
  const isDouble = viewMode === "double";
@@ -23339,18 +23288,16 @@ var Viewer = ({
23339
23288
  const gestureScrollLockActiveRef = (0, import_react3.useRef)(false);
23340
23289
  const [pinchPreviewScale, setPinchPreviewScale] = (0, import_react3.useState)(1);
23341
23290
  const [lastPinchEndedAt, setLastPinchEndedAt] = (0, import_react3.useState)(null);
23342
- const [horizontalScrollRestore, setHorizontalScrollRestore] = (0, import_react3.useState)(null);
23343
23291
  const pinchGestureActiveRef = (0, import_react3.useRef)(false);
23344
23292
  const pinchStartZoomRef = (0, import_react3.useRef)(1);
23345
23293
  const pinchPreviewZoomRef = (0, import_react3.useRef)(1);
23346
23294
  const pinchFocalPointRef = (0, import_react3.useRef)({ x: 0, y: 0 });
23347
23295
  const pinchUpdateLoggedAtRef = (0, import_react3.useRef)(0);
23348
- const horizontalScrollOffsetsRef = (0, import_react3.useRef)(/* @__PURE__ */ new Map());
23296
+ const horizontalScrollOffsetRef = (0, import_react3.useRef)(0);
23349
23297
  const pendingPinchAnchorRestoreRef = (0, import_react3.useRef)(
23350
23298
  null
23351
23299
  );
23352
23300
  const pinchAnchorRestoreFrameRef = (0, import_react3.useRef)(null);
23353
- const nextHorizontalRestoreRequestIdRef = (0, import_react3.useRef)(0);
23354
23301
  const viewerFrameRef = (0, import_react3.useRef)({ y: 0, height: 0 });
23355
23302
  const viewerContentHeightRef = (0, import_react3.useRef)(0);
23356
23303
  const resolvedWindowSize = (0, import_react3.useMemo)(
@@ -23650,6 +23597,30 @@ var Viewer = ({
23650
23597
  },
23651
23598
  [columnGap, columnWidth, horizontalPadding, isDouble, windowWidth]
23652
23599
  );
23600
+ const documentSurfaceWidth = (0, import_react3.useMemo)(() => {
23601
+ if (isDouble) {
23602
+ const leftPageWidth = getPageWidthForZoom(0, zoom);
23603
+ const doubleContentWidth = leftPageWidth * 2 + columnGap;
23604
+ return resolveDocumentSurfaceWidth({
23605
+ viewportWidth: windowWidth,
23606
+ contentWidth: doubleContentWidth,
23607
+ horizontalPadding
23608
+ });
23609
+ }
23610
+ return resolveDocumentSurfaceWidth({
23611
+ viewportWidth: windowWidth,
23612
+ contentWidth: getPageWidthForZoom(currentPage - 1, zoom),
23613
+ horizontalPadding
23614
+ });
23615
+ }, [
23616
+ columnGap,
23617
+ currentPage,
23618
+ getPageWidthForZoom,
23619
+ horizontalPadding,
23620
+ isDouble,
23621
+ windowWidth,
23622
+ zoom
23623
+ ]);
23653
23624
  const getPageLayoutForZoom = (0, import_react3.useCallback)(
23654
23625
  (pageIndex, zoomValue) => {
23655
23626
  if (isSingle) {
@@ -23884,7 +23855,7 @@ var Viewer = ({
23884
23855
  startPageOffsetY,
23885
23856
  startPageHeight,
23886
23857
  startPageWidth,
23887
- startPageScrollX: horizontalScrollOffsetsRef.current.get(anchorPageIndex) ?? 0,
23858
+ startSurfaceScrollX: horizontalScrollOffsetRef.current,
23888
23859
  pageViewportWidth,
23889
23860
  pageHorizontalPadding,
23890
23861
  pageViewportContentOffsetX: Math.max(
@@ -23920,34 +23891,21 @@ var Viewer = ({
23920
23891
  setDocumentStateTracked,
23921
23892
  zoom
23922
23893
  ]);
23923
- const handlePageHorizontalScrollOffsetChange = (0, import_react3.useCallback)(
23924
- (pageIndex, offsetX) => {
23925
- horizontalScrollOffsetsRef.current.set(pageIndex, Math.max(0, offsetX));
23926
- const pageWidth = getPageWidthForZoom(pageIndex, zoom);
23927
- const { viewportWidth, horizontalPadding: horizontalPadding2 } = getPageViewportMetrics(pageIndex);
23928
- const pageViewportWidth = Math.max(
23929
- 0,
23930
- viewportWidth - horizontalPadding2 * 2
23931
- );
23932
- const nextOffsetX = resolveClampedScrollOffset(
23894
+ const scrollHorizontalSurfaceTo = (0, import_react3.useCallback)(
23895
+ (offsetX) => {
23896
+ const nextOffsetX = resolveGlobalHorizontalOffset({
23933
23897
  offsetX,
23934
- pageWidth,
23935
- pageViewportWidth
23936
- );
23937
- setHorizontalScrollRestore((current) => {
23938
- if (current && Math.abs(current.offsetX - nextOffsetX) < 0.5) {
23939
- return current;
23940
- }
23941
- const requestId = nextHorizontalRestoreRequestIdRef.current + 1;
23942
- nextHorizontalRestoreRequestIdRef.current = requestId;
23943
- return {
23944
- pageIndex,
23945
- requestId,
23946
- offsetX: nextOffsetX
23947
- };
23898
+ surfaceWidth: documentSurfaceWidth,
23899
+ viewportWidth: windowWidth
23900
+ });
23901
+ horizontalScrollOffsetRef.current = nextOffsetX;
23902
+ horizontalScrollRef.current?.scrollTo({
23903
+ x: nextOffsetX,
23904
+ animated: false
23948
23905
  });
23906
+ return nextOffsetX;
23949
23907
  },
23950
- [getPageViewportMetrics, getPageWidthForZoom, zoom]
23908
+ [documentSurfaceWidth, windowWidth]
23951
23909
  );
23952
23910
  const viewerPinchGesture = (0, import_react3.useMemo)(
23953
23911
  () => import_react_native_gesture_handler2.Gesture.Pinch().enabled(!isWebView && pageCount > 0).onTouchesDown((event) => {
@@ -24030,7 +23988,7 @@ var Viewer = ({
24030
23988
  );
24031
23989
  const nextOffsetX = resolveAnchoredViewportOffset({
24032
23990
  viewportOffset: pendingRestore.pageViewportContentOffsetX,
24033
- startScrollOffset: pendingRestore.startPageScrollX,
23991
+ startScrollOffset: pendingRestore.startSurfaceScrollX,
24034
23992
  startItemOffset: 0,
24035
23993
  startItemLength: pendingRestore.startPageWidth,
24036
23994
  endItemOffset: 0,
@@ -24038,19 +23996,13 @@ var Viewer = ({
24038
23996
  viewportLength: pageViewportContentWidth,
24039
23997
  endContentLength: endPageWidth
24040
23998
  });
24041
- const requestId = nextHorizontalRestoreRequestIdRef.current + 1;
24042
- nextHorizontalRestoreRequestIdRef.current = requestId;
24043
- setHorizontalScrollRestore({
24044
- pageIndex: pendingRestore.pageIndex,
24045
- requestId,
24046
- offsetX: nextOffsetX
24047
- });
23999
+ const appliedOffsetX = scrollHorizontalSurfaceTo(nextOffsetX);
24048
24000
  pendingPinchAnchorRestoreRef.current = null;
24049
24001
  if (perfEnabled) {
24050
24002
  logPerfEvent("Viewer", "pinch.anchorRestore", {
24051
24003
  page: pendingRestore.pageIndex + 1,
24052
24004
  scrollY: Math.round(nextScrollY * 100) / 100,
24053
- scrollX: Math.round(nextOffsetX * 100) / 100,
24005
+ scrollX: Math.round(appliedOffsetX * 100) / 100,
24054
24006
  zoom: Math.round(zoom * 100) / 100
24055
24007
  });
24056
24008
  }
@@ -24061,22 +24013,18 @@ var Viewer = ({
24061
24013
  pinchAnchorRestoreFrameRef.current = null;
24062
24014
  }
24063
24015
  };
24064
- }, [getPageLayoutForZoom, getPageWidthForZoom, isSingle, perfEnabled, zoom]);
24016
+ }, [
24017
+ getPageLayoutForZoom,
24018
+ getPageWidthForZoom,
24019
+ isSingle,
24020
+ perfEnabled,
24021
+ scrollHorizontalSurfaceTo,
24022
+ zoom
24023
+ ]);
24065
24024
  (0, import_react3.useEffect)(() => {
24066
- if (zoom > 1) return;
24067
- setHorizontalScrollRestore((current) => {
24068
- if (!current || Math.abs(current.offsetX) < 0.5) {
24069
- return current;
24070
- }
24071
- const requestId = nextHorizontalRestoreRequestIdRef.current + 1;
24072
- nextHorizontalRestoreRequestIdRef.current = requestId;
24073
- return {
24074
- pageIndex: current.pageIndex,
24075
- requestId,
24076
- offsetX: 0
24077
- };
24078
- });
24079
- }, [zoom]);
24025
+ if (zoom > 1 && documentSurfaceWidth > windowWidth) return;
24026
+ scrollHorizontalSurfaceTo(0);
24027
+ }, [documentSurfaceWidth, scrollHorizontalSurfaceTo, windowWidth, zoom]);
24080
24028
  const captureViewerFrame = (0, import_react3.useCallback)((node) => {
24081
24029
  const measurable = node;
24082
24030
  measurable?.measureInWindow?.((_, y, __, height) => {
@@ -24116,12 +24064,12 @@ var Viewer = ({
24116
24064
  if (!Number.isFinite(absoluteY) || frame.height <= 0) return 0;
24117
24065
  const relativeY = absoluteY - frame.y;
24118
24066
  const { dy } = getSelectionEdgeAutoscroll({
24119
- x: SELECTION_EDGE_THRESHOLD_PX2,
24067
+ x: SELECTION_EDGE_THRESHOLD_PX,
24120
24068
  y: relativeY,
24121
- width: SELECTION_EDGE_THRESHOLD_PX2 * 2,
24069
+ width: SELECTION_EDGE_THRESHOLD_PX * 2,
24122
24070
  height: frame.height,
24123
- threshold: SELECTION_EDGE_THRESHOLD_PX2,
24124
- maxStep: SELECTION_EDGE_MAX_STEP_PX2
24071
+ threshold: SELECTION_EDGE_THRESHOLD_PX,
24072
+ maxStep: SELECTION_EDGE_MAX_STEP_PX
24125
24073
  });
24126
24074
  return scrollViewerBy(dy);
24127
24075
  },
@@ -24359,42 +24307,49 @@ var Viewer = ({
24359
24307
  ({ item }) => {
24360
24308
  if (isDouble) {
24361
24309
  const row = item;
24362
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react_native3.View, { style: [styles3.row, { paddingHorizontal: horizontalPadding }], children: [
24363
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native3.View, { style: { width: columnWidth }, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
24364
- PageRenderer_default,
24365
- {
24366
- engine,
24367
- pageIndex: row.left,
24368
- pageAspectRatio: getPageAspectRatio(row.left),
24369
- availableWidth: columnWidth,
24370
- horizontalPadding: 8,
24371
- spacing: DOUBLE_PAGE_SPACING,
24372
- onSelectionDragActiveChange: setSelectionDragActive,
24373
- gestureScrollLockActive,
24374
- lastPinchEndedAt,
24375
- onHorizontalScrollOffsetChange: handlePageHorizontalScrollOffsetChange,
24376
- horizontalScrollRestore,
24377
- requestSelectionVerticalAutoscroll: handleSelectionVerticalAutoscroll
24378
- }
24379
- ) }),
24380
- row.right !== null ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native3.View, { style: { width: columnWidth }, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
24381
- PageRenderer_default,
24382
- {
24383
- engine,
24384
- pageIndex: row.right,
24385
- pageAspectRatio: getPageAspectRatio(row.right),
24386
- availableWidth: columnWidth,
24387
- horizontalPadding: 8,
24388
- spacing: DOUBLE_PAGE_SPACING,
24389
- onSelectionDragActiveChange: setSelectionDragActive,
24390
- gestureScrollLockActive,
24391
- lastPinchEndedAt,
24392
- onHorizontalScrollOffsetChange: handlePageHorizontalScrollOffsetChange,
24393
- horizontalScrollRestore,
24394
- requestSelectionVerticalAutoscroll: handleSelectionVerticalAutoscroll
24395
- }
24396
- ) }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native3.View, { style: { width: columnWidth } })
24397
- ] });
24310
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
24311
+ import_react_native3.View,
24312
+ {
24313
+ style: [
24314
+ styles3.row,
24315
+ { paddingHorizontal: horizontalPadding, width: documentSurfaceWidth }
24316
+ ],
24317
+ children: [
24318
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native3.View, { style: { width: columnWidth }, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
24319
+ PageRenderer_default,
24320
+ {
24321
+ engine,
24322
+ pageIndex: row.left,
24323
+ pageAspectRatio: getPageAspectRatio(row.left),
24324
+ availableWidth: columnWidth,
24325
+ horizontalPadding: 8,
24326
+ pageViewportWidth: columnWidth,
24327
+ spacing: DOUBLE_PAGE_SPACING,
24328
+ onSelectionDragActiveChange: setSelectionDragActive,
24329
+ gestureScrollLockActive,
24330
+ lastPinchEndedAt,
24331
+ requestSelectionVerticalAutoscroll: handleSelectionVerticalAutoscroll
24332
+ }
24333
+ ) }),
24334
+ row.right !== null ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native3.View, { style: { width: columnWidth }, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
24335
+ PageRenderer_default,
24336
+ {
24337
+ engine,
24338
+ pageIndex: row.right,
24339
+ pageAspectRatio: getPageAspectRatio(row.right),
24340
+ availableWidth: columnWidth,
24341
+ horizontalPadding: 8,
24342
+ pageViewportWidth: columnWidth,
24343
+ spacing: DOUBLE_PAGE_SPACING,
24344
+ onSelectionDragActiveChange: setSelectionDragActive,
24345
+ gestureScrollLockActive,
24346
+ lastPinchEndedAt,
24347
+ requestSelectionVerticalAutoscroll: handleSelectionVerticalAutoscroll
24348
+ }
24349
+ ) }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native3.View, { style: { width: columnWidth } })
24350
+ ]
24351
+ }
24352
+ );
24398
24353
  }
24399
24354
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
24400
24355
  PageRenderer_default,
@@ -24402,27 +24357,27 @@ var Viewer = ({
24402
24357
  engine,
24403
24358
  pageIndex: item,
24404
24359
  pageAspectRatio: getPageAspectRatio(item),
24360
+ availableWidth: windowWidth,
24361
+ pageViewportWidth: documentSurfaceWidth,
24405
24362
  spacing: CONTINUOUS_PAGE_SPACING,
24406
24363
  onSelectionDragActiveChange: setSelectionDragActive,
24407
24364
  gestureScrollLockActive,
24408
24365
  lastPinchEndedAt,
24409
- onHorizontalScrollOffsetChange: handlePageHorizontalScrollOffsetChange,
24410
- horizontalScrollRestore,
24411
24366
  requestSelectionVerticalAutoscroll: handleSelectionVerticalAutoscroll
24412
24367
  }
24413
24368
  );
24414
24369
  },
24415
24370
  [
24416
24371
  columnWidth,
24372
+ documentSurfaceWidth,
24417
24373
  engine,
24418
24374
  getPageAspectRatio,
24419
- handlePageHorizontalScrollOffsetChange,
24420
24375
  handleSelectionVerticalAutoscroll,
24421
24376
  gestureScrollLockActive,
24422
- horizontalScrollRestore,
24423
24377
  horizontalPadding,
24424
24378
  isDouble,
24425
- lastPinchEndedAt
24379
+ lastPinchEndedAt,
24380
+ windowWidth
24426
24381
  ]
24427
24382
  );
24428
24383
  if (isWebView) {
@@ -24439,50 +24394,64 @@ var Viewer = ({
24439
24394
  children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
24440
24395
  import_react_native3.ScrollView,
24441
24396
  {
24442
- ref: (node) => {
24443
- captureViewerFrame(node);
24444
- listRef.current = node;
24445
- },
24446
- contentContainerStyle: styles3.singleContent,
24447
- showsVerticalScrollIndicator: false,
24448
- scrollEnabled: resolvedViewerScrollEnabled,
24449
- onLayout: () => captureViewerFrame(listRef.current),
24450
- onContentSizeChange: (_, height) => {
24451
- viewerContentHeightRef.current = height;
24397
+ ref: horizontalScrollRef,
24398
+ horizontal: true,
24399
+ scrollEnabled: !gestureScrollLockActive && documentSurfaceWidth > windowWidth,
24400
+ showsHorizontalScrollIndicator: false,
24401
+ onScroll: (event) => {
24402
+ horizontalScrollOffsetRef.current = event.nativeEvent.contentOffset?.x ?? 0;
24452
24403
  },
24453
- onScroll: (event) => handleViewerScroll(event, "single"),
24454
- onScrollBeginDrag: perfEnabled ? () => {
24455
- scrollMonitorRef.current.begin("single.beginDrag");
24456
- } : void 0,
24457
- onMomentumScrollBegin: perfEnabled ? () => {
24458
- scrollMonitorRef.current.begin("single.momentumBegin");
24459
- } : void 0,
24460
- onScrollEndDrag: perfEnabled ? () => {
24461
- scrollMonitorRef.current.end("single.endDrag");
24462
- sampleMemory("Viewer", "single.endDrag", { pageCount });
24463
- } : void 0,
24464
- onMomentumScrollEnd: perfEnabled ? () => {
24465
- scrollMonitorRef.current.end("single.momentumEnd");
24466
- sampleMemory("Viewer", "single.momentumEnd", {
24467
- pageCount
24468
- });
24469
- } : void 0,
24470
24404
  scrollEventThrottle: 16,
24471
24405
  children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
24472
- PageRenderer_default,
24406
+ import_react_native3.ScrollView,
24473
24407
  {
24474
- engine,
24475
- pageIndex: Math.max(0, currentPage - 1),
24476
- pageAspectRatio: getPageAspectRatio(
24477
- Math.max(0, currentPage - 1)
24478
- ),
24479
- spacing: 32,
24480
- onSelectionDragActiveChange: setSelectionDragActive,
24481
- gestureScrollLockActive,
24482
- lastPinchEndedAt,
24483
- onHorizontalScrollOffsetChange: handlePageHorizontalScrollOffsetChange,
24484
- horizontalScrollRestore,
24485
- requestSelectionVerticalAutoscroll: handleSelectionVerticalAutoscroll
24408
+ ref: (node) => {
24409
+ captureViewerFrame(node);
24410
+ listRef.current = node;
24411
+ },
24412
+ style: { width: documentSurfaceWidth },
24413
+ contentContainerStyle: styles3.singleContent,
24414
+ showsVerticalScrollIndicator: false,
24415
+ scrollEnabled: resolvedViewerScrollEnabled,
24416
+ onLayout: () => captureViewerFrame(listRef.current),
24417
+ onContentSizeChange: (_, height) => {
24418
+ viewerContentHeightRef.current = height;
24419
+ },
24420
+ onScroll: (event) => handleViewerScroll(event, "single"),
24421
+ onScrollBeginDrag: perfEnabled ? () => {
24422
+ scrollMonitorRef.current.begin("single.beginDrag");
24423
+ } : void 0,
24424
+ onMomentumScrollBegin: perfEnabled ? () => {
24425
+ scrollMonitorRef.current.begin("single.momentumBegin");
24426
+ } : void 0,
24427
+ onScrollEndDrag: perfEnabled ? () => {
24428
+ scrollMonitorRef.current.end("single.endDrag");
24429
+ sampleMemory("Viewer", "single.endDrag", { pageCount });
24430
+ } : void 0,
24431
+ onMomentumScrollEnd: perfEnabled ? () => {
24432
+ scrollMonitorRef.current.end("single.momentumEnd");
24433
+ sampleMemory("Viewer", "single.momentumEnd", {
24434
+ pageCount
24435
+ });
24436
+ } : void 0,
24437
+ scrollEventThrottle: 16,
24438
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
24439
+ PageRenderer_default,
24440
+ {
24441
+ engine,
24442
+ pageIndex: Math.max(0, currentPage - 1),
24443
+ pageAspectRatio: getPageAspectRatio(
24444
+ Math.max(0, currentPage - 1)
24445
+ ),
24446
+ availableWidth: windowWidth,
24447
+ pageViewportWidth: documentSurfaceWidth,
24448
+ spacing: 32,
24449
+ onSelectionDragActiveChange: setSelectionDragActive,
24450
+ gestureScrollLockActive,
24451
+ lastPinchEndedAt,
24452
+ requestSelectionVerticalAutoscroll: handleSelectionVerticalAutoscroll
24453
+ }
24454
+ )
24486
24455
  }
24487
24456
  )
24488
24457
  }
@@ -24498,74 +24467,90 @@ var Viewer = ({
24498
24467
  { transform: [{ scale: pinchPreviewScale }] }
24499
24468
  ],
24500
24469
  children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
24501
- import_react_native3.FlatList,
24470
+ import_react_native3.ScrollView,
24502
24471
  {
24503
- ref: listRef,
24504
- data: isDouble ? rows : pages,
24505
- initialNumToRender: FLATLIST_INITIAL_NUM_TO_RENDER,
24506
- windowSize: resolvedWindowSize,
24507
- maxToRenderPerBatch: resolvedMaxToRenderPerBatch,
24508
- updateCellsBatchingPeriod: FLATLIST_UPDATE_CELLS_BATCHING_PERIOD,
24509
- removeClippedSubviews: resolvedRemoveClippedSubviews,
24510
- getItemLayout,
24511
- keyExtractor,
24512
- contentContainerStyle: styles3.listContent,
24513
- renderItem,
24514
- onViewableItemsChanged,
24515
- viewabilityConfig: { itemVisiblePercentThreshold: 60 },
24516
- scrollEnabled: resolvedViewerScrollEnabled,
24517
- onLayout: () => captureViewerFrame(listRef.current),
24518
- onContentSizeChange: (_, height) => {
24519
- viewerContentHeightRef.current = height;
24472
+ ref: horizontalScrollRef,
24473
+ horizontal: true,
24474
+ scrollEnabled: !gestureScrollLockActive && documentSurfaceWidth > windowWidth,
24475
+ showsHorizontalScrollIndicator: false,
24476
+ onScroll: (event) => {
24477
+ horizontalScrollOffsetRef.current = event.nativeEvent.contentOffset?.x ?? 0;
24520
24478
  },
24521
- onScrollToIndexFailed: ({ index, averageItemLength }) => {
24522
- const dataLength = isDouble ? rows.length : pages.length;
24523
- if (index < 0 || index >= dataLength) return;
24524
- pendingScrollIndexRef.current = index;
24525
- const offset = Math.max(0, getFallbackOffsetForIndex(index));
24526
- listRef.current?.scrollToOffset({ offset, animated: false });
24527
- if (!isDouble) {
24528
- ensurePageDimensions(index);
24529
- } else {
24530
- const row = rows[index];
24531
- if (row) {
24532
- ensurePageDimensions(row.left);
24533
- if (row.right !== null) {
24534
- ensurePageDimensions(row.right);
24479
+ scrollEventThrottle: 16,
24480
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
24481
+ import_react_native3.FlatList,
24482
+ {
24483
+ ref: listRef,
24484
+ data: isDouble ? rows : pages,
24485
+ style: { width: documentSurfaceWidth },
24486
+ initialNumToRender: FLATLIST_INITIAL_NUM_TO_RENDER,
24487
+ windowSize: resolvedWindowSize,
24488
+ maxToRenderPerBatch: resolvedMaxToRenderPerBatch,
24489
+ updateCellsBatchingPeriod: FLATLIST_UPDATE_CELLS_BATCHING_PERIOD,
24490
+ removeClippedSubviews: resolvedRemoveClippedSubviews,
24491
+ getItemLayout,
24492
+ keyExtractor,
24493
+ contentContainerStyle: styles3.listContent,
24494
+ renderItem,
24495
+ onViewableItemsChanged,
24496
+ viewabilityConfig: { itemVisiblePercentThreshold: 60 },
24497
+ scrollEnabled: resolvedViewerScrollEnabled,
24498
+ onLayout: () => captureViewerFrame(listRef.current),
24499
+ onContentSizeChange: (_, height) => {
24500
+ viewerContentHeightRef.current = height;
24501
+ },
24502
+ onScrollToIndexFailed: ({ index, averageItemLength }) => {
24503
+ const dataLength = isDouble ? rows.length : pages.length;
24504
+ if (index < 0 || index >= dataLength) return;
24505
+ pendingScrollIndexRef.current = index;
24506
+ const offset = Math.max(0, getFallbackOffsetForIndex(index));
24507
+ listRef.current?.scrollToOffset({ offset, animated: false });
24508
+ if (!isDouble) {
24509
+ ensurePageDimensions(index);
24510
+ } else {
24511
+ const row = rows[index];
24512
+ if (row) {
24513
+ ensurePageDimensions(row.left);
24514
+ if (row.right !== null) {
24515
+ ensurePageDimensions(row.right);
24516
+ }
24517
+ }
24535
24518
  }
24536
- }
24537
- }
24538
- scheduleScrollRetry("onScrollToIndexFailed");
24539
- if (perfEnabled) {
24540
- logPerfEvent("Viewer", "scrollToIndexFailed", {
24541
- index,
24542
- averageItemLength,
24543
- fallbackOffset: offset,
24544
- fallbackSource: "cached-item-layout",
24545
- itemCount: dataLength,
24546
- retryAttempt: pendingScrollAttemptsRef.current
24547
- });
24519
+ scheduleScrollRetry("onScrollToIndexFailed");
24520
+ if (perfEnabled) {
24521
+ logPerfEvent("Viewer", "scrollToIndexFailed", {
24522
+ index,
24523
+ averageItemLength,
24524
+ fallbackOffset: offset,
24525
+ fallbackSource: "cached-item-layout",
24526
+ itemCount: dataLength,
24527
+ retryAttempt: pendingScrollAttemptsRef.current
24528
+ });
24529
+ }
24530
+ },
24531
+ onScroll: (event) => handleViewerScroll(event, "continuous"),
24532
+ onScrollBeginDrag: perfEnabled ? () => {
24533
+ scrollMonitorRef.current.begin("continuous.beginDrag");
24534
+ } : void 0,
24535
+ onMomentumScrollBegin: perfEnabled ? () => {
24536
+ scrollMonitorRef.current.begin("continuous.momentumBegin");
24537
+ } : void 0,
24538
+ onScrollEndDrag: perfEnabled ? () => {
24539
+ scrollMonitorRef.current.end("continuous.endDrag");
24540
+ sampleMemory("Viewer", "continuous.endDrag", {
24541
+ pageCount
24542
+ });
24543
+ } : void 0,
24544
+ onMomentumScrollEnd: perfEnabled ? () => {
24545
+ scrollMonitorRef.current.end("continuous.momentumEnd");
24546
+ sampleMemory("Viewer", "continuous.momentumEnd", {
24547
+ pageCount
24548
+ });
24549
+ } : void 0,
24550
+ scrollEventThrottle: 16,
24551
+ showsVerticalScrollIndicator: false
24548
24552
  }
24549
- },
24550
- onScroll: (event) => handleViewerScroll(event, "continuous"),
24551
- onScrollBeginDrag: perfEnabled ? () => {
24552
- scrollMonitorRef.current.begin("continuous.beginDrag");
24553
- } : void 0,
24554
- onMomentumScrollBegin: perfEnabled ? () => {
24555
- scrollMonitorRef.current.begin("continuous.momentumBegin");
24556
- } : void 0,
24557
- onScrollEndDrag: perfEnabled ? () => {
24558
- scrollMonitorRef.current.end("continuous.endDrag");
24559
- sampleMemory("Viewer", "continuous.endDrag", { pageCount });
24560
- } : void 0,
24561
- onMomentumScrollEnd: perfEnabled ? () => {
24562
- scrollMonitorRef.current.end("continuous.momentumEnd");
24563
- sampleMemory("Viewer", "continuous.momentumEnd", {
24564
- pageCount
24565
- });
24566
- } : void 0,
24567
- scrollEventThrottle: 16,
24568
- showsVerticalScrollIndicator: false
24553
+ )
24569
24554
  }
24570
24555
  )
24571
24556
  }