|
4 | 4 | apps: [] |
5 | 5 | }, require("Storage").readJSON("swipeinv.json", true) || {}); |
6 | 6 |
|
7 | | - let getAppIdFromSrc = ()=> { return global.__FILE__.split(".")[0]; } |
| 7 | + let getAppIdFromSrc = ()=> { |
| 8 | + return global.__FILE__ && global.__FILE__.split(".")[0]; |
| 9 | + } |
8 | 10 |
|
9 | 11 | setTimeout(() => { // Timeout so we prepend listeners late, hopefully after all other listerners were added. |
10 | | - if (settings.global || settings.apps.length > 0) { |
| 12 | + if (settings.global || Object.keys(settings.apps).length > 0) { |
11 | 13 |
|
12 | 14 | let swipeInverter = (dirLR, dirUD, obj) => { |
13 | 15 | if (settings.global ^ Object.keys(settings.apps).includes(getAppIdFromSrc())) { |
14 | 16 | if (!(obj && obj.inverted)) { |
15 | 17 | E.stopEventPropagation(); |
16 | 18 | obj = Object.assign({inverted:true}, obj); |
17 | 19 |
|
18 | | - if (settings.global ^ settings.apps[getAppIdFromSrc].swipeH) {dirLR *= -1;} |
19 | | - if (settings.global ^ settings.apps[getAppIdFromSrc].swipeV) {dirUD *= -1;} |
| 20 | + if (settings.global ^ (settings.apps[getAppIdFromSrc()]&&settings.apps[getAppIdFromSrc()].swipeH)) {dirLR *= -1;} |
| 21 | + if (settings.global ^ (settings.apps[getAppIdFromSrc()]&&settings.apps[getAppIdFromSrc()].swipeV)) {dirUD *= -1;} |
20 | 22 |
|
21 | 23 | Bangle.emit("swipe", dirLR, dirUD, obj) |
22 | 24 | } |
|
29 | 31 | E.stopEventPropagation(); |
30 | 32 | e.inverted = true; |
31 | 33 |
|
32 | | - if (settings.global ^ settings.apps[getAppIdFromSrc].dragH) {e.dx *= -1;} |
33 | | - if (settings.global ^ settings.apps[getAppIdFromSrc].dragV) {e.dy *= -1;} |
| 34 | + if (settings.global ^ (settings.apps[getAppIdFromSrc()]&&settings.apps[getAppIdFromSrc()].dragH)) {e.dx *= -1;} |
| 35 | + if (settings.global ^ (settings.apps[getAppIdFromSrc()]&&settings.apps[getAppIdFromSrc()].dragV)) {e.dy *= -1;} |
34 | 36 |
|
35 | 37 | Bangle.emit("drag", e); |
36 | 38 | } |
|
0 commit comments