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
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,14 @@ Use the axis attribute to lock the dragging to a specific axis. By default, both
Use the onDragStart and onDragEnd events to call functions whenever the dragging starts or stops
```html
<!-- Calls a function on start and stop -->
<div drag-scroll onDragStart="handleDragStart()" onDragEnd="handleDragEnd()">
<div drag-scroll on-drag-start="handleDragStart()" on-drag-end="handleDragEnd()">
```

### Other attributes
Use dragScrollExcludedClasses to exclude drag scrolling for elements having certain classes. Class names should be separated using comma.
```html
<div drag-scroll="true" drag-scroll-excluded-classes="form-control,some-other-class"></div>
```

## Credits / Inspiration
* https://github.com/asvd/dragscroll
Expand Down
14 changes: 6 additions & 8 deletions src/ng-drag-scroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
//<div drag-scroll>Lorem ipsum dolor sit amet</div>
var directive = {
restrict: 'A',
link: function($scope, $element, $attributes, vm) {
link: function($scope, $element, $attributes) {
var enabled = true;
var allowedClickOffset = 5;
var pushed = false;
Expand All @@ -30,12 +30,6 @@
enabled = newValue !== undefined ? newValue : true;
});

// Set event listeners
$element.on('mousedown', handleMouseDown);

// Set destroy listener
$scope.$on('$destroy', destroy);

/**
* Sets the event listeners for the mouseup and mousedown events
*/
Expand All @@ -60,7 +54,7 @@
if(enabled){
for (var i= 0; i<excludedClasses.length; i++) {
if (angular.element(e.target).hasClass(excludedClasses[i])) {
return false;
return true;
}
}

Expand Down Expand Up @@ -172,7 +166,11 @@
}
}

// Set event listeners
$element.on('mousedown', handleMouseDown);

// Set destroy listener
$scope.$on('$destroy', destroy);
}
};
return directive;
Expand Down