0

I have a grid of left floated (float:left) images and an user can drag any image and drop it in a 'droppable', the images after the dragged image fills the vacated space, but it's very abrupt, I would like to ease the movement of images a bit.

Is it possible with css transition ?

HTML

<section id="basket">

    <!--A sortable widget -jquery.ui-->
    <ul id="sortable">

    </ul>

</section>


<!--Main content - image grid-->
<section class="col s12">
    <figure class="left  draggable"> <img src="imges/1.jpg' ?>"> </figure>
    <figure class="left  draggable"> <img src="imges/1.jpg' ?>"> </figure>
    <figure class="left  draggable"> <img src="imges/1.jpg' ?>"> </figure>
    <figure class="left  draggable"> <img src="imges/1.jpg' ?>"> </figure>
    <figure class="left  draggable"> <img src="imges/1.jpg' ?>"> </figure>
    <figure class="left  draggable"> <img src="imges/1.jpg' ?>"> </figure>
</section>
<!--Main content - image grid end-->

CSS

.left {
    float: left !important;
}

#basket {
    position: fixed;
    left: 20px;
    top: 10%;

    width: 200px;
    Height: 200px;
    border: 1px solid #B0B5BF;
    background-color: #FFF;

}

Javascript

$( document ).ready ( function (  ) {

    $ ( "#sortable" ).sortable (  );

    $ ( ".draggable" ).draggable ( {

        revert : "invalid", cursor: "grabbing" 

    } );

    $ (  "#basket" ).droppable ( {

        drop: function ( event, ui ) {

            var $sortable = $ ( this ).children (  )[0];
            ui.draggable.detach (  ).appendTo (  $( '<li></li>' ).appendTo( $sortable )  );

        },
        activeClass: "z-depth-1"

    } );

} );

So, for example if I remove the <figure class="left draggable"> <img src="imges/1.jpg' ?>"> </figure> by draggin it to the #basket and jQuery.detach() then the remaining <figure> should ease in to their respective new positions. Since all the <figure> are floated elements, I think simple transition isn't working.

Sato
  • 433
  • 4
  • 13
StudentX
  • 2,243
  • 6
  • 35
  • 67
  • 4
    Include example code... What have you tried? – 099 Aug 25 '15 at 07:59
  • 2
    possible duplicate of [JQuery draggable with ease](http://stackoverflow.com/questions/6398854/jquery-draggable-with-ease) – Pixelomo Aug 25 '15 at 08:30
  • @Totoro no it's not duplicate, I did my homework :/ – StudentX Aug 25 '15 at 08:37
  • @StudentX In what way is it not a duplicate, other than the implementation via jQuery vs CSS? – TylerH Aug 26 '15 at 21:38
  • @TylerH The suggested question is about the element which is being dragged whereas my question is about the remaining elements in the group of draggables. I have explained what exactly I am looking for at the end of the question, please read the whole question again. Moreover the suggested question is way too old and the asked requirements are now supported natively by JQuery UI. – StudentX Aug 27 '15 at 10:31

0 Answers0