Skip to content

Commit

Permalink
Merge pull request #176 from DevStaKat/master
Browse files Browse the repository at this point in the history
interactionEndFrictionCoefficient param added
  • Loading branch information
espresso3389 authored Jun 18, 2024
2 parents 2a1cb05 + b365748 commit 2515409
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/src/widgets/pdf_viewer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@ class _PdfViewerState extends State<PdfViewer>
onInteractionEnd: widget.params.onInteractionEnd,
onInteractionStart: widget.params.onInteractionStart,
onInteractionUpdate: widget.params.onInteractionUpdate,
interactionEndFrictionCoefficient: widget.params.interactionEndFrictionCoefficient,
onWheelDelta: widget.params.scrollByMouseWheel != null
? _onWheelDelta
: null,
Expand Down
13 changes: 13 additions & 0 deletions lib/src/widgets/pdf_viewer_params.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class PdfViewerParams {
this.onInteractionEnd,
this.onInteractionStart,
this.onInteractionUpdate,
this.interactionEndFrictionCoefficient = _kDrag,
this.onDocumentChanged,
this.calculateInitialPageNumber,
this.calculateCurrentPageNumber,
Expand Down Expand Up @@ -190,6 +191,13 @@ class PdfViewerParams {
/// See [InteractiveViewer.onInteractionUpdate] for details.
final GestureScaleUpdateCallback? onInteractionUpdate;

/// See [InteractiveViewer.interactionEndFrictionCoefficient] for details.
final double interactionEndFrictionCoefficient;

// Used as the coefficient of friction in the inertial translation animation.
// This value was eyeballed to give a feel similar to Google Photos.
static const double _kDrag = 0.0000135;

/// Function to notify that the document is loaded/changed.
///
/// The function is called even if the document is null (it means the document is unloaded).
Expand Down Expand Up @@ -401,6 +409,8 @@ class PdfViewerParams {
other.pageDropShadow != pageDropShadow ||
other.panEnabled != panEnabled ||
other.scaleEnabled != scaleEnabled ||
other.interactionEndFrictionCoefficient !=
interactionEndFrictionCoefficient ||
other.scrollByMouseWheel != scrollByMouseWheel ||
other.enableKeyboardNavigation != enableKeyboardNavigation ||
other.scrollByArrowKey != scrollByArrowKey ||
Expand Down Expand Up @@ -434,6 +444,8 @@ class PdfViewerParams {
other.onInteractionEnd == onInteractionEnd &&
other.onInteractionStart == onInteractionStart &&
other.onInteractionUpdate == onInteractionUpdate &&
other.interactionEndFrictionCoefficient ==
interactionEndFrictionCoefficient &&
other.onDocumentChanged == onDocumentChanged &&
other.calculateInitialPageNumber == calculateInitialPageNumber &&
other.calculateCurrentPageNumber == calculateCurrentPageNumber &&
Expand Down Expand Up @@ -479,6 +491,7 @@ class PdfViewerParams {
onInteractionEnd.hashCode ^
onInteractionStart.hashCode ^
onInteractionUpdate.hashCode ^
interactionEndFrictionCoefficient.hashCode ^
onDocumentChanged.hashCode ^
calculateInitialPageNumber.hashCode ^
calculateCurrentPageNumber.hashCode ^
Expand Down

0 comments on commit 2515409

Please sign in to comment.