Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
pressBehaviors.forEach(behaviorElement => {
const trigger: PressTrigger =
behaviorElement.getAttribute(ATTRIBUTES.TRIGGER) || TRIGGERS.PRESS;
const triggerPropName = PRESS_TRIGGERS_PROP_NAMES[trigger];
const handler = this.createActionHandler(
element,
behaviorElement,
onUpdate,
);
if (pressHandlers[triggerPropName]) {
const oldHandler = pressHandlers[triggerPropName];
pressHandlers[triggerPropName] = () => {
oldHandler();
setTimeout(handler, time);
time += 1;
};
} else {
pressHandlers[triggerPropName] = handler;
}
e =>
PRESS_TRIGGERS.indexOf(
e.getAttribute(ATTRIBUTES.TRIGGER) || TRIGGERS.PRESS,
) >= 0,
);
export const PRESS_PROP_NAMES = {
ON_LONG_PRESS: 'onLongPress',
ON_PRESS_IN: 'onPressIn',
ON_PRESS_OUT: 'onPressOut',
ON_PRESS: 'onPress',
};
export type PressPropName = $Values;
export const PRESS_TRIGGERS_PROP_NAMES: {
[PressTrigger]: PressPropName,
} = {
[TRIGGERS.LONG_PRESS]: PRESS_PROP_NAMES.ON_LONG_PRESS,
[TRIGGERS.PRESS_IN]: PRESS_PROP_NAMES.ON_PRESS_IN,
[TRIGGERS.PRESS_OUT]: PRESS_PROP_NAMES.ON_PRESS_OUT,
[TRIGGERS.PRESS]: PRESS_PROP_NAMES.ON_PRESS,
};