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

Draggable attribute to disable/enable draggabilly #11

Closed
dotlouis opened this issue Feb 8, 2015 · 1 comment
Closed

Draggable attribute to disable/enable draggabilly #11

dotlouis opened this issue Feb 8, 2015 · 1 comment

Comments

@dotlouis
Copy link

dotlouis commented Feb 8, 2015

Hi, first of thanks for this module, it's really useful to me.
Anyway I was wondering if the attribute draggable is meant to be used ?
It isn't mentioned in the ReadMe however I looked at the source and found that a draggable attribute is provided for the directive. I tried to set it to false but nothing happened.

I would like to do something like this:
<packery draggable="{{isDrag}}"> with isDrag being a variable in my controller.
Basically I just want to enable and disable drag and drop with a click of a button.

Then I found this line: https://github.com/SunGard-Labs/angular-packery/blob/master/src/packery.js#L195
The problem is that scope.draggable will always be true either because of the config boolean or because any variable set in scope.draggable will be a string therefore true.

Anyway after doing a little type check:

if(typeof scope.draggable === "string")
  scope.draggable = (scope.draggable === "true");

I managed to disable drag at launch. But if I change isDrag later for example with a click of a button, of course the draggability won't update.

Is it possible to add this behaviour ? There is a method to enable/disable drag in the Draggabillly module.

@joshuahiggins
Copy link
Contributor

Yes, draggable is meant to be used. This actually mimics an issue, #7, that was discovered earlier but I missed that draggable had the same problem.

As for disabling Draggabilly on the fly, I don't think the library should be responsible for this functionality since Draggabilly offers destroy, disable, and enable methods already. Instead of building that functionality into angular-packery, I think exposing the Draggabilly object to the user would be a better method. Then you can build in a function to toggle the enable and disable methods that are already available.

I've created the following issues to address both of the above:
#12 - Fix issue with draggable
#13 - Expose Draggabilly object

I'm going to close this issue. Please reference the new issue for the individual workstreams.

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

No branches or pull requests

2 participants