0.0.7 • Published 7 years ago

capture-anchor-click v0.0.7

Weekly downloads
1
License
MIT
Repository
-
Last release
7 years ago

capture-anchor-click

window click trigger for HTMLAnchorElement

You can use the capture trigger to dynamically reload the web-page, or individual web-page elements

CaptureAnchorClick object

NameDescription
isBlurboolean call .blur() after prevent, default = true
blurDurationTimeoutint Timeout for blur, default = 1
onTestset function(link) The function is called before dispatch all events
addfunction(callback) Add click event function
removefunction(callback) Remove click event function
removeAllfunction(callback) Remove all click event functions

Example

import CaptureAnchorClick from "capture-anchor-click";

CaptureAnchorClick.add(evn => {
	
	let target = evn.target;
	let href = evn.detail.link;
	
	// <a href="#open-window" data-name="login">...</a>
	if( href === "#open-window" ) {
		let myWin = target.getAttribute("data-name"); // or target.dataset.name
		// todo your action 
	}
	
	// <a href="/page/name.html">...</a>
	else if( /^\/page\/(.*?)\.html/.test(href) ) {
		let page = RegExp.$1;
		// todo your action for dynamic reload page
	}
	
	// use default event click
	else {
		return void 0
	}
	
	// trigger will be prevented
	evn.preventDefault();
})
0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago