@chasi/ui
Advanced tools
Comparing version 0.2.80 to 0.2.81
@@ -1,26 +0,2 @@ | ||
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, { onStart, onMove, onEnd, handlerSelector }) { | ||
@@ -67,3 +43,9 @@ let ghostElement = null; | ||
const clone = node.cloneNode(true); | ||
clone.classList.add('ghost'); | ||
clone.style.position = 'fixed'; | ||
clone.style.top = '0'; | ||
clone.style.left = '0'; | ||
clone.style.pointerEvents = 'none'; | ||
clone.style.transition = 'none'; | ||
clone.style.zIndex = '9999'; | ||
clone.style.boxShadow = 'var(--shadow-4)'; | ||
clone.style.width = `${width}px`; | ||
@@ -75,3 +57,6 @@ clone.style.height = `${height}px`; | ||
document.body.append(clone); | ||
node.classList.add('dragged'); | ||
node.style.opacity = '0'; | ||
node.style.transition = 'none'; | ||
node.style.animation = 'none'; | ||
node.style.pointerEvents = 'none'; | ||
return { | ||
@@ -89,3 +74,6 @@ update(dx, dy) { | ||
clone.remove(); | ||
node.classList.remove('dragged'); | ||
node.style.opacity = ''; | ||
node.style.transition = ''; | ||
node.style.animation = ''; | ||
node.style.pointerEvents = ''; | ||
}, duration); | ||
@@ -92,0 +80,0 @@ } |
{ | ||
"name": "@chasi/ui", | ||
"version": "0.2.80", | ||
"version": "0.2.81", | ||
"bin": { | ||
@@ -5,0 +5,0 @@ "gen-theme": "./dist/bin/theme.js" |
109135
1179