Skip to content

Commit

Permalink
fix #8 closes a notification.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Sep 20, 2018
1 parent 4e22e89 commit 7b1dddf
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ const notify = new Notify({
effect: 'flash', // flash | scroll, Flashing or scrolling
openurl:'https://github.com/jaywcjlove/iNotify', // Click on the pop-up window to open the connection address
onclick: () => { // Click on the pop-up window trip event
// Programmatically closes a notification.
notify.close();
console.log('---')
},
// Optional playback sound
Expand Down Expand Up @@ -168,7 +170,6 @@ iNotify.setTitle('New title') // Flashing new title
iNotify.setTitle() // Clear Blinking Show original title
```


### setInterval

Set time interval.
Expand All @@ -177,6 +178,14 @@ Set time interval.
iNotify.setInterval(2000)
```

### close

Programmatically closes a notification.

```js
iNotify.close();
```

### addTimer

Add counter
Expand Down
4 changes: 4 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ Notify.prototype = {
n.onerror = () => {
(json.onerror && typeof json.onerror === 'function') && json.onerror(n);
};
this.Notifiy = n;
}
return this;
},
Expand Down Expand Up @@ -270,6 +271,9 @@ Notify.prototype = {
}
return this;
},
close() {
if (this.Notifiy) this.Notifiy.close();
},
// 清除Icon
faviconClear() {
const newicon = document.getElementById(`new${this.updateFavicon.id}`);
Expand Down
22 changes: 22 additions & 0 deletions website/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,23 @@ export default class App extends Component {
this.iN.faviconClear();
},
},
{
label: 'Open website.',
onClick: () => {
this.iN.notify({
title: 'Welcome to iNotify!',
body: 'You are opening the iNotify website!',
openurl: 'https://github.com/jaywcjlove/iNotify',
onclick: () => {
console.log('on click');
this.iN.close();
},
onshow: () => {
console.log('on show');
},
});
},
},
{
label: 'Favicon Font color',
onClick: () => {
Expand Down Expand Up @@ -100,11 +117,16 @@ export default class App extends Component {
title: '通知!',
body: '您来了一条新消息',
},
onclick: () => {
console.log('on click');
this.iN.close();
},
});
this.iN.setTitle('New news, welcome to iNotify!')
.notify({
title: 'Welcome to iNotify!',
body: 'You are opening the iNotify website!',
openurl: 'https://github.com/jaywcjlove/iNotify',
})
.player();
}
Expand Down

0 comments on commit 7b1dddf

Please # to comment.