A small (actually really small, around 4KB) library, that attempts to mimic the three finger tap behaviour exhibited when you tap on a URL with three fingers in Safari.
In Safari, when the user taps on a hyperlink using three fingers, a small preview window opens that shows the webpage the link would have taken the use to. This library attempts to mimic that behaviour. But instead of using the three finger tap gesture to open the URL preview window (as it is not available on all hardware), in desktop, the library makes use of timed hover gesture to achieve the same.
In mobile, the user has to triple tap on a URL to open the preview window.
You have a look at the demo here.
You can install the library as a dependency over NPM or you can simply download the release from the dist folder here.
npm i three-finger-tap-js
1.Assign an appropriate class name to all the
<a> (anchor) tags for which you wish to add the hover effect to.
2.Add references to
threeFingerTap.min.css to the HTML page.
3.Call the library using the init method and see the magic happen.
Initializes the library and adds it to the window object with the name threeFingerTap. Use this method only once when you load the page.
An object with name, hoverTimeout and customLoadingBackground as keys.
|name||name of the CSS class name that will be used to identify the links to apply the hover effect on||String||yes||N/A|
|hoverTimeout||the duration for which a user needs to hover over an URL before the preview window appears. The value should be in milliseconds (Desktop only)||Number||yes||Ignored and set to 500 for Mobile|
|customLoadingBackground||By default a loading background is added, you can use this parameter to set a custom image or gif as background. The value should be a valid value for the CSS
All the three options can be specified either at the time the
init function is called by passing them as parameters, or
you can modify them any time after that using their corresponding getters and setters. All the three options are dynamic and changes
reflect as soon as they are modified.
Disables the hover effect added by the library
Enables the hover effect added by the library
Getter and Setters
|getName||Returns the current value of the
||String||yes||A CSS valid class name|
|getHoverTimeout||Returns the current value of the
|getCustomLoadingBackground||Returns the current value of the
|setCustomLoadingBackground||Sets the loading effect to the passed GIF/image||String||yes||A valid value for the CSS
Removes the DOM nodes and their respective event listeners. Also resets the library to the initial state.
If you have any issues report them at Issues