Skip to content

Commit b955993

Browse files
author
Vasyl Vavrychuk
committed
fixed touch rotate
1 parent f832e55 commit b955993

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/webdriver/extension_qt/web_view_executor.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,6 @@ void QWebViewCmdExecutor::TouchPinchRotate(const ElementId &element, const int &
840840
float degree = angle;
841841
float rad = M_PI*degree/180;
842842

843-
844843
QTouchEvent *touchBeginEvent = create2PointTouchEvent(QEvent::TouchBegin, Qt::TouchPointPressed, startPoint, startPoint2);
845844
QApplication::postEvent(view_, touchBeginEvent);
846845

@@ -908,7 +907,7 @@ void QWebViewCmdExecutor::TouchPinchZoom(const ElementId &element, const double
908907
point2.setX(startPoint2.x() + dx*i/stepCount);
909908
else
910909
point2.setX(startPoint2.x() - dx*i/stepCount);
911-
qDebug()<<i<<point1<<point2;
910+
912911
QTouchEvent *touchMoveEvent = create2PointTouchEvent(QEvent::TouchUpdate, Qt::TouchPointMoved, point1, point2);
913912
QApplication::postEvent(view_, touchMoveEvent);
914913

web/webdriver-app.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,10 +450,21 @@ VisualizerController.prototype.visualizerAssignEventHandlers = function() {
450450
});
451451

452452
hammer.on("rotate", function(event) {
453+
// get principal angle from the interval (-180, 180)
454+
function toPrincipalAngle(angle) {
455+
while (angle < 0) angle += 360;
456+
angle = angle - Math.round(angle / 360) * 360;
457+
if (angle > 180) angle -= 360;
458+
return angle;
459+
}
460+
461+
var angle = event.gesture.rotation;
462+
angle = Math.round(toPrincipalAngle(angle));
463+
453464
var xpath = Util.getXPath(event.target);
454465
var target = self.driver.findElement(webdriver.By.xpath(xpath));
455466
self.driver.actions().
456-
touchPinchRotate(target, event.gesture.rotation).
467+
touchPinchRotate(target, angle).
457468
perform();
458469
});
459470

0 commit comments

Comments
 (0)