Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <link href="https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css" rel="stylesheet">
<script src="https://unpkg.com/selectable.js@latest/selectable.min.js"></script>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<style>


#wrap {
  position: relative;
  height: 1000px;
  width: 100%;
  overflow:hidden;
}

#objects {
  position: fixed;
  bottom:0px;
  overflow:auto;
}

.droppable-wrap {
  position:relative;
  overflow:auto;
  overflow-y:hidden;
  width:100%;
  white-space: nowrap
}
.object-wrap {
  position:absolute;
}

#area {
  background-color:yellow;
  background-position: 0px 0px;
  padding: 0 10px;
  width: 100%;
  height: 500px;
  transform-origin: 50% 50% 0px;
  overflow:scroll;
}

.badge {
  position: absolute;
  width:15px;
  height:15px;
  background-color:black;
  bottom:0px;
  right:0px;
  border-radius: 50%;
}

.category {
  position: absolute;
  width:15px;
  height:15px;
  bottom:0px;
  left:0px;
  border-radius: 50%;
}
.border1 {
  border-left:5px solid red;
}
.border2 {
  border-left:5px solid blue;
}
.border3 {
  border-left:5px solid violet;
}
.border4 {
  border-left:5px solid green;
}
.cat1 {
  background-color:red;
}
.cat2 {
  background-color:blue;
}
.cat3 {
  background-color:violet;
}
.cat4 {
  background-color:green;
}
.opacity02 {
  opacity: 0.1;
}
.umbrella-name {
  position: absolute;
  top: 20px;
  width: 80px;
  left: 5px;
  font-size: 6px;
  background-color: white;
  padding:1px 5px;
  width:40px;
  border-radius: 5px;
}

.umbrella-code {  
  position: absolute;
  top: 3px;
  width: 30px;
  left: 9px;
  font-size: 8px;
  font-weight: bold;
  background-color: white;
  padding:1px 5px;
  border-radius: 5px;
}

.obj,
.noobject {
  width: 50px;
  height: 50px;
  position: absolute;
  font-size: 10px;
  text-align: center;
  cursor: pointer !important;
  background-repeat: no-repeat !important;
  background-color:red;
  border-radius:50%;
}

.droppable, .object-group {
  width: 50px;
  height: 50px;
  cursor: pointer;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  display:inline-block;
  margin-right:20px;
}
   
.resize-handle {
  position: absolute;
  width: 0px;
  height: 0px;
  margin-top: -17px;
  margin-left: -17px;
  border-style: solid;
  border-width: 0 0 16px 16px;
  border-color: transparent transparent #AAA transparent;
  cursor: nw-resize !important;
}

.ui-selectable-helper {
  border: 0px dotted darkgrey !important;
  z-index: 9999;
  position: absolute;
}

  </style>
<div class="w-full  mt-0 pt-3 mb-5 md:pb-0">
      

<script src="https://cdnjs.cloudflare.com/ajax/libs/dat-gui/0.6.5/dat.gui.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/1.18.2/TweenMax.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.8.0/gsap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.8.0/Draggable.min.js"></script>

<style>
    .ui-selecting {
      border: 3px solid green;
      background-color: lightblue !important;
    }

    .ui-selected {
      border: 3px dotted white;
      color:blue !important;
      background-color:white !important;
    }

    .range-selecting {
      background: yellow;
    }

    .drag-handle {
      border: 2px solid red;
    }
  </style>


<div class="bg-white border rounded">

  

  <div id="wrap">
    <div id="area">
      
      
      <div class="object obj filter104" id="id3057" data-id="3057" style="left:100px;top:0px;width:50px;height:50px" data-code="33L" data-color="" data-category="0">
        <div class="umbrella-code">33L</div>
      </div>
      <div class="object obj filter101" id="id3058" data-id="3058" style="left:100px;top:50px;width:50px;height:50px" data-code="33M" data-color="" data-category="0">
        <div class="umbrella-code">33M</div>
      </div>
      <div class="object obj filter102" id="id3059" data-id="3059" style="left:100px;top:100px;width:50px;height:50px" data-code="33N" data-color="" data-category="0">
        <div class="umbrella-code">33N</div>
      </div>
      <div class="object obj filter103" id="id3060" data-id="3060" style="left:100px;top:150px;width:50px;height:50px" data-code="33O" data-color="" data-category="0">
        <div class="umbrella-code">33O</div>
      </div>
      <div class="object obj filter104" id="id3063" data-id="3063" style="left:100px;top:200px;width:50px;height:50px" data-code="33R" data-color="" data-category="0">
        <div class="umbrella-code">33R</div>
      </div>
      <div class="object obj filter101" id="id3098" data-id="3098" style="left:100px;top:250px;width:50px;height:50px" data-code="" data-color="" data-category="12">
        <div class="umbrella-code"></div>
      </div>
      <div class="object obj filter102" id="id3099" data-id="3099" style="left:100px;top:300px;width:50px;height:50px" data-code="" data-color="" data-category="12">
        <div class="umbrella-code"></div>
    
      </div>
      <div class="object obj filter103" id="id3100" data-id="3100" style="left:100px;top:350px;width:50px;height:50px" data-code="" data-color="" data-category="12">
        <div class="umbrella-code"></div>
      
      </div>
    </div>

    <div id="threshold">
      <div class="threshold"></div>
      <div class="threshold"></div>
    </div>
  </div>
</div>


<script>
   
    var gridWidth = 25, gridHeight = 25;
    var drag;

    
   

    const elem = document.getElementById('area')
    var grid_size = 25, object_size = 20;

   
    var selectable;
    var moving = '';
    var drag, resize;
    var selected = 0;
    
    var container = document.getElementById("area");
    var rect = container.getBoundingClientRect();
    //var boxes = [].slice.call(container.getElementsByClassName(".object"));
    var filter = "selectable";
    var currentLeft = 0,currentTop = 0;
  
  
    function selecte() {
      selectable = new Selectable({
        filter: ".object",
        ignore: ".noobject",
        saveState: false,
        tolerance: "touch",
        lassoSelect: "normal",
        toggle: false,
        autoRefresh: true
      });

      $(".object").addClass('ui-selectable');
      
      selectable.on("end", function (e, selected, unselected) {
        if (Array.isArray(drag)) {

          drag.forEach(function (i, v) {
          i.update();
          i.kill();
          });

        }

       
        $(".object.ui-selected").removeClass('object highlight drag-handle').addClass('noobject');
        var $first = $(".ui-selected").first();
        $first.addClass('drag-handle');


        if (selected.length == 1) {

          $first.append('<div class="resize-handle"></div>');
          TweenLite.set($(".resize-handle"), { top: $(".noobject").width(), left: $(".noobject").height() });

        
          resize = Draggable.create('.resize-handle', {
            type: "top,left",
            liveSnap: true,
            snap: {
              x: function (endValue) {
                return Math.round(endValue / gridWidth) * gridWidth;
              },
              y: function (endValue) {
                return Math.round(endValue / gridHeight) * gridHeight;
              }
            },
            onPress: function (e) {
              e.stopPropagation(); // cancel drag
            },
            onDrag: function (e) {
              TweenLite.set(this.target.parentNode, { width: this.x, height: this.y });
            },
            onRelease: function (e) {

              $(".resize-handle").remove();
              $(".noobject,.object").removeClass('noobject drag-handle ui-selected').addClass('object');
              this.kill();

              drag.forEach(function (i, v) {
                console.log(i);
                i.disable();
              });
              
            }
          });

        } // end num == 1

        drag = Draggable.create($first, {
          bounds: "#area",
          onRelease: function (e) {

            $(".noobject").each(function () {
              var left = $(this).css('left').replace('px','');
              var top = $(this).css('top').replace('px','');
  
              var trans = $(this).css('transform').replace(/[^0-9\-.,]/g, '').split(',');
              $(this).css('transform','translate3d(0,0,0)');
                            
              $(this).css({'left': (parseInt(left) + parseInt(trans[4])) +'px','top': (parseInt(top) + parseInt(trans[5])) +'px'});
            });


            $(".noobject").removeClass('ui-selected noobject drag-handle').addClass('object');
            $(".resize-handle").remove();

            if (Array.isArray(resize)) {
            resize.forEach(function (i, v) {
              i.kill();
            });
            }
            
            drag.forEach(function (i, v) {
              i.update();
              i.kill();
            });

            
          },
          onPressInit: function (e) {
    
            var trans = $(this.target).css('transform').replace(/[^0-9\-.,]/g, '').split(',');
            currentLeft = parseInt(trans[4]);
            currentTop = parseInt(trans[5]);

            if (!currentTop) currentTop = 0;
            if (!currentLeft) currentLeft = 0;
          },
          onDrag: function (e) {
            var that = this;
            var trans = [0,0,0,0,0,0];
            $(".ui-selected").not('.drag-handle').each(function () {
              trans = $(this).css('transform').replace(/[^0-9\-.,]/g, '').split(',');
              console.log(currentLeft,that.x);
              trans[4] = 0;
              trans[5] = 0;
              $(this).css('transform','translate3d('+(that.x - currentLeft)+'px,'+(that.y - currentTop)+'px,0px)')
            })
          },
          liveSnap: true,
          snap: {
            x: function (endValue) {
              return Math.round(endValue / gridWidth) * gridWidth;
            },
            y: function (endValue) {
              return Math.round(endValue / gridHeight) * gridHeight;
            }
          }
        });
      }); // selectable end
    }
    
    
    
    



    var overlapThreshold = "99%";
    $(function () {
      selecte();
      
    });

   
  </script>
    </div>
              
            
!

CSS

              
                
              
            
!

JS

              
                
              
            
!
999px

Console