Skip to main content

A11y 无障碍插件




Eva.js accessibility plugin, used to add accessibility capabilities to game objects. The plugin automatically adds auxiliary DOM by locating the position of the game object, so that the game object can be focused, and the game has a11y.


With NPM

tnpm install @eva/plugin-a11y

In Browser

<script src=""></script>


First add system, and then add a11y component to the game objects.

import { A11ySystem, A11y, A11yActivate } from '@eva/plugin-a11y'

game.addSystem(new A11ySystem({
debug: true,
activate: A11yActivate.CHECK,
checkA11yOpen: () => {
return new Promise(resolve => {
resolve(true) // opened
resolve(false) // closed
// add a11y
gameObject.addComponent(new A11y({
hint: '按钮',
role: 'button',
"aria-value": "0"
"aira-hidden": "true"

The above code will automatically add an auxiliary DOM as shown in the following figure above the game object area:


Working diagram


gameObject.addComponent(new A11y({ hint: 'text' }))





debugbooleanWhether to turn on debugging, a red mask will appear after turning onfalse
activateA11yActivateWhether to activate accessibility, the default is to automatically activate according to the user's system settingsCHECK

2、A11y Accessibility components, game objects give accessibility capabilities

hintstringWhat needs to be read-
rolestringAccessibility roles, such as role="button"-
delaynumberDelay div inner time, in milliseconds0
aria-*stringAccessibility attributes


CHECKCheck the accessibility according to the incoming method
ENABLEEnable plugin accessibility
DISABLEDisable plugin accessibility


Some points to note when using:

  • Some draggable gameplay needs to be optimized according to the business
  • The auxiliary DOM node of the DragonBones animation is 1px
  • Click events will automatically trigger 'touchstart/touchend/tip' events on the Event component

Eva.js 无障碍插件动画

For transition animations, the barrier-free DOM layer needs to wait until the animation ends to know the position of the game object.

eva-plugin-a11y chooses this to process the transition animation.


Listen to the finish event of the animation, and add barrier-free capabilities to the game object after the animation is complete.

animation.on('finish', name => {
image.addComponent(new A11y({ hint: 'What needs to be read' }))

If there are multiple animations, you only need to listen to the finish event of the last animation.

// move animation
// idle animation
animation.on('finish', name => {
name === 'idle' && image.addComponent(new A11y({ hint: 'What needs to be read' }))

It is not recommended to use accessibility capabilities in Infinity's mobile animations, such as such animations.

This type of animation is not accessible to users at all, and it is recommended to optimize it from the product level.


The construction of the barrier-free component also provides a delay parameter, and the developer can choose to render the barrier-free DOM of the game object at any time.

image.addComponent(new A11y({ hint: 'What needs to be read', delay: 1000})