-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Updated documentation * Updated ease function * Fixed breakpoint function null check bug * Added line-clamp mixin * Optimized DOM state methods * Improved state module * Implemented addDelegatedEventListener * Added and updated mixins * Removed default values column from config variables table in readme * Updated version to 1.0.5
- Loading branch information
André Ekeberg
authored and
björn
committed
Nov 1, 2019
1 parent
2bd1c1a
commit b86d463
Showing
11 changed files
with
436 additions
and
586 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "bolts-lib", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "Front-end helper library", | ||
"main": "src/js/index.js", | ||
"author": "Pocketsize <[email protected]> (https://www.pocketsize.se)", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
const matches = function(el, selector) { | ||
var p = Element.prototype | ||
|
||
var f = p.matches || p.webkitMatchesSelector || p.mozMatchesSelector || p.msMatchesSelector || function (s) { | ||
return [].indexOf.call(document.querySelectorAll(s), this) !== -1 | ||
} | ||
|
||
return f.call(el, selector) | ||
} | ||
|
||
const delegatedEventListeners = {} | ||
|
||
const addDelegatedEventListener = function (type, selector, callback) { | ||
if (!delegatedEventListeners[type]) { | ||
const listeners = (delegatedEventListeners[type] = []) | ||
|
||
document.addEventListener(type, function (event) { | ||
for ( | ||
let element = event.target; | ||
element && element.parentNode; | ||
element = element.parentNode | ||
) { | ||
for (const { selector, callback } of listeners) { | ||
if (matches(element, selector)) { | ||
callback.call(element, event) | ||
} | ||
} | ||
|
||
if (event.cancelBubble) { | ||
break | ||
} | ||
} | ||
}) | ||
} | ||
|
||
delegatedEventListeners[type].push({ selector, callback }) | ||
} | ||
|
||
export { addDelegatedEventListener } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.