На данный момент у меня есть следующий код...
- Я обнаружил пользовательский значок
- Я заменяю этот значок локальным, добавляя свойство в заголовок
Есть ли лучший подход достичь своей цели?
let custom_cursor_a = 'url("https://ssl.gstatic.com/ui/v1/icons/mai ... enhand.cur") 7 5, default';
let custom_cursor_b = 'url("https://ssl.gstatic.com/ui/v1/icons/mai ... edhand.cur") 7 5, move';
document.addEventListener('mouseover',function(e){
var cursor = getComputedStyle(e.target).cursor;
//console.log(cursor);
const cursorStyle = document.createElement('style');
cursorStyle.id = 'cursor-style';
if (cursor == custom_cursor_a) {
console.log("custom_cursor_a");
cursorStyle.innerHTML = '* {cursor: -webkit-grab !important; cursor: -moz-grab !important; cursor: -o-grab !important; cursor: -ms-grab !important; cursor: grab !important}';
document.head.appendChild(cursorStyle);
} else {
if (cursor == custom_cursor_b) {
console.log("custom_cursor_b");
cursorStyle.innerHTML = '* {cursor: -webkit-grabbing !important; cursor: -moz-grabbing !important; cursor: -o-grabbing !important; cursor: -ms-grabbing !important; cursor: grabbing !important;}';
document.head.appendChild(cursorStyle);
} else {
console.log(cursor);
if (document.getElementById('cursor-style')) { document.getElementById('cursor-style').remove(); }
}
}
});
Подробнее здесь: https://stackoverflow.com/questions/792 ... d-chromium
Мобильная версия