Skip to content

Commit 8fb043d

Browse files
author
Vasyl Vavrychuk
committed
started adding gestures
1 parent 5659d99 commit 8fb043d

File tree

3 files changed

+1445
-0
lines changed

3 files changed

+1445
-0
lines changed

web/WebDriverJsDemo.html

+17
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<script src="webdriver.js"></script>
1616
<script src="base64-arraybuffer.js"></script>
1717
<script src="FileSaver.js"></script>
18+
<script src="hammer.min.js"></script>
1819
<script>
1920
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith
2021
if (!String.prototype.startsWith) {
@@ -105,6 +106,16 @@
105106
'WebDriver.visualizerShowPoint()');
106107
}
107108

109+
webdriver.ActionSequence.prototype.touchFlick = function(speed) {
110+
var command = new webdriver.Command(webdriver.CommandName.TOUCH_FLICK);
111+
112+
command.setParameter('xspeed', speed.x);
113+
command.setParameter('yspeed', speed.y);
114+
115+
this.schedule_('touchFlick', command);
116+
return this;
117+
}
118+
108119
var Util = function() {}
109120
Util.WebDriverKeyFromJs = function(keyCode) {
110121
switch (keyCode) {
@@ -372,6 +383,12 @@
372383

373384
return false;
374385
}
386+
387+
Hammer(win.document).on("swipe", function(event) {
388+
self.driver.actions().
389+
touchFlick({x: event.gesture.velocityX, y: event.gesture.velocityY}).
390+
perform();
391+
});
375392
}
376393

377394
WebDriverJsDemo.prototype.showVisualizationWindow = function(source, size) {

0 commit comments

Comments
 (0)