README.md 1.61 KB
Newer Older
loelkes's avatar
loelkes committed
1
2
# zkmtools

loelkes's avatar
loelkes committed
3
4
5
6
7
8
9
10
11
12
13
14
## Installation

You can install this module with

```
yarn add https://url-to-this-repository...
```

## ToDo

* Allow any kind of event for the setupPointerLock() callback
* Enable element selection for FullscreenUtils.request()
loelkes's avatar
loelkes committed
15
16

## Documentation
loelkes's avatar
loelkes committed
17

loelkes's avatar
loelkes committed
18
### blink( target, interval, duration )
loelkes's avatar
loelkes committed
19
20
21

This toggles the _.visible_ attribute of _target_ with the interval _interval_ (milliseconds) for the duration _duration_ (milliseconds).

loelkes's avatar
loelkes committed
22
### getRandomInt( min, max )
loelkes's avatar
loelkes committed
23
24
25

Returns a random integer between _min_ (inclusive) and _max_ (exclusive). Default is min=0 and max=10.

loelkes's avatar
loelkes committed
26
### getRandomArbitrary( min, max )
loelkes's avatar
loelkes committed
27
28
29

Returns a random float between _min_ (inclusive) and _max_ (exclusive). Default is min=0, max=1.

loelkes's avatar
loelkes committed
30
### getMaxOfArray( numArray )
loelkes's avatar
loelkes committed
31
32
33

Get the maximum value from an array of values.

loelkes's avatar
loelkes committed
34
### getMinOfArray( numArray)
loelkes's avatar
loelkes committed
35
36
37

Get the minim value from an array of values.

loelkes's avatar
loelkes committed
38
### getQueryVariable( variableName, fallbackValue )
loelkes's avatar
loelkes committed
39
40
41

Returns HTTP GET value for _variableName_ form the current _window.location_ or _fallbackValue_ if _variableName_ is not set or found.

loelkes's avatar
loelkes committed
42
43
44
45
### getElementCenter( target, useViewport )

Returns the center in pixels of target. If _useViewport_ is set to true, the mothid will return the center of _target_ realtive to the top left corner of the viewport. Default is useViewport=false.

loelkes's avatar
loelkes committed
46
### setupPointerLock( target, callback )
loelkes's avatar
loelkes committed
47
48
49

Request a pointer lock for any element _target_ and execute _callback_ on the **mousemove** event.

loelkes's avatar
loelkes committed
50
51
52
53
54
### FullscreenUtils()
#### Static methods
##### .toogle()
Toggle between the fullscreen mode.
##### .request()
loelkes's avatar
loelkes committed
55
Request the element **document** to go fullscreen.
loelkes's avatar
loelkes committed
56
57
##### .close()
Close the fullscreen mode.