@amafil/react-native-pdf-toolkit 1.0.9 → 1.0.11

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.
@@ -579,8 +579,10 @@ public class PdfView extends PDFView implements OnPageChangeListener,OnLoadCompl
579
579
 
580
580
  // Autoscroll methods
581
581
 
582
- public void startAutoScroll(float pixels, long resumeDelayMs) {
583
- this.autoScrollPixels = pixels; // pixels per second
582
+ public void startAutoScroll(float dpPerSecond, long resumeDelayMs) {
583
+ // Convert dp to physical pixels so scroll speed is consistent across screen densities
584
+ float density = getResources().getDisplayMetrics().density;
585
+ this.autoScrollPixels = dpPerSecond * density;
584
586
  this.autoScrollResumeDelay = resumeDelayMs;
585
587
  this.isAutoScrolling = true;
586
588
  this.lastFrameTimeNanos = 0;
@@ -635,6 +637,7 @@ public class PdfView extends PDFView implements OnPageChangeListener,OnLoadCompl
635
637
  }
636
638
 
637
639
  moveTo(0, -accumulatedScrollOffset);
640
+ loadPages();
638
641
  Choreographer.getInstance().postFrameCallback(this);
639
642
  }
640
643
  };
package/index.d.ts CHANGED
@@ -87,10 +87,10 @@ export interface PdfRef {
87
87
  setPage(pageNumber: number): void
88
88
  /**
89
89
  * Start smooth automatic vertical scrolling using the display refresh rate.
90
- * @param pixels - Scroll speed in pixels per second (default: 15). `interval` is ignored in smooth mode.
90
+ * @param dpPerSecond - Scroll speed in density-independent pixels (dp) per second (default: 15). Produces consistent physical speed across screen densities.
91
91
  * @param resumeDelay - Milliseconds to wait before resuming after user touch (default: 3000)
92
92
  */
93
- startAutoScroll(pixels?: number, resumeDelay?: number): void
93
+ startAutoScroll(dpPerSecond?: number, resumeDelay?: number): void
94
94
  /** Stop automatic scrolling. */
95
95
  stopAutoScroll(): void
96
96
  }
package/index.js CHANGED
@@ -372,13 +372,13 @@ export default class Pdf extends Component {
372
372
 
373
373
  }
374
374
 
375
- startAutoScroll( pixels = 15, resumeDelay = 3000 ) {
375
+ startAutoScroll( dpPerSecond = 15, resumeDelay = 3000 ) {
376
376
  this._isAutoScrollActive = true;
377
377
  if (!!global?.nativeFabricUIManager) {
378
378
  if (this._root) {
379
379
  PdfViewCommands.startNativeAutoScroll(
380
380
  this._root,
381
- pixels,
381
+ dpPerSecond,
382
382
  resumeDelay,
383
383
  );
384
384
  }
@@ -387,7 +387,7 @@ export default class Pdf extends Component {
387
387
  ReactNative.UIManager.dispatchViewManagerCommand(
388
388
  ReactNative.findNodeHandle(this._root),
389
389
  'startNativeAutoScroll',
390
- [pixels, resumeDelay],
390
+ [dpPerSecond, resumeDelay],
391
391
  );
392
392
  }
393
393
  }
@@ -79,7 +79,7 @@ const float MIN_SCALE = 1.0f;
79
79
  // Autoscroll
80
80
  CADisplayLink *_displayLink;
81
81
  NSTimer *_autoScrollResumeTimer;
82
- CGFloat _autoScrollPixels; // pixels per second
82
+ CGFloat _autoScrollPixels; // points per second (dp maps 1:1 to iOS points)
83
83
  NSTimeInterval _autoScrollResumeDelay;
84
84
  BOOL _isAutoScrolling;
85
85
  BOOL _isUserDragging;
@@ -306,7 +306,7 @@ using namespace facebook::react;
306
306
  _changedProps = NULL;
307
307
 
308
308
  // Autoscroll defaults
309
- _autoScrollPixels = 15.0f; // px/sec
309
+ _autoScrollPixels = 15.0f; // dp/sec
310
310
  _autoScrollResumeDelay = 3.0;
311
311
  _isAutoScrolling = NO;
312
312
  _isUserDragging = NO;
@@ -1002,9 +1002,10 @@ using namespace facebook::react;
1002
1002
  return nil;
1003
1003
  }
1004
1004
 
1005
- - (void)startAutoScroll:(CGFloat)pixels resumeDelay:(NSTimeInterval)resumeDelay
1005
+ - (void)startAutoScroll:(CGFloat)dpPerSecond resumeDelay:(NSTimeInterval)resumeDelay
1006
1006
  {
1007
- _autoScrollPixels = pixels; // pixels per second
1007
+ // dp maps 1:1 to iOS points (both are ~160 dpi logical units)
1008
+ _autoScrollPixels = dpPerSecond;
1008
1009
  _autoScrollResumeDelay = resumeDelay;
1009
1010
  _isAutoScrolling = YES;
1010
1011
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amafil/react-native-pdf-toolkit",
3
- "version": "1.0.9",
3
+ "version": "1.0.11",
4
4
  "summary": "A react native PDF view component",
5
5
  "description": "A react native PDF view component, support ios and android platform",
6
6
  "main": "index.js",