Git Product home page Git Product logo

on-demand-live-region's Introduction

On Demand Live Regions

A tiny module for making screen readers announce text on demand, without a visual change to the interface. Initializing and using the live region is as simple as:

const liveRegion = new OnDemandLiveRegion()

liveRegion.say('Hello World!')

Installation

Just grab the minified version or install from NPM:

npm i on-demand-live-region

Settings object

  • level — the live region level (default: polite)
  • parent — the element to which the live region will be appended (default: body)
  • idPrefix — the prefix for the unique id generated for the live region (default: live-region-)
  • delay — the delay in milliseconds before the phrase is announced (default: 0)

Assertive example with a half second delay

const liveRegionDelayed = new OnDemandLiveRegion({
  level: 'assertive',
  delay: 500
})

liveRegionDelayed.say('Hello World! (sorry, delayed reaction)')

You can override the delay setting in a second argument when calling say:

liveRegionDelayed.say('Hello World! (sorry, delayed reaction)', 1000)

Say it over and over

Each time you use the say method, the extant live region (if it exists) is destroyed and a new one created. This means you can reliably make the same announcement multiple times. This is not guaranteed in other implementations, where a persistent live region is repopulated.

Tested in

  • Safari with VoiceOver
  • Chrome with VoiceOver
  • IE11 with JAWS
  • Chrome with JAWS
  • Firefox with NVDA
  • Chrome with ChromeVox

on-demand-live-region's People

Contributors

heydon avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.