drag_handler 1.0.0

drag_handler #

drag_handler is a dart library to simplify the management of mouse dragging state. An instance of the DragHandler class maintains a set of DOM elements and monitors them for mouse events.

Usage #

To use this library in your code :

  • add a dependency in your pubspec.yaml :

    dependencies:
    drag_handler: ">=0.1.1 <1.0.0"
    

* add import in your `dart` code :

    ```dart
import 'package:drag_handler/drag_handler.dart';
  • create a DragHandler

    var dh = new DragHandler();
    

* add a target

    ```dart
dh.addTarget(querySelector('#drag-element'));
  • listen for drag events

    1. Drag start: when the user mouses down on a DOM element added to the DragHandler and begins to move the mouse.
      dh.onDragStart.listen((DragEvent e) => print('Started dragging on element ${e.element}'));
    
    1. Drag: each time the user moves the mouse during a drag
      dh.onDrag.listen((DragEvent e) => print('Still dragging ${e.element}'));
    
    1. Drag out: when the user moves the mouse out of an element in the DragHandler.
      dh.onDragOut.listen((DragEvent e) => print('Started drag on ${e.element}, dragging out of ${e.other}'));
    
    1. Drag over: when the user moves the mouse into an element in the DragHandler
      dh.onDragOver.listen((DragEvent e) => print('Started drag on ${e.element}, dragging over ${e.other}'));
    
    1. Drag end: when the user mouses up during a drag
      dh.onDragEnd.listen((DragEvent e) => print('Finished dragging ${e.element}'));
    
  • selectively add targets

    If you want to know if a drag operation enters or leaves an element, but you don't want to watch for drags that start on that element, you can specify those events when adding the target:

    dh.addTarget(querySelector("#drag-target"), drag: false, over: true, out: true);
    

* temporarily disable a DragHandler

    ```dart
dh.enabled = false;
  • define conditions in which drags may begin

    // don't react to mouse drags when application is loading
    dh.dragConditions = (DragHandler dh, Element e, MouseEvent me) => application_state == ApplicationState.LOADING;
    

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  drag_handler: ^1.0.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:drag_handler/drag_handler.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
81
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
58
Overall:
Weighted score of the above. [more]
36
Learn more about scoring.

We analyzed this package on Jul 9, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.13

Analysis suggestions

Package not compatible with runtime flutter-native on android

Because of the import of dart:html via the import chain package:drag_handler/drag_handler.dartdart:html

Package not compatible with runtime flutter-native on ios

Because of the import of dart:html via the import chain package:drag_handler/drag_handler.dartdart:html

Package not compatible with runtime flutter-native on linux

Because of the import of dart:html via the import chain package:drag_handler/drag_handler.dartdart:html

Package not compatible with runtime flutter-native on macos

Because of the import of dart:html via the import chain package:drag_handler/drag_handler.dartdart:html

Package not compatible with runtime flutter-native on windows

Because of the import of dart:html via the import chain package:drag_handler/drag_handler.dartdart:html

Package not compatible with runtime native-aot

Because of the import of dart:html via the import chain package:drag_handler/drag_handler.dartdart:html

Package not compatible with runtime native-jit

Because of the import of dart:html via the import chain package:drag_handler/drag_handler.dartdart:html

Health suggestions

Fix lib/drag_handler.dart. (-18.58 points)

Analysis of lib/drag_handler.dart reported 41 hints, including:

line 37 col 15: Don't type annotate initializing formals.

line 37 col 45: Don't type annotate initializing formals.

line 37 col 67: Don't type annotate initializing formals.

line 37 col 96: Don't type annotate initializing formals.

line 98 col 26: Unnecessary new keyword.

Maintenance issues and suggestions

Provide a file named CHANGELOG.md. (-20 points)

Changelog entries help developers follow the progress of your package. See the example generated by stagehand.

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and drag_handler.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

The package description is too short. (-7 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Documentation URL is insecure. (-5 points)

Update the documentation field and use a secure (https) URL.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
logging >=0.9.0 <1.0.0 0.11.4