Content-Length: 371327 | pFad | https://github.com/MarcScheib/aurelia-notify/commit/97438d6

E1 feat(*): add transitions on show/hide notification · MarcScheib/aurelia-notify@97438d6 · GitHub
Skip to content

Commit

Permalink
feat(*): add transitions on show/hide notification
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcScheib committed May 29, 2016
1 parent 364483c commit 97438d6
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 5 deletions.
3 changes: 1 addition & 2 deletions build/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ module.exports = {
root: appRoot,
source: appRoot + '**/*.js',
html: appRoot + '**/*.html',
style: 'styles/**/*.css',
less: appRoot + 'styles/**/*.less',
style: appRoot + '**/*.css',
output: 'dist/',
sample: 'sample',
doc:'./doc',
Expand Down
16 changes: 15 additions & 1 deletion build/tasks/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,25 @@ gulp.task('remove-dts-folder', function () {
.pipe(vinylPaths(del));
});

gulp.task('build-css', function () {
var amdCSS = gulp.src(paths.style)
.pipe(gulp.dest(paths.output+"amd"));

var sysCSS = gulp.src(paths.style)
.pipe(gulp.dest(paths.output+"system"));

var commonCSS = gulp.src(paths.style)
.pipe(gulp.dest(paths.output+"commonjs"));

var es2015CSS = gulp.src(paths.style)
.pipe(gulp.dest(paths.output+"es2015"));
});

gulp.task('build', function (callback) {
return runSequence(
'clean',
'build-index',
['build-es2015-temp', 'build-commonjs', 'build-amd', 'build-system', 'build-es2015'],
['build-es2015-temp', 'build-commonjs', 'build-amd', 'build-system', 'build-es2015', 'build-css'],
'build-dts',
callback
);
Expand Down
2 changes: 2 additions & 0 deletions src/bs-notification.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<template>
<require from="./style.css"></require>

<div class="alert alert-${level}" role="alert">
${notification}
<div class="pull-right">
Expand Down
48 changes: 46 additions & 2 deletions src/notification-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,29 @@ export let globalSettings = {
limit: 5
};

let transitionEvent = (function() {
let transition = null;

return function() {
if (transition) return transition;

let t;
let el = document.createElement('fakeelement');
let transitions = {
'transition': 'transitionend',
'OTransition': 'oTransitionEnd',
'MozTransition': 'transitionend',
'WebkitTransition': 'webkitTransitionEnd'
};
for (t in transitions) {
if (el.style[t] !== undefined) {
transition = transitions[t];
return transition;
}
}
};
}());

export class NotificationRenderer {
defaultSettings = globalSettings;

Expand Down Expand Up @@ -44,7 +67,20 @@ export class NotificationRenderer {
notificationController.timer = setTimeout(notificationController.close.bind(notificationController), settings.timeout);
}

return Promise.resolve();
return new Promise((resolve) => {
function onTransitionEnd(e) {
if (e.target !== notificationHost) {
return;
}
notificationHost.removeEventListener(transitionEvent(), onTransitionEnd);
resolve();
}

notificationHost.addEventListener(transitionEvent(), onTransitionEnd);
setTimeout(() => {
notificationHost.classList.add('notification-host-active');
}, 0);
});
};

notificationController.hideNotification = () => {
Expand All @@ -53,7 +89,15 @@ export class NotificationRenderer {
this.notificationControllers.splice(i, 1);
}

return Promise.resolve();
return new Promise((resolve) => {
function onTransitionEnd() {
notificationHost.removeEventListener(transitionEvent(), onTransitionEnd);
resolve();
}

notificationHost.addEventListener(transitionEvent(), onTransitionEnd);
notificationHost.classList.remove('notification-host-active');
});
};

notificationController.destroyNotificationHost = () => {
Expand Down
9 changes: 9 additions & 0 deletions src/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
notification-host {
display: block;
transition: opacity .2s linear;
opacity: 0;
}

.notification-host-active {
opacity: 1;
}

0 comments on commit 97438d6

Please sign in to comment.








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/MarcScheib/aurelia-notify/commit/97438d6

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy