Skip to content

Commit

Permalink
Added 'sentinel-load' event, bumped version number
Browse files Browse the repository at this point in the history
  • Loading branch information
amorey committed Sep 24, 2017
1 parent ffe1c2c commit 42b694b
Show file tree
Hide file tree
Showing 12 changed files with 83 additions and 25 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# SentinelJS Changelog

## 0.0.4 - September 24, 2017

* Added 'sentinel-load' event on library load

## 0.0.3 - September 23, 2017

* Removed `extraAnimations` option
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<img src="https://www.muicss.com/static/images/sentinel.svg" width="250px">

SentinelJS is a tiny JavaScript library that lets you detect new DOM nodes using CSS selectors (602 bytes).
SentinelJS is a tiny JavaScript library that lets you detect new DOM nodes using CSS selectors (653 bytes).

## Introduction

Expand Down Expand Up @@ -39,15 +39,15 @@ sentinel.on('custom-element', function(el) {
});
```

SentinelJS is 602 bytes (minified + gzipped).
SentinelJS is 653 bytes (minified + gzipped).

## Quickstart

```html
<!doctype html>
<html>
<head>
<script src="//cdn.rawgit.com/muicss/sentineljs/0.0.3/dist/sentinel.min.js"></script>
<script src="//cdn.rawgit.com/muicss/sentineljs/0.0.4/dist/sentinel.min.js"></script>
<script>
// use the `sentinel` global object
sentinel.on('.my-div', function(el) {
Expand Down Expand Up @@ -187,7 +187,7 @@ To make it easy to use SentinelJS asynchronously, the library dispatches a `sent
<!doctype html>
<html>
<head>
<script src="//cdn.rawgit.com/muicss/sentineljs/0.0.3/dist/sentinel.min.js" async></script>
<script src="//cdn.rawgit.com/muicss/sentineljs/0.0.4/dist/sentinel.min.js" async></script>
<script>
// use the `sentinel-load` event to detect load time
document.addEventListener('sentinel-load', function() {
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sentinel-js",
"version": "0.0.3",
"version": "0.0.4",
"license": "MIT",
"authors": [
"Andres Morey <andres@muicss.com>"
Expand Down
15 changes: 11 additions & 4 deletions dist/sentinel.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// define global object
sentinel = this.sentinel || (function () {
var isArray = Array.isArray,
if (!this.sentinel) (function(doc, ev) {
// define global object
sentinel = (function(){
var isArray = Array.isArray,
selectorToAnimationMap = {},
animationCallbacks = {},
styleEl,
Expand Down Expand Up @@ -133,4 +134,10 @@ return {
}
};

})();
})();

// dispatch load event
ev = doc.createEvent('HTMLEvents');
ev.initEvent('sentinel-load', false, false);
doc.dispatchEvent(ev);
})(document);
2 changes: 1 addition & 1 deletion dist/sentinel.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 11 additions & 4 deletions examples/assets/sentineljs/sentinel.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// define global object
sentinel = this.sentinel || (function () {
var isArray = Array.isArray,
if (!this.sentinel) (function(doc, ev) {
// define global object
sentinel = (function(){
var isArray = Array.isArray,
selectorToAnimationMap = {},
animationCallbacks = {},
styleEl,
Expand Down Expand Up @@ -133,4 +134,10 @@ return {
}
};

})();
})();

// dispatch load event
ev = doc.createEvent('HTMLEvents');
ev.initEvent('sentinel-load', false, false);
doc.dispatchEvent(ev);
})(document);
2 changes: 1 addition & 1 deletion examples/assets/sentineljs/sentinel.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions examples/async-example.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<html>
<head>
<script src="assets/sentineljs/sentinel.js" async></script>
<script>
document.addEventListener('sentinel-load', function() {
console.log('sentinel-load');

// use the `sentinel` global object
sentinel.on('.my-div', function(el) {
el.innerHTML = 'The sentinel is always watching.';
});
});

// add a new div to the DOM
function addDiv() {
var newEl = document.createElement('div');
newEl.className = 'my-div';
document.body.appendChild(newEl);
}
</script>
</head>
<body>
<button onclick="addDiv();">Add another DIV</button>
<div class="my-div"></div>
</body>
</html>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sentinel-js",
"version": "0.0.3",
"version": "0.0.4",
"license": "MIT",
"description": "JS library that detects new DOM nodes using CSS selectors",
"keywords": [
Expand Down
15 changes: 11 additions & 4 deletions test/assets/sentineljs/sentinel.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// define global object
sentinel = this.sentinel || (function () {
var isArray = Array.isArray,
if (!this.sentinel) (function(doc, ev) {
// define global object
sentinel = (function(){
var isArray = Array.isArray,
selectorToAnimationMap = {},
animationCallbacks = {},
styleEl,
Expand Down Expand Up @@ -133,4 +134,10 @@ return {
}
};

})();
})();

// dispatch load event
ev = doc.createEvent('HTMLEvents');
ev.initEvent('sentinel-load', false, false);
doc.dispatchEvent(ev);
})(document);
2 changes: 1 addition & 1 deletion test/assets/sentineljs/sentinel.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 11 additions & 4 deletions umd-templates/web.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
// define global object
<%= namespace %> = this.sentinel || (function (<%= param %>) {
<%= contents %>
})(<%= global %>);
if (!this.<%= namespace %>) (function(doc, ev) {
// define global object
<%= namespace %> = (function(){
<%= contents %>
})();

// dispatch load event
ev = doc.createEvent('HTMLEvents');
ev.initEvent('sentinel-load', false, false);
doc.dispatchEvent(ev);
})(document);

0 comments on commit 42b694b

Please sign in to comment.