Skip to content

Commit

Permalink
better doubletap, updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
jtangelder committed Mar 27, 2014
1 parent 24af195 commit 03b76f0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ var horde = gremlins.createHorde()
horde.unleash();
// gremlins will act randomly, at 10 ms interval, 100 times
```
`gremlins.js` provides several gremlin *species*: some click everywhere on the page, others enter data in form inputs, others scroll the window in every possible direction, etc.

`gremlins.js` provides several gremlin *species*: some click everywhere on the page, others enter data in form inputs, others scroll the window in every possible direction, etc.

You will see traces of the gremlins actions on the screen (they leave red traces) and in the console log:

```
gremlin formFiller input 5 in <input type=​"number" name=​"age">​
gremlin formFiller input [email protected] in <input type=​"email" name=​"email">​
gremlin clicker click at 1219 301
gremlin scroller scroll to 100 25
gremlin scroller scroll to 100 25
...
```

Expand Down Expand Up @@ -88,7 +88,7 @@ Alternately, you can include `gremlins.min.js` as a RequireJS module, leaving th

```js
require.config({
paths: {
paths: {
gremlins: 'path/to/gremlins.min'
}
});
Expand All @@ -102,14 +102,15 @@ require(['gremlins'], function(gremlins) {

### Setting Gremlins and Mogwais To Use In A Test

By default, all gremlins and mogwais species are added to the horde.
By default, all gremlins and mogwais species are added to the horde.

You can also choose to add only the gremlins species you want, using the `gremlin()` function of the `horde` object:

```js
gremlins.createHorde()
.gremlin(gremlins.species.formFiller())
.gremlin(gremlins.species.clicker().clickTypes(['click']))
.gremlin(gremlins.species.toucher())
.gremlin(gremlins.species.scroller())
.gremlin(function() {
window.$ = function() {};
Expand All @@ -133,6 +134,7 @@ To add just the mogwais you want, use the `mogwai()` and `allMogwais()` method t
`gremlins.js` currently provides a few gremlins and mogwais:

* [clickerGremlin](src/species/clicker.js) clicks anywhere on the visible area of the document
* [toucherGremlin](src/species/toucher.js) clicks anywhere on the visible area of the document
* [formFillerGremlin](src/species/formFiller.js) fills forms by entering data, selecting options, clicking checkboxes, etc
* [scrollerGremlin](src/species/scroller.js) scrolls the viewport to reveal another part of the document
* [typerGremlin](src/species/typer.js) types keys on the keyboard
Expand All @@ -142,7 +144,7 @@ To add just the mogwais you want, use the `mogwai()` and `allMogwais()` method t

### Configuring Gremlins

All the gremlins and mogwais provided by `gremlins.js` are *configurable functions*, i.e. you can alter the way they work by calling methods on them.
All the gremlins and mogwais provided by `gremlins.js` are *configurable functions*, i.e. you can alter the way they work by calling methods on them.

For instance, the clicker gremlin is a function that you can execute it directly:

Expand Down
8 changes: 5 additions & 3 deletions src/species/toucher.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ define(function(require) {
tap: function(position, element, done) {
var touches = getTouches(position, 1),
gesture = {
duration: config.randomizer.natural({ min: 4, max: 700 })
duration: config.randomizer.natural({ min: 20, max: 700 })
};

triggerTouch(touches, element, 'start');
Expand All @@ -243,7 +243,9 @@ define(function(require) {
*/
doubletap: function(position, element, done) {
touchTypes.tap(position, element, function() {
touchTypes.tap(position, element, done);
setTimeout(function() {
touchTypes.tap(position, element, done);
}, 30);
});
},

Expand All @@ -258,7 +260,7 @@ define(function(require) {
distanceX: config.randomizer.natural({ min: -100, max: 200 }),
distanceY: config.randomizer.natural({ min: -100, max: 200 }),
angle: config.randomizer.natural({ min: -200, max: 200 }),
duration: config.randomizer.natural({ min: 30, max: 500 })
duration: config.randomizer.natural({ min: 20, max: 500 })
},
touches = getTouches(position, points, gesture.radius);

Expand Down

0 comments on commit 03b76f0

Please sign in to comment.