Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added: new variable to be able to disable the default behavior of wrapping draggable elements #27

Merged
merged 1 commit into from
Nov 25, 2016
Merged

added: new variable to be able to disable the default behavior of wrapping draggable elements #27

merged 1 commit into from
Nov 25, 2016

Conversation

maartentibau
Copy link
Contributor

Being able to disable this default behavior might come useful for some people (myself included). I'm using your script in an Angular 2 project, and I need to disable this feature to get everything working correctly.

So would be cool if we could add this feature if possible.

Copy link
Owner

@sunpietro sunpietro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're going in the right direction.
Maybe adding some console.warn with information that elements should be wrapped manually by a developer could be useful, what do you think?

elements.forEach(function (draggableElement) {
var wrapper = createElementWrapper(),
draggableParent = draggableElement.parentNode;
if (finalParams.wrapDraggableElements === TRUE) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would do it a different way.

wrapDraggableElements = function (elements) {
    if (finalParams.wrapDraggableElements === FALSE) {
        return FALSE;
    }
    
    elements.forEach(function (draggableElement) {
        var wrapper = createElementWrapper(),
            draggableParent = draggableElement.parentNode;

        if (draggableParent.classList.contains(CLASS_DRAGGABLE)) {
            return FALSE;
        }

        draggableParent.insertBefore(wrapper, draggableElement);
        draggableParent.removeChild(draggableElement);
        wrapper.appendChild(draggableElement);
    });
};

It avoids the indentation of huge block of code.

@maartentibau
Copy link
Contributor Author

Made the requested changes.

@@ -201,6 +202,17 @@
* @return {Array}
*/
wrapDraggableElements = function (elements) {
if (finalParams.wrapDraggableElements === TRUE) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

finalParams.wrapDraggableElements === FALSE

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OMG .. my bad .. sry

@maartentibau
Copy link
Contributor Author

Fixed

@sunpietro
Copy link
Owner

@Webtrix can you squash the commits into the one named: added: new variable to be able to disable the default behavior of wrapping draggable elements?

…pping

draggable elements

added: new variable to be able to disable the default behavior of wrapping
draggable elements

added: new variable to be able to disable the default behavior of wrapping
draggable elements
added: new variable to be able to disable the default behavior of wrapping
draggable elements

updated: made requested changes to PR

fixed: typo TRUE --> FALSE

typo: draggster --> dragster
@maartentibau
Copy link
Contributor Author

Took me some searching but this OK?

@sunpietro sunpietro merged commit dc107fe into sunpietro:master Nov 25, 2016
@maartentibau maartentibau deleted the feat/wrapDraggableElements branch November 25, 2016 08:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants