Hammer.js panstart与自定义平移手势

时间:2015-11-22 06:06:56

标签: javascript hammer.js gestures

我要求使用一个指针和多个指针进行平移。一个指向在地图上绘制的指针和多个用于拖动地图的指针。 创建自定义平移手势后,我无法触发Dim ws As Worksheet Dim MyWSTarget As Worksheet Dim i As Long Dim k As Long Set ws = ActiveSheet Set MyWSTarget = Workbooks.Open("C:\MASTER_QT.xlsx").Sheets(1) Dim ofst As Long Dim ttlArr() As String ttarr = Array("QTY", "TYPE", vbNullString, "LENGTH", "FINISH", vbNullString, vbNullString, "LIST", "NET", "MFG", "MODEL") ofst = 17 With ws For i = 1 To 200 If Left(ws.Cells(i, 1).Value, 2) = "HW" Then On Error Resume Next k = ws.Range(ws.Cells(i + 1, 1), ws.Cells(200, 1)).Find("HW").Row On Error GoTo 0 If k <= i Then k = ws.Cells(i, 1).End(xlDown).Row + 2 MyWSTarget.Cells(i + ofst, 3).Value = "SET" MyWSTarget.Cells(i + ofst, 4).Resize(2).Value = ws.Cells(i, 1).Resize(2).Value If IsNumeric(MyWSTarget.Cells((i + 2), 1).Value) Then MyWSTarget.Cells(i + ofst, 2).Value = Len("'" & Format(ws.Cells(i + 2, 1).Value, "#,##0")) - Len(Replace("'" & Format(ws.Cells(i + 2, 1).Value, "#,##0"), ",", "")) + 1 MyWSTarget.Cells(i + ofst + 2, 4).Value = "Doors: " & Format(ws.Cells(i + 2, 1).Value, "#,##0") Else MyWSTarget.Cells(i + ofst + 2, 4).Value = "Doors: " & ws.Cells(i + 2, 1).Value End If MyWSTarget.Cells(i + ofst + 4, 3).Resize(, UBound(ttarr) + 1).Value = ttarr MyWSTarget.Cells(i + ofst + 4, 3).Resize(, UBound(ttarr) + 1).Font.Bold = True MyWSTarget.Cells(i + ofst + 4, 3).Resize(, 5).Borders(xlEdgeBottom).LineStyle = xlDouble MyWSTarget.Cells(i + ofst + 4, 10).Resize(, 4).Borders(xlEdgeBottom).LineStyle = xlDouble ofst = ofst + 2 MyWSTarget.Cells(i + ofst + 3, 3).Resize(k - i - 3).Value = ws.Cells(i + 3, 1).Resize(k - i - 3).Value MyWSTarget.Cells(i + ofst + 3, 4).Resize(k - i - 3).Value = ws.Cells(i + 3, 2).Resize(k - i - 3).Value MyWSTarget.Cells(i + ofst + 3, 6).Resize(k - i - 3).Value = ws.Cells(i + 3, 5).Resize(k - i - 3).Value MyWSTarget.Cells(i + ofst + 3, 7).Resize(k - i - 3).Value = ws.Cells(i + 3, 6).Resize(k - i - 3).Value MyWSTarget.Cells(i + ofst + 3, 10).Resize(k - i - 3).Value = ws.Cells(i + 3, 7).Resize(k - i - 3).Value MyWSTarget.Cells(i + ofst + 3, 11).Resize(k - i - 3).Value = ws.Cells(i + 3, 8).Resize(k - i - 3).Value MyWSTarget.Cells(i + ofst + 3, 12).Resize(k - i - 3).Value = ws.Cells(i + 3, 3).Resize(k - i - 3).Value MyWSTarget.Cells(i + ofst + 3, 13).Resize(k - i - 3).Value = ws.Cells(i + 3, 4).Resize(k - i - 3).Value MyWSTarget.Cells(i + ofst + k - i - 1, 11).Value = WorksheetFunction.Sum(MyWSTarget.Cells(i + ofst + 3, 11).Resize(k - i - 4)) ' Change the Range("H1") to your cell with the factor MyWSTarget.Cells(i + ofst + k - i - 1, 12).Value = MyWSTarget.Cells(i + ofst + k - i - 1, 11).Value / MyWSTarget.Range("L12") MyWSTarget.Cells(i + ofst - 2, 8).Value = MyWSTarget.Cells(i + ofst + k - i - 1, 12).Value MyWSTarget.Cells(i + ofst - 2, 9).Value = MyWSTarget.Cells(i + ofst + k - i - 1, 12).Value * MyWSTarget.Cells(i + ofst - 2, 2).Value i = k - 1 End If Next i panstart等原生平移事件。如何为两个自定义手势单独触发本机事件。

这是我的代码HTML:

panend

这是我的JavaScript代码:

<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html xmlns='http://www.w3.org/1999/xhtml' lang='en'>
<head>
 <meta  content='width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;' name='viewport' />
</head>
  <body>
      <div id="log" style="position:absolute;top:10px;left:10px;"> Hi</div>
      <div id="mymap" style="width: 300px;height:400px;border:1px solid #c0c0c0; background-color:blue">
      </div>  
        <script type="text/javascript" src="./js/build.js"></script>
  </body>
</html>

1 个答案:

答案 0 :(得分:1)

必须为pan1pstart原始事件pan已被命名为pan1p

mc.on('panstart', function(ev) {
  var log = document.getElementById('log');
  log.innerHTML =  'panstart: '+JSON.stringify(ev);
}); 

hammer.js repository

得到澄清