long press arrow

This commit is contained in:
oc 2019-06-02 14:49:54 +08:00
parent 718852b9ef
commit ddac388dd0
2 changed files with 55 additions and 17 deletions

View File

@ -760,10 +760,31 @@ editor.constructor.prototype.listen=function () {
} }
var viewportButtons=document.getElementById('viewportButtons'); var viewportButtons=document.getElementById('viewportButtons');
var pressTimer = null;
for(var ii=0,node;node=viewportButtons.children[ii];ii++){ for(var ii=0,node;node=viewportButtons.children[ii];ii++){
(function(x,y){ (function(x,y){
node.onclick=function(){ var move = function () {
editor.moveViewport(x,y); editor.moveViewport(x, y);
}
node.onmousedown = function () {
clearTimeout(pressTimer);
pressTimer = setTimeout(function () {
pressTimer = -1;
var f = function () {
if (pressTimer != null) {
move();
setTimeout(f, 150);
}
}
f();
}, 500);
};
node.onmouseup = function () {
if (pressTimer >= 0) {
clearTimeout(pressTimer);
move();
}
pressTimer = null;
} }
})([-1,0,0,1][ii],[0,-1,1,0][ii]); })([-1,0,0,1][ii],[0,-1,1,0][ii]);
} }

View File

@ -511,23 +511,40 @@ uievent.move = function (dx, dy) {
uievent.values.left = core.clamp(uievent.values.left + dx, 0, uievent.values.width - core.__SIZE__); uievent.values.left = core.clamp(uievent.values.left + dx, 0, uievent.values.width - core.__SIZE__);
uievent.values.top = core.clamp(uievent.values.top + dy, 0, uievent.values.height - core.__SIZE__); uievent.values.top = core.clamp(uievent.values.top + dy, 0, uievent.values.height - core.__SIZE__);
this.updateSelectPoint(true); this.updateSelectPoint(true);
} };
uievent.elements.selectPointButtons.children[0].onclick = function () { (function() {
uievent.move(-1, 0);
}
uievent.elements.selectPointButtons.children[1].onclick = function () { var viewportButtons = uievent.elements.selectPointButtons;
uievent.move(0, -1); var pressTimer = null;
} for(var ii=0,node;node=viewportButtons.children[ii];ii++){
(function(x,y){
uievent.elements.selectPointButtons.children[2].onclick = function () { var move = function () {
uievent.move(0, 1); uievent.move(x, y);
} }
node.onmousedown = function () {
uievent.elements.selectPointButtons.children[3].onclick = function () { clearTimeout(pressTimer);
uievent.move(1, 0); pressTimer = setTimeout(function () {
} pressTimer = -1;
var f = function () {
if (pressTimer != null) {
move();
setTimeout(f, 150);
}
}
f();
}, 500);
};
node.onmouseup = function () {
if (pressTimer >= 0) {
clearTimeout(pressTimer);
move();
}
pressTimer = null;
}
})([-1,0,0,1][ii],[0,-1,1,0][ii]);
}
})();
uievent.elements.div.onmousewheel = function (e) { uievent.elements.div.onmousewheel = function (e) {
if (uievent.mode != 'selectPoint' || uievent.values.hideFloor) return; if (uievent.mode != 'selectPoint' || uievent.values.hideFloor) return;