소스 검색

Auto white-out with a finger when using apple stylus (#167)

When using an iPad with an apple stylus, finger touches now trigger the whiteout tool.
This behavior can be disabled by setting the environment variable AUTO_FINGER_WHITEOUT=disabled

* Auto white-out with a finger when using stylus

* Add AUTO_FINGER_WHITEOUT config variable

* Use local variable to remember if stylus was used and make behavior configurable

* Delete "stylus" property

* Make AUTO_FINGER_WHITEOUT on by default

Co-authored-by: Ophir LOJKINE <pere.jobs@gmail.com>

* Delete parseBool, add note about iPad/Pencil

Co-authored-by: ishabalin <ishabalin@apple.com>
Co-authored-by: Ophir LOJKINE <pere.jobs@gmail.com>
dev_h
Ilya Shabalin 4 년 전
부모
커밋
edf31cd6c2
No account linked to committer's email address
3개의 변경된 파일31개의 추가작업 그리고 0개의 파일을 삭제
  1. 26
    0
      client-data/tools/pencil/pencil.js
  2. 1
    0
      server/client_configuration.js
  3. 4
    0
      server/configuration.js

+ 26
- 0
client-data/tools/pencil/pencil.js 파일 보기

@@ -34,6 +34,9 @@
34 34
 	// than this?
35 35
 	var MIN_PENCIL_INTERVAL_MS = Tools.server_config.MAX_EMIT_COUNT_PERIOD / Tools.server_config.MAX_EMIT_COUNT;
36 36
 
37
+	var AUTO_FINGER_WHITEOUT = Tools.server_config.AUTO_FINGER_WHITEOUT;
38
+	var hasUsedStylus = false;
39
+
37 40
 	//Indicates the id of the line the user is currently drawing or an empty string while the user is not drawing
38 41
 	var curLineId = "",
39 42
 		lastTime = performance.now(); //The time at which the last point was drawn
@@ -46,11 +49,30 @@
46 49
 		this.y = y;
47 50
 	}
48 51
 
52
+	function handleAutoWhiteOut(evt) {
53
+		if (evt.touches && evt.touches[0] && evt.touches[0].touchType == "stylus") {
54
+			//When using stylus, switch back to the primary
55
+			if (hasUsedStylus && Tools.curTool.secondary.active) {
56
+				Tools.change("Pencil");
57
+			}
58
+			//Remember if starting a line with a stylus
59
+			hasUsedStylus = true;
60
+		}
61
+		if (evt.touches && evt.touches[0] && evt.touches[0].touchType == "direct") {
62
+			//When used stylus and touched with a finger, switch to secondary
63
+			if (hasUsedStylus && !Tools.curTool.secondary.active) {
64
+				Tools.change("Pencil");
65
+			}
66
+		}
67
+	}
68
+
49 69
 	function startLine(x, y, evt) {
50 70
 
51 71
 		//Prevent the press from being interpreted by the browser
52 72
 		evt.preventDefault();
53 73
 
74
+		if (AUTO_FINGER_WHITEOUT) handleAutoWhiteOut(evt);
75
+
54 76
 		curLineId = Tools.generateUID("l"); //"l" for line
55 77
 
56 78
 		Tools.drawAndSend({
@@ -149,6 +171,10 @@
149 171
 			"release": stopLineAt,
150 172
 		},
151 173
 		"draw": draw,
174
+		"onstart": function(oldTool) {
175
+			//Reset stylus
176
+			hasUsedStylus = false;
177
+		},
152 178
 		"secondary": {
153 179
 			"name": "White-out",
154 180
 			"icon": "tools/pencil/whiteout_tape.svg",

+ 1
- 0
server/client_configuration.js 파일 보기

@@ -6,4 +6,5 @@ module.exports = {
6 6
   MAX_EMIT_COUNT: config.MAX_EMIT_COUNT,
7 7
   MAX_EMIT_COUNT_PERIOD: config.MAX_EMIT_COUNT_PERIOD,
8 8
   BLOCKED_TOOLS: config.BLOCKED_TOOLS,
9
+  AUTO_FINGER_WHITEOUT: config.AUTO_FINGER_WHITEOUT,
9 10
 };

+ 4
- 0
server/configuration.js 파일 보기

@@ -41,4 +41,8 @@ module.exports = {
41 41
 
42 42
   /** Blocked Tools. A comma-separated list of tools that should not appear on boards. */
43 43
   BLOCKED_TOOLS: (process.env["WBO_BLOCKED_TOOLS"] || "").split(","),
44
+
45
+  /** Automatically switch to White-out on finger touch after drawing
46
+      with Pencil using a stylus. Only supported on iPad with Apple Pencil. */
47
+  AUTO_FINGER_WHITEOUT: process.env['AUTO_FINGER_WHITEOUT'] !== "disabled",
44 48
 };

Loading…
취소
저장