Skip to content

Commit

Permalink
Add top-center position
Browse files Browse the repository at this point in the history
  • Loading branch information
Glagan committed Sep 1, 2019
1 parent 93f16f0 commit 47f3c72
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ <h2 class="title is-2">Custom Notification</h2>
<div class="select">
<select name="position" id="position">
<option value="top-left">top-left</option>
<option value="top-center">top-center</option>
<option value="top-right" selected>top-right (default)</option>
<option value="bottom-left">bottom-left</option>
<option value="bottom-center">bottom-center</option>
Expand Down
19 changes: 19 additions & 0 deletions src/simpleNotification.css
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@
}
}

@keyframes insert-top {
from {
transform: rotateX(70deg);
transform-origin: top;
}
to {
transform: rotateX(0deg);
transform-origin: top;
}
}

@keyframes insert-bottom {
from {
transform: rotateX(-70deg);
Expand Down Expand Up @@ -73,6 +84,11 @@
top: 0;
right: 0;
}
.gn-top-center {
top: 0;
left: 50%;
transform: translateX(-50%);
}
.gn-top-left {
top: 0;
left: 0;
Expand Down Expand Up @@ -124,6 +140,9 @@
animation-name: insert-right;
}

.gn-top-center .gn-insert {
animation-name: insert-top;
}
.gn-bottom-center .gn-insert {
animation-name: insert-bottom;
}
Expand Down
6 changes: 4 additions & 2 deletions src/simpleNotification.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,8 @@ class SimpleNotification {
this.close(false);
} else if (event.animationName == 'insert-left' ||
event.animationName == 'insert-right' ||
event.animationName == 'insert-bottom') {
event.animationName == 'insert-bottom' ||
event.animationName == 'insert-top') {
this.node.classList.remove('gn-insert');
}
});
Expand Down Expand Up @@ -468,7 +469,8 @@ class SimpleNotification {
let startOnInsertFinish = event => {
if (event.animationName == 'insert-left' ||
event.animationName == 'insert-right' ||
event.animationName == 'insert-bottom') {
event.animationName == 'insert-bottom' ||
event.animationName == 'insert-top') {
// Set the time before removing the notification
this.progressBar.style.animationDuration = [this.duration, 'ms'].join('');
if (document.hasFocus()) {
Expand Down

0 comments on commit 47f3c72

Please sign in to comment.