AshesOfOwls / jquery.shapeshift

A dynamic grid system with drag and drop functionality.
http://ashesofowls.github.com/jquery.shapeshift/
MIT License
1.67k stars 311 forks source link

Stopping something from being dragged over #63

Open tm0054 opened 11 years ago

tm0054 commented 11 years ago

HI,

Sorry I already wrote this in a response to my message in the closed messages area. I'm a jquery newb so I know this is pretty basic stuff. Anyhow:

I'm combining a few things to attempt to get the results I am looking for . In some events I want the first object to always occupy the first spot. I don't want it to be able to be dragged or dragged over. In your docs I found a few commands that in description sound like they might help me achieve that goal:

            $(".container").shapeshift({
                handle: '.dragger',
                dragWhitelist: '.draggable',
                cutoffStart: 2
            });

This is the code I am using. The 'dragWhiteList' command works great. You can't drag the first item as it's not set to draggable.

cutoffStart sounds like what I would need in order to stop things from dragging over the first item, but I'm not sure if I am using it correctly. Anyhow, what I have there isn't stopping anything from dragging over the first item

AshesOfOwls commented 11 years ago

This kind of functionality was kind of a tack on rather than a feature I planned out (actually most of the plugin feels that way now heh). The cutoffstart is definitely what I think you are looking for but honestly I'm not sure if I tested it well enough.

This is my first public plugin so I haven't really developed a personal system to maintain it. I am currently working on version 3.0 though which is intended to be a much more polished 2.0, in which I will test out these features more. In order to spend more time on making 3.0 the best I can I have decided to abandon maintaining 2.0 and I'll add this feature to my 3.0 todo list and get back to you when I push it up to the branch.

appcuarium commented 10 years ago

Hi,

To enable this behavior:

  1. Under Plugin.prototype.setTargetPosition, line 515, set target_position variable to
    target_position = ( options.cutoffStart !== undefined && options.cutoffStart == 0 ) ? 1 : 0;
  2. Pass cutoffStart as option with value of 0
    $container.shapeshift({ cutoffStart: 0 });
    

You're good to go. Best regards.