Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/src/drag_marker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class DragMarker {
final bool rotateMarker;

/// This option prevents the marker from being dragged
final bool disableDrag;
bool disableDrag;

/// Alignment of the marker relative to the normal center at [point]
///
Expand Down
33 changes: 19 additions & 14 deletions lib/src/drag_marker_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,16 @@ class DragMarkerWidgetState extends State<DragMarkerWidget> {
return MobileLayerTransformer(
child: GestureDetector(
// drag detectors
onVerticalDragStart: (marker.disableDrag || marker.useLongPress) ? null : _onPanStart,
onVerticalDragUpdate: (marker.disableDrag || marker.useLongPress) ? null : _onPanUpdate,
onVerticalDragEnd: (marker.disableDrag || marker.useLongPress) ? null : _onPanEnd,
onHorizontalDragStart: (marker.disableDrag || marker.useLongPress) ? null : _onPanStart,
onHorizontalDragUpdate: (marker.disableDrag || marker.useLongPress) ? null : _onPanUpdate,
onHorizontalDragEnd: (marker.disableDrag || marker.useLongPress) ? null : _onPanEnd,
onVerticalDragStart: (marker.useLongPress) ? null : _onPanStart,
onVerticalDragUpdate: (marker.useLongPress) ? null : _onPanUpdate,
onVerticalDragEnd: (marker.useLongPress) ? null : _onPanEnd,
onHorizontalDragStart: (marker.useLongPress) ? null : _onPanStart,
onHorizontalDragUpdate: (marker.useLongPress) ? null : _onPanUpdate,
onHorizontalDragEnd: (marker.useLongPress) ? null : _onPanEnd,
// long press detectors
onLongPressStart: (marker.disableDrag || marker.useLongPress) ? _onLongPanStart : null,
onLongPressMoveUpdate: (marker.disableDrag || marker.useLongPress) ? _onLongPanUpdate : null,
onLongPressEnd: (marker.disableDrag || marker.useLongPress) ? _onLongPanEnd : null,
onLongPressStart: (marker.useLongPress) ? _onLongPanStart : null,
onLongPressMoveUpdate: (marker.useLongPress) ? _onLongPanUpdate : null,
onLongPressEnd: (marker.useLongPress) ? _onLongPanEnd : null,
// user callbacks
onTap: () => marker.onTap?.call(markerPoint),
onLongPress: () => marker.onLongPress?.call(markerPoint),
Expand Down Expand Up @@ -118,23 +118,28 @@ class DragMarkerWidgetState extends State<DragMarkerWidget> {
offsetPosition = Offset(offset.dx - right, offset.dy - bottom);
}

void _start(Offset localPosition) {
bool _start(Offset localPosition) {
if (widget.marker.disableDrag) { return false; }
_isDragging = true;
_dragPosStart = _offsetToCrs(localPosition);
_markerPointStart = LatLng(markerPoint.latitude, markerPoint.longitude);
return true;
}

void _onPanStart(DragStartDetails details) {
_start(details.localPosition);
widget.marker.onDragStart?.call(details, markerPoint);
if (_start(details.localPosition)) {
widget.marker.onDragStart?.call(details, markerPoint);
}
}

void _onLongPanStart(LongPressStartDetails details) {
_start(details.localPosition);
widget.marker.onLongDragStart?.call(details, markerPoint);
if (_start(details.localPosition)) {
widget.marker.onLongDragStart?.call(details, markerPoint);
}
}

void _pan(Offset localPosition) {
if (!_isDragging) { return; }
final dragPos = _offsetToCrs(localPosition);

final deltaLat = dragPos.latitude - _dragPosStart.latitude;
Expand Down