MCPcopy
hub / github.com/aframevr/aframe / emitIfAxesChanged

Function emitIfAxesChanged

src/utils/tracked-controls.js:106–130  ·  view source on GitHub ↗
(component, axesMapping, evt)

Source from the content-addressed store, hash-verified

104 * @param {object} evt - Event to process.
105 */
106export function emitIfAxesChanged (component, axesMapping, evt) {
107 var axes;
108 var buttonType;
109 var changed;
110 var detail;
111 var j;
112
113 for (buttonType in axesMapping) {
114 axes = axesMapping[buttonType];
115
116 changed = false;
117 for (j = 0; j < axes.length; j++) {
118 if (evt.detail.changed[axes[j]]) { changed = true; }
119 }
120
121 if (!changed) { continue; }
122
123 // Axis has changed. Emit the specific moved event with axis values in detail.
124 detail = {};
125 for (j = 0; j < axes.length; j++) {
126 detail[AXIS_LABELS[j]] = evt.detail.axis[axes[j]];
127 }
128 component.el.emit(buttonType + 'moved', detail);
129 }
130}
131
132/**
133 * Handle a button event and reemits the events.

Calls 1

emitMethod · 0.80

Tested by

no test coverage detected