MCPcopy Create free account
hub / github.com/MankaiHuang/screen-visualization / onDrop

Function onDrop

src/components/Workspace/Layer/index.jsx:159–182  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

157 }
158 }
159 function onDrop (e) {
160 const dragElement = document.getElementById(dragId)
161 const moveOffsetTop = dragElement.offsetTop + 70 // 当前拖拽离顶部的高度
162 let step = 0
163 if (e.pageY - moveOffsetTop > 0) {
164 // 下移
165 step = 70
166 } else {
167 step = 40
168 }
169 _css(dragElement, 'will-change', `transform`); // 增加动画
170 _css(dragElement, 'transition', `all ${300}ms`);
171 _css(dragElement, 'transform', `translate3d(0,${e.pageY - moveOffsetTop}px,0)`);
172 const dropGroupId = e.currentTarget.dataset.groupid // 拖入的groupId
173 const targetId = e.target.dataset.id || e.target.parentElement.dataset.id
174 setTimeout(() => {
175 _css(dragElement, 'transition', `none`);
176 _css(dragElement, 'transform', `translate3d(0,0,0)`); // 清除动画属性
177 _css(dragElement, 'will-change', `auto`);
178 props.onPropertyChange({ templateId: dragId, groupId: dropGroupId, targetId }, 'layer', 'updateLayer')
179 }, 300);
180 e.stopPropagation() // 阻止事件冒泡 因为是树结构 不阻止会调用父级的事件
181
182 }
183 function onDrag (e) {
184 setDragId(e.currentTarget.dataset.id)
185 }

Callers

nothing calls this directly

Calls 2

_cssFunction · 0.85
setTimeoutFunction · 0.85

Tested by

no test coverage detected