Skip to content

Latest commit

 

History

History
 
 

ResizeMirror

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

ResizeMirror

The ResizeMirror plugin resizes the mirror element to the dimensions of the draggable element that the mirror is hovering over.

It will also appends the mirror element to whatever draggable container element the mirror is hovering over. You can add transitions to the mirror element to animate the resizing.

This plugin is not included in the default Draggable bundle, so you'll need to import it separately.

grid-mirror-resize

Example of ResizeMirror in action. Custom transitions are applied via CSS (not provided by the plugin)Grid Layout Example

Usage

  • ES6:
import { Draggable, Plugins } from "@shopify/draggable";
// Or
// import Draggable from '@shopify/draggable/lib/draggable';
// import ResizeMirror from '@shopify/draggable/lib/plugins/resize-mirror';

const draggable = new Draggable(document.querySelectorAll('ul'), {
  draggable: 'li',
  plugins: [Plugins.ResizeMirror] // Or [ResizeMirror]
});
  • Browser (All bundle):
<script src="https://cdn.jsdelivr.net/npm/@shopify/[email protected]/lib/draggable.bundle.js"></script>
<script>
    const draggable = new Draggable.Draggable(document.querySelectorAll('ul'), {
      draggable: 'li',
      plugins: [Draggable.Plugins.ResizeMirror]
    });
</script>
  • Browser (Standalone):
<script src="https://cdn.jsdelivr.net/npm/@shopify/[email protected]/lib/draggable.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@shopify/[email protected]/lib/plugins/resize-mirror.js"></script>
<script>
    const draggable = new Draggable.default(document.querySelectorAll('ul'), {
      draggable: 'li',
      plugins: [ResizeMirror.default]
    });
</script>

API

new ResizeMirror(draggable: Draggable): ResizeMirror Creates an instance of the ResizeMirror plugin.

Options

No options

Examples

import { Sortable, Plugins } from '@shopify/draggable';

const sortable = new Sortable(document.querySelectorAll('ul'), {
  draggable: 'li',
  plugins: [Plugins.ResizeMirror]
});

Caveats

  • The mirror is not re-positioned under the cursor once resized, i.e. if the mirror shrinks/expands the mirror may no longer be directly beneath the cursor