Как изменить иконку курсора когда перетаскиваем элемент по сайту?
сначала кликаем по тексту test появляется попап его можно перетаскивать
let prevX = 0;
let prevY = 0;
let app = Vue.createApp({
data: () => ({
helpShow: false,
}),
methods: {
openHelp() {
this.helpShow = !this.helpShow;
this.$nextTick(() => {
const halfDialogWidth = this.$refs.elemHelp.getBoundingClientRect().width / 2
const centerWindow = window.innerWidth / 2;
this.$refs.elemHelp.style.left = centerWindow - halfDialogWidth + 'px'
})
//document.body.classList.add("modal-open");
},
mousedown(e){
let prevX = e.clientX;
let prevY = e.clientY;
let mousemove = (e) => {
console.log('ttt');
let newX = prevX - e.clientX;
let newY = prevY - e.clientY;
const rect = this.$refs.elemHelp.getBoundingClientRect();
let x = rect.left - newX
let y = rect.top - newY
if (x < 0) x = 0
if (x > window.innerWidth - rect.width) x = window.innerWidth - rect.width
if (y < 0) y = 0
if (y > window.innerHeight - rect.height) y = window.innerHeight - rect.height
this.$refs.elemHelp.style.left = x + 'px';
this.$refs.elemHelp.style.top = y < 0 ? 0 : y + 'px';
prevX = e.clientX;
prevY = e.clientY;
}
let mouseup = (e) => {
window.removeEventListener('mousemove', mousemove);
window.removeEventListener('mouseup', mouseup);
}
window.addEventListener('mousemove', mousemove);
window.addEventListener('mouseup', mouseup);
},
}
})
app.mount('#app');
* {
margin: 0;
padding: 0;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
img {
width: 100px;
}
.help {
position: fixed;
left: 0;
top: 0;
right: 0;
bottom: 0;
display: flex;
flex-direction: column;
justify-content: center;
padding: 20px;
z-index: 15;
pointer-events: none;
}
.help .ps {
max-width: 896px;
width: 100%;
margin: 0 auto;
}
.help__wrap {
max-width: 496px;
width: 100%;
position: absolute;
background-color: #23262c;
border-radius: 12px;
padding: 40px 0px;
pointer-events: auto;
box-sizing: border-box;
}
.help__inner {
overflow-y: auto;
max-height: 80vh;
-webkit-overflow-scrolling: touch;
scrollbar-width: thin;
scrollbar-color: #555a66;
}
.help__inner::-webkit-scrollbar {
width: 8px;
height: 8px;
}
.help__inner::-webkit-scrollbar-track {
width: 8px;
height: 8px;
background-color: transparent;
}
.help__inner::-webkit-scrollbar-corner {
width: 8px;
height: 8px;
background-color: transparent;
}
.help__inner::-webkit-scrollbar-thumb {
width: 8px;
height: 8px;
border-radius: 4px;
background-color: rgba(220, 224, 232, 0.51);
}
.help__inner::-webkit-scrollbar-thumb:hover {
background-color: rgba(220, 224, 232, 0.8)
}
.help__inner::-webkit-scrollbar-track-piece {
background-color: transparent;
}
.help__drag {
position: absolute;
}
.help__holder {
padding-left: 80px;
}
.help__title {
font-size: 26px;
line-height: 1.2;
color: #f2f4f7;
padding-bottom: 30px;
font-weight: 600;
}
.help__row {
display: flex;
flex-wrap: wrap;
}
.help__item {
width: 50%;
}
.help__item:first-child {
padding-right: 20px;
}
.help__subtitle {
font-size: 15px;
line-height: 1.33;
color: #f2f4f7;
margin-bottom: 16px;
font-weight: 600;
}
.help__box {
width: max-content;
cursor: pointer;
display: flex;
align-items: center;
font-size: 13px;
color: #f2f4f7;
margin-bottom: 15px;
font-weight: 500;
}
.help__box i {
display: block;
font-size: 24px;
color: #757c8a;
margin-right: 8px;
}
.help__row{
color: #fff;
}
<div id="app">
<a @click.prevent="openHelp()" :class="{ open: helpShow }" style="color: red">test</a>
<div class="help" v-show="helpShow">
<div class="help__wrap" ref="elemHelp" @mousedown="mousedown">
<div class="help__inner">
<i class="icon icons-home"></i>
<div class="help__holder">
<div class="help__row">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Repudiandae nobis ipsum nam neque, omnis, voluptate tempore ipsa blanditiis nulla, iusto nemo eveniet voluptas perferendis debitis hic sequi id aliquam eligendi.</p>
</div>
</div>
</div>
</div>
</div>
</div>
<script src="https://unpkg.com/[email protected]/dist/vue.global.js"></script>