Skip to content
This repository has been archived by the owner on Jul 23, 2021. It is now read-only.

Tyriar/abbr-touch

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

abbr-touch

Build Status Code Climate

abbr-touch is a tiny JavaScript library that makes the title attribute of <abbr> element touch accessible. It does so by utilising touchtap-event to only expose the functionality to touch-enabled devices, a custom touch handler can then be used to display <abbr>'s content any way you wish.

Example usage: touching an <abbr> tag brings up a description

Install

npm install --save abbr-touch

Include

<script src="node_modules/abbr-touch/abbr-touch.js"></script>

Usage

// default handler on document (alert)
abbrTouch();

// default handler, apply to descendants of #some-element
abbrTouch(document.querySelector('#some-element'));

// custom handler, apply to descendants of #some-element
abbrTouch(document.querySelector('#some-element'), myHandler);

function myHandler(target, title, touchX, touchY) {
  console.log(target);
  console.log(title);
  console.log(touchX);
  console.log(touchY);
}

A deeper example of usage can be found in demo.html. A live demo can be viewed on Growing with the Web.

See also