MCPcopy Create free account
hub / github.com/microsoft/SandDance / whichButtons

Function whichButtons

docs/app/js/sanddance-app.js:95182–95209  ·  view source on GitHub ↗
(event)

Source from the content-addressed store, hash-verified

95180const MOUSE_EVENT_BUTTONS_RIGHT_MASK = 2;
95181const MOUSE_EVENT_BUTTONS_MIDDLE_MASK = 4;
95182function whichButtons(event) {
95183 const eventType = MOUSE_EVENTS[event.srcEvent.type];
95184 if (!eventType) // Not a mouse evet
95185 return null;
95186 const { buttons , button , which } = event.srcEvent;
95187 let leftButton = false;
95188 let middleButton = false;
95189 let rightButton = false;
95190 if (// button is up, need to find out which one was pressed before
95191 eventType === UP_EVENT || eventType === MOVE_EVENT && !Number.isFinite(buttons)) {
95192 leftButton = which === MOUSE_EVENT_WHICH_LEFT;
95193 middleButton = which === MOUSE_EVENT_WHICH_MIDDLE;
95194 rightButton = which === MOUSE_EVENT_WHICH_RIGHT;
95195 } else if (eventType === MOVE_EVENT) {
95196 leftButton = Boolean(buttons & MOUSE_EVENT_BUTTONS_LEFT_MASK);
95197 middleButton = Boolean(buttons & MOUSE_EVENT_BUTTONS_MIDDLE_MASK);
95198 rightButton = Boolean(buttons & MOUSE_EVENT_BUTTONS_RIGHT_MASK);
95199 } else if (eventType === DOWN_EVENT) {
95200 leftButton = button === MOUSE_EVENT_BUTTON_LEFT;
95201 middleButton = button === MOUSE_EVENT_BUTTON_MIDDLE;
95202 rightButton = button === MOUSE_EVENT_BUTTON_RIGHT;
95203 }
95204 return {
95205 leftButton,
95206 middleButton,
95207 rightButton
95208 };
95209}
95210function getOffsetPosition(event, rootElement) {
95211 const center = event.center;
95212 // `center` is a hammer.js event property

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected