@chasi/ui
Advanced tools
Comparing version 0.2.71 to 0.2.72
@@ -0,6 +1,30 @@ | ||
import { BROWSER } from 'esm-env'; | ||
import pannable from './pannable.js'; | ||
if (BROWSER) { | ||
if (!document.querySelector('#draggable-styles')) { | ||
const style = document.createElement('style'); | ||
style.setAttribute('id', 'draggable-styles'); | ||
style.innerHTML = ` | ||
[data-draggable-item].ghost { | ||
position: fixed; | ||
top: 0; | ||
left: 0; | ||
pointer-events: none; | ||
transition: none; | ||
z-index: 9999; | ||
box-shadow: var(--shadow-4); | ||
} | ||
:where([data-draggable-item].dragged) { | ||
opacity: 0; | ||
transition: none !important; | ||
animation: none !important; | ||
pointer-events: none; | ||
}`; | ||
document.getElementsByTagName('head')[0].appendChild(style); | ||
} | ||
} | ||
export default function (node, { onDrop, onMove, onStart, handlerSelector, duration = 250 }) { | ||
let ghostElement = null; | ||
createStyles(); | ||
const handler = handlerSelector ? node.querySelector(handlerSelector) : node; | ||
node.setAttribute('data-draggable-item', ''); | ||
return pannable(node, { | ||
@@ -62,24 +86,1 @@ onStart(e, coords) { | ||
} | ||
function createStyles() { | ||
if (!document.querySelector('#draggable-styles')) { | ||
const style = document.createElement('style'); | ||
style.setAttribute('id', 'draggable-styles'); | ||
style.innerHTML = ` | ||
.ghost { | ||
position: fixed; | ||
top: 0; | ||
left: 0; | ||
pointer-events: none; | ||
transition: none; | ||
z-index: 9999; | ||
box-shadow: var(--shadow-4); | ||
} | ||
.dragged { | ||
opacity: 0.5; | ||
transition: none !important; | ||
animation: none !important; | ||
pointer-events: none; | ||
}`; | ||
document.getElementsByTagName('head')[0].appendChild(style); | ||
} | ||
} |
{ | ||
"name": "@chasi/ui", | ||
"version": "0.2.71", | ||
"version": "0.2.72", | ||
"bin": { | ||
@@ -5,0 +5,0 @@ "gen-theme": "./dist/bin/theme.js" |
109357
1180