MCPcopy
hub / github.com/ampproject/amphtml / onMouseMove_

Method onMouseMove_

src/input.js:221–251  ·  view source on GitHub ↗

* @param {!Event} e * @return {!Promise|undefined} * @private

(e)

Source from the content-addressed store, hash-verified

219 * @private
220 */
221 onMouseMove_(e) {
222 // The event explicitly states that it's a result of a touch event.
223 if (e.sourceCapabilities && e.sourceCapabilities.firesTouchEvents) {
224 this.mouseCanceled_();
225 return undefined;
226 }
227 if (!this.boundMouseConfirmed_) {
228 this.boundMouseConfirmed_ = this.mouseConfirmed_.bind(this);
229 this.boundMouseCanceled_ = this.mouseCanceled_.bind(this);
230 }
231 // If "click" arrives within a timeout time, this is most likely a
232 // touch/mouse emulation. Otherwise, if timeout exceeded, this looks
233 // like a legitimate mouse event.
234 let unlisten;
235 const listenPromise = listenOncePromise(
236 this.win.document,
237 'click',
238 /* capture */ undefined,
239 (unlistener) => {
240 unlisten = unlistener;
241 }
242 );
243 return Services.timerFor(this.win)
244 .timeoutPromise(CLICK_TIMEOUT_, listenPromise)
245 .then(this.boundMouseCanceled_, () => {
246 if (unlisten) {
247 unlisten();
248 }
249 this.boundMouseConfirmed_();
250 });
251 }
252
253 /** @private */
254 mouseConfirmed_() {

Callers 1

test-input.jsFile · 0.45

Calls 5

mouseCanceled_Method · 0.95
listenOncePromiseFunction · 0.90
unlistenFunction · 0.85
timeoutPromiseMethod · 0.80
thenMethod · 0.45

Tested by

no test coverage detected