@amafil/react-native-pdf-toolkit 1.0.10 → 1.0.15
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
|
|
583
|
-
|
|
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;
|
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
|
|
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(
|
|
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(
|
|
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
|
-
|
|
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
|
-
[
|
|
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; //
|
|
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; //
|
|
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)
|
|
1005
|
+
- (void)startAutoScroll:(CGFloat)dpPerSecond resumeDelay:(NSTimeInterval)resumeDelay
|
|
1006
1006
|
{
|
|
1007
|
-
|
|
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
|
|
|
@@ -55,35 +55,13 @@ RCT_EXPORT_VIEW_PROPERTY(enableTextSelection, BOOL);
|
|
|
55
55
|
RCT_EXPORT_VIEW_PROPERTY(onTextSelectionChange, RCTBubblingEventBlock);
|
|
56
56
|
|
|
57
57
|
RCT_EXPORT_METHOD(startAutoScroll:(nonnull NSNumber *)reactTag
|
|
58
|
-
|
|
58
|
+
dpPerSecond:(double)dpPerSecond
|
|
59
59
|
resumeDelay:(double)resumeDelay)
|
|
60
60
|
{
|
|
61
61
|
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
62
62
|
RNPDFPdfView *view = (RNPDFPdfView *)viewRegistry[reactTag];
|
|
63
63
|
if ([view isKindOfClass:[RNPDFPdfView class]]) {
|
|
64
|
-
[view startAutoScroll:(CGFloat)
|
|
65
|
-
}
|
|
66
|
-
}];
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
RCT_EXPORT_METHOD(stopAutoScroll:(nonnull NSNumber *)reactTag)
|
|
70
|
-
{
|
|
71
|
-
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
72
|
-
RNPDFPdfView *view = (RNPDFPdfView *)viewRegistry[reactTag];
|
|
73
|
-
if ([view isKindOfClass:[RNPDFPdfView class]]) {
|
|
74
|
-
[view stopAutoScroll];
|
|
75
|
-
}
|
|
76
|
-
}];
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
RCT_EXPORT_METHOD(startAutoScroll:(nonnull NSNumber *)reactTag
|
|
80
|
-
pixels:(double)pixels
|
|
81
|
-
resumeDelay:(double)resumeDelay)
|
|
82
|
-
{
|
|
83
|
-
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
|
84
|
-
RNPDFPdfView *view = (RNPDFPdfView *)viewRegistry[reactTag];
|
|
85
|
-
if ([view isKindOfClass:[RNPDFPdfView class]]) {
|
|
86
|
-
[view startAutoScroll:(CGFloat)pixels resumeDelay:(NSTimeInterval)(resumeDelay / 1000.0)];
|
|
64
|
+
[view startAutoScroll:(CGFloat)dpPerSecond resumeDelay:(NSTimeInterval)(resumeDelay / 1000.0)];
|
|
87
65
|
}
|
|
88
66
|
}];
|
|
89
67
|
}
|
package/package.json
CHANGED