@aller/blink-labrador
Advanced tools
Comparing version 0.3.0 to 0.4.0
@@ -12,2 +12,6 @@ 'use strict'; | ||
var _debounce = require('lodash/debounce'); | ||
var _debounce2 = _interopRequireDefault(_debounce); | ||
var _addListener = require('../utils/add-listener'); | ||
@@ -64,9 +68,17 @@ | ||
function addEventListenerOnOutgoingLink(callback) { | ||
(0, _addListener.addListenerAggregated)('click', function (event) { | ||
var lastUrl = ''; | ||
var resetUrl = (0, _debounce2.default)(function () { | ||
lastUrl = ''; | ||
}, 100); | ||
function sendEventIfLink(event) { | ||
var clickData = isClickOnLinkClick(event); | ||
if (clickData.isLink) { | ||
if (clickData.isLink && clickData.element.getAttribute('href') !== lastUrl) { | ||
lastUrl = clickData.element.getAttribute('href'); | ||
callback(event, clickData.element); | ||
resetUrl(); | ||
} | ||
}); | ||
} | ||
(0, _addListener.addListenerAggregated)('contextmenu', sendEventIfLink); | ||
(0, _addListener.addListenerAggregated)('click', sendEventIfLink); | ||
(0, _addListener.addListenerAggregated)('mousedown', sendEventIfLink); | ||
} |
@@ -36,4 +36,4 @@ 'use strict'; | ||
* Adds an event listener. Try to use addListenerAggreagted | ||
* when you do no need to remove the EventListener for | ||
* need to have a spesial thortelling in place | ||
* when you do not need to remove the EventListener for | ||
* need to have a special throttling in place | ||
* @param {string} evt - Event to listen to. | ||
@@ -40,0 +40,0 @@ * @param {EventListener} cb - Callback |
{ | ||
"name": "@aller/blink-labrador", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"description": "Library for using blink on Labrador", | ||
@@ -5,0 +5,0 @@ "main": "lib/main.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
48792
1235