| | |
| | | document.onmousemove = function (e) { |
| | | e.preventDefault(); |
| | | window.getSelection().removeAllRanges(); |
| | | el.parentElement.style.left = e.clientX - disx + 'px'; |
| | | el.parentElement.style.top = e.clientY - disy + 'px'; |
| | | let toLeft = e.clientX - disx; |
| | | let toTop = e.clientY - disy; |
| | | //边界处理 |
| | | if(toLeft <= 0 ){ |
| | | toLeft = 0 |
| | | }else if(toLeft >= document.body.getBoundingClientRect().width-40){ |
| | | toLeft = document.body.getBoundingClientRect().width-40; |
| | | } |
| | | el.parentElement.style.left = toLeft + 'px'; |
| | | if(toTop <= 0 ){ |
| | | toTop = 0 |
| | | }else if(toTop >= document.body.getBoundingClientRect().height-40){ |
| | | toTop = document.body.getBoundingClientRect().height-40; |
| | | } |
| | | el.parentElement.style.top = toTop + 'px'; |
| | | }; |
| | | document.onmouseup = function () { |
| | | el.dragLock = false; |
| | |
| | | <style scoped> |
| | | html, |
| | | body { |
| | | heiht: 100%; |
| | | height: 100%; |
| | | } |
| | | .d-frame { |
| | | position: fixed; |