Skip to content

Commit

Permalink
Merge pull request #27 from webtrix/feat/wrapDraggableElements
Browse files Browse the repository at this point in the history
added: new variable to be able to disable the default behavior of wrapping draggable elements
  • Loading branch information
sunpietro authored Nov 25, 2016
2 parents ff173d9 + 6dedcc8 commit dc107fe
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,13 @@ Tell the dragster to scroll window while dragging an element. Default value: `fa
The drag-only region CSS class name. Used to identify regions. Default value: `'dragster-region--drag-only'`.
### cloneElements - {Boolean}
The flag stating the elements can be cloned from region to region. Requires `dragOnlyRegionCssClass` to be applied in the HTML markup of a page. Default value: `false`.
### wrapDraggableElements - {Boolean}
By default all draggable elements are wrapped in a wrapper `<div>`, by settings this variable to `false` this behavior can be disabled. This can sometimes be useful when using the script in frameworks like Angular or such.

**IMPORTANT**

If you put this value to `false`, you **MUST** do the wrapping of the elements yourself.
A wrapper container looks like this `<div draggable="true" class="dragster-draggable"> ... </div>`

## Properties - callbacks
These properties allow a developer to control the behaviour of dragster.js library using callbacks.
Expand All @@ -139,4 +145,4 @@ After drop callback.
## Methods
List of methods ready to be used by any webdeveloper:
### update
Updates a reference to draggable elements. For example, when user adds a new element to any of droppable regions then running `update` method makes a new element draggable as well.
Updates a reference to draggable elements. For example, when user adds a new element to any of droppable regions then running `update` method makes a new element draggable as well.
14 changes: 13 additions & 1 deletion dragster.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@
onAfterDragDrop: dummyCallback,
scrollWindowOnDrag: FALSE,
dragOnlyRegionsEnabled: FALSE,
cloneElements: FALSE
cloneElements: FALSE,
wrapDraggableElements: TRUE
},
draggableAttrName = 'draggable',
placeholderAttrName = 'data-placeholder-position',
Expand Down Expand Up @@ -201,6 +202,17 @@
* @return {Array}
*/
wrapDraggableElements = function (elements) {
if (finalParams.wrapDraggableElements === FALSE) {
console.warn(
'You have disabled the default behavior of wrapping the draggable elements, ' +
'if you want dragster to work properly you still will have to do this manually.\n' +
'\n' +
'More inf: https://github.com/sunpietro/dragster/blob/master/README.md#user-content-wrapdraggableelements---boolean'
);

return FALSE;
}

elements.forEach(function (draggableElement) {
var wrapper = createElementWrapper(),
draggableParent = draggableElement.parentNode;
Expand Down
2 changes: 1 addition & 1 deletion dragster.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified dragster.min.js.gz
Binary file not shown.

0 comments on commit dc107fe

Please sign in to comment.