跨浏览器 GRAB 游标(-moz、-webkit)
Crossbrowser GRAB cursor (-moz, -webkit)
我正在尝试自定义光标的行为。现在它以另一种方式工作:在我使用的 mousemove 上:
scheme.setAttribute("cursor", "move");
鼠标抬起:
scheme.setAttribute("cursor", "auto");
在这种情况下:
scheme.setAttribute("cursor", "-moz-grab");
scheme.setAttribute("cursor", "-webkit-grab");
光标仅适用于 -webkit(Chrome).
虽然这种情况
scheme.setAttribute("cursor", "-webkit-grab");
scheme.setAttribute("cursor", "-moz-grab");
光标仅适用于 -moz(FF).
以下结构没有像我预期的那样工作:
scheme.setAttribute("cursor", "-moz-grab, -webkit-grab");
这个有效:
scheme.setAttribute("style", "cursor:-moz-grab; cursor:-webkit-grab;");
在这两种浏览器中,但我read here认为这是不好的做法。
密码here works but I need to use a structure like this and that.
类似于this(该结构现在不起作用)。
编辑 1
从这个other Stack Overflow post:
解决方案使用:
scheme.setAttribute("cursor", "url(http://www.google.com/intl/en_ALL/mapfiles/openhand.cur) 4 4, move");
适用于两种浏览器,但仍需要使用 -moz-grab
和 -webkit-grab
值的解决方案。
而且它在 IE 中似乎不起作用(我希望看到第二个,保留移动图标)
编辑 2
更清晰,mousedown/mouseup示例:
Case 1:(仅适用 Chrome)
Case 2:(这里mousedown没有变化)
根据J.Steve的回答:
.grabbable {
cursor: move; /* fallback if grab cursor is unsupported */
cursor: grab;
cursor: -moz-grab;
cursor: -webkit-grab;
}
/* (Optional) Apply a "closed-hand" cursor during drag operation. */
.grabbable:active {
cursor: grabbing;
cursor: -moz-grabbing;
cursor: -webkit-grabbing;
}
从这里开始CSS for grabbing cursors (drag & drop)
还有这个评论
您确定逗号列表仍然有效吗?我正在使用 cursor:move;
光标:-webkit-抓取;光标:-moz-grab; cursor:grab;与大多数
首选最后
如果您指定多种格式,则逗号列表有效
光标:url(example.svg#linkcursor),url(hyper.cur),指针
在我的例子中,我设置了 CCS 选项
item.setAttribute("style", "cursor: move; cursor: grab; cursor:-moz-grab; cursor:-webkit-grab;");
并通过
取消设置
item.setAttribute("style", "cursor: auto;");
在我的取消事件(鼠标弹起)之后。
JS:
var item = document.getElementById("changeCurArea");
item.addEventListener("mousedown", func, false);
item.addEventListener("mouseup", func1, false);
function func() {
item.setAttribute("style", "cursor: move; cursor: grab; cursor:-moz-grab; cursor:-webkit-grab;");
}
function func1() {
// item.setAttribute("cursor", "auto");
item.setAttribute("style", "cursor: auto;");
}
HTML:
<svg xmlns="http://www.w3.org/2000/svg" width="400" height="350" viewBox="200 150">
<rect id="mySvgArea" width="400" height="350" stroke="black" fill="lightgrey"></rect>
<rect id="changeCurArea" x="100" y="100" width="200" height="150" stroke="red" fill="pink"></rect>
</svg>
我正在尝试自定义光标的行为。现在它以另一种方式工作:在我使用的 mousemove 上:
scheme.setAttribute("cursor", "move");
鼠标抬起:
scheme.setAttribute("cursor", "auto");
在这种情况下:
scheme.setAttribute("cursor", "-moz-grab");
scheme.setAttribute("cursor", "-webkit-grab");
光标仅适用于 -webkit(Chrome).
虽然这种情况
scheme.setAttribute("cursor", "-webkit-grab");
scheme.setAttribute("cursor", "-moz-grab");
光标仅适用于 -moz(FF).
以下结构没有像我预期的那样工作:
scheme.setAttribute("cursor", "-moz-grab, -webkit-grab");
这个有效:
scheme.setAttribute("style", "cursor:-moz-grab; cursor:-webkit-grab;");
在这两种浏览器中,但我read here认为这是不好的做法。
密码here works but I need to use a structure like this and that.
类似于this(该结构现在不起作用)。
编辑 1
从这个other Stack Overflow post:
解决方案使用:
scheme.setAttribute("cursor", "url(http://www.google.com/intl/en_ALL/mapfiles/openhand.cur) 4 4, move");
适用于两种浏览器,但仍需要使用 -moz-grab
和 -webkit-grab
值的解决方案。
而且它在 IE 中似乎不起作用(我希望看到第二个,保留移动图标)
编辑 2
更清晰,mousedown/mouseup示例:
Case 1:(仅适用 Chrome)
Case 2:(这里mousedown没有变化)
根据J.Steve的回答:
.grabbable {
cursor: move; /* fallback if grab cursor is unsupported */
cursor: grab;
cursor: -moz-grab;
cursor: -webkit-grab;
}
/* (Optional) Apply a "closed-hand" cursor during drag operation. */
.grabbable:active {
cursor: grabbing;
cursor: -moz-grabbing;
cursor: -webkit-grabbing;
}
从这里开始CSS for grabbing cursors (drag & drop) 还有这个评论
您确定逗号列表仍然有效吗?我正在使用 cursor:move; 光标:-webkit-抓取;光标:-moz-grab; cursor:grab;与大多数 首选最后
如果您指定多种格式,则逗号列表有效 光标:url(example.svg#linkcursor),url(hyper.cur),指针
在我的例子中,我设置了 CCS 选项
item.setAttribute("style", "cursor: move; cursor: grab; cursor:-moz-grab; cursor:-webkit-grab;");
并通过
取消设置item.setAttribute("style", "cursor: auto;");
在我的取消事件(鼠标弹起)之后。
JS:
var item = document.getElementById("changeCurArea");
item.addEventListener("mousedown", func, false);
item.addEventListener("mouseup", func1, false);
function func() {
item.setAttribute("style", "cursor: move; cursor: grab; cursor:-moz-grab; cursor:-webkit-grab;");
}
function func1() {
// item.setAttribute("cursor", "auto");
item.setAttribute("style", "cursor: auto;");
}
HTML:
<svg xmlns="http://www.w3.org/2000/svg" width="400" height="350" viewBox="200 150">
<rect id="mySvgArea" width="400" height="350" stroke="black" fill="lightgrey"></rect>
<rect id="changeCurArea" x="100" y="100" width="200" height="150" stroke="red" fill="pink"></rect>
</svg>