touch drag offset calculation fix : scrollTop & Left is taken into account (scrolling parents elements must be positioned)

restore chrome --touch-event switch
This commit is contained in:
jean-emmanuel 2015-10-28 15:49:03 +01:00
parent bbf7440417
commit 5289f74c67
4 changed files with 9 additions and 7 deletions

View file

@ -1,6 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
<link rel="stylesheet" href="fonts/font-awesome.min.css"/>
<link rel="stylesheet" href="css/style.css"/>
<script>

View file

@ -43,18 +43,18 @@
}
function getOffset(obj) {
var offsetLeft = 0;
var offsetTop = 0;
var offsetLeft = 0
var offsetTop = 0
do {
if (!isNaN(obj.offsetLeft)) {
offsetLeft += obj.offsetLeft;
offsetLeft += obj.offsetLeft - obj.scrollLeft
}
if (!isNaN(obj.offsetTop)) {
offsetTop += obj.offsetTop;
offsetTop += obj.offsetTop - obj.scrollTop
}
} while(obj = obj.offsetParent );
} while(obj = obj.offsetParent )
return {left: offsetLeft, top: offsetTop};
return {left: offsetLeft, top: offsetTop}
}
element.on("touchstart.drag mousedown.drag", function(e) {

View file

@ -721,6 +721,7 @@ form {
height:100%;
padding:6rem 0;
overflow: auto;
position: relative;
> .widget {
border:0;
}

View file

@ -80,7 +80,7 @@ compileScss = function(){
}
}
// app.commandLine.appendSwitch('--touch-events')
app.commandLine.appendSwitch('--touch-events')
app.on('window-all-closed', function() {