mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-07 22:29:19 +00:00
Slider adapted to touchpad
git-svn-id: https://svn.fhem.de/fhem/trunk@1476 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
bc6dc9dba9
commit
4f974b656d
@ -57,10 +57,21 @@ Slider(slider, min, stp, max)
|
|||||||
var sh = slider.firstChild;
|
var sh = slider.firstChild;
|
||||||
var lastX=-1, offX=-1, minX, maxX, val=-1;
|
var lastX=-1, offX=-1, minX, maxX, val=-1;
|
||||||
|
|
||||||
sh.onselectstart = function() { return false; }
|
function
|
||||||
sh.onmousedown = function(e) {
|
touchFn(e, fn)
|
||||||
var oldMoveFn = document['onmousemove'];
|
{
|
||||||
var oldUpFn = document['onmouseup'];
|
e.preventDefault(); // Prevents Safari from scrolling!
|
||||||
|
if(e.touches == null || e.touches.length == 0)
|
||||||
|
return;
|
||||||
|
e.clientX = e.touches[0].clientX;
|
||||||
|
fn(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
function
|
||||||
|
mouseDown(e)
|
||||||
|
{
|
||||||
|
var oldFn1 = document.onmousemove, oldFn2 = document.onmouseup,
|
||||||
|
oldFn3 = document.ontouchmove, oldFn4 = document.ontouchend;
|
||||||
|
|
||||||
if(offX == -1) {
|
if(offX == -1) {
|
||||||
minX = offX = slider.offsetLeft;
|
minX = offX = slider.offsetLeft;
|
||||||
@ -68,7 +79,9 @@ Slider(slider, min, stp, max)
|
|||||||
}
|
}
|
||||||
lastX = e.clientX;
|
lastX = e.clientX;
|
||||||
|
|
||||||
document['onmousemove'] = function(e) {
|
function
|
||||||
|
mouseMove(e)
|
||||||
|
{
|
||||||
var diff = e.clientX-lastX; lastX = e.clientX;
|
var diff = e.clientX-lastX; lastX = e.clientX;
|
||||||
offX += diff;
|
offX += diff;
|
||||||
if(offX < minX) offX = minX;
|
if(offX < minX) offX = minX;
|
||||||
@ -78,14 +91,21 @@ Slider(slider, min, stp, max)
|
|||||||
sh.innerHTML = val;
|
sh.innerHTML = val;
|
||||||
sh.setAttribute('style', 'left:'+offX+'px;');
|
sh.setAttribute('style', 'left:'+offX+'px;');
|
||||||
}
|
}
|
||||||
|
document.onmousemove = mouseMove;
|
||||||
|
document.ontouchmove = function(e) { touchFn(e, mouseMove); }
|
||||||
|
|
||||||
document.onmouseup = function(e) {
|
document.onmouseup = document.ontouchend = function(e)
|
||||||
document['onmousemove'] = oldMoveFn;
|
{
|
||||||
document['onmouseup'] = oldUpFn;
|
document.onmousemove = oldFn1; document.onmouseup = oldFn2;
|
||||||
|
document.ontouchmove = oldFn3; document.ontouchend = oldFn4;
|
||||||
slider.nextSibling.setAttribute('value', val);
|
slider.nextSibling.setAttribute('value', val);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
sh.onselectstart = function() { return false; }
|
||||||
|
sh.onmousedown = mouseDown;
|
||||||
|
sh.ontouchstart = function(e) { touchFn(e, mouseDown); }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,7 +26,8 @@ table#room tr.sel { background: #A0FFFF; }
|
|||||||
|
|
||||||
.set,.attr { margin-bottom:5px; float:left; }
|
.set,.attr { margin-bottom:5px; float:left; }
|
||||||
.slider { float:right; width:250px; height:26px; background:#F0F0D8;
|
.slider { float:right; width:250px; height:26px; background:#F0F0D8;
|
||||||
margin-left:10px; -moz-border-radius:8px; border-radius:8px; }
|
margin-top:3px; margin-left:10px;
|
||||||
.handle { position:absolute; cursor:pointer; width:50px; height:20px; line-height:20px;
|
-moz-border-radius:8px; border-radius:8px; }
|
||||||
border:3px solid; color:#278727; text-align:center; }
|
.handle { position:absolute; cursor:pointer; width:50px; height:20px;
|
||||||
.downText { margin-top:2px; }
|
line-height:20px; border:3px solid; color:#278727; text-align:center; }
|
||||||
|
.downText { margin-top:6px; }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user