MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / onSample

Function onSample

examples/commodetto/mini-drag/main.js:140–167  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

138if (!Touch) throw new Error("No touch driver configured");
139
140const onSample = () => {
141 const points = touch.sample();
142 if (!points) return;
143
144 const last = touch.points[0];
145
146 if (points.length === 0) {
147 if (last) {
148 last.target?.onTouchEnded(last.x, last.y);
149 touch.points[0] = undefined;
150 }
151 return;
152 }
153
154 const { x, y } = points[0];
155
156 if (last) {
157 last.x = x;
158 last.y = y;
159 last.target?.onTouchMoved(x, y);
160 return;
161 }
162
163 const entry = { x, y };
164 touch.points[0] = entry;
165 entry.target = dragger.contains(x, y) ? dragger : null;
166 entry.target?.onTouchBegan(x, y);
167};
168
169const touch = new Touch({ onSample })
170

Callers

nothing calls this directly

Calls 5

onTouchMovedMethod · 0.65
onTouchBeganMethod · 0.65
sampleMethod · 0.45
onTouchEndedMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected