Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ private async Task ShowAsyncMessage()
_option.IsAutoHide = false;
_option.Delay = 3000;
_option.Content = Localizer["MessagesAsyncDemoStep1Text"];
_option.Color = Color.Info;
_option.Color = Color.Primary;
await MessageService.Show(_option);

await Task.Delay(3000);
_option.Content = Localizer["MessagesAsyncDemoStep2Text"];
_option.IsAutoHide = true;
_option.Color = Color.Info;
await MessageService.Show(_option);

await Task.Delay(2000);
_option.IsAutoHide = true;
_option.Content = Localizer["MessagesAsyncDemoStep3Text"];
_option.Color = Color.Success;

Expand Down
20 changes: 12 additions & 8 deletions src/BootstrapBlazor/Components/Message/Message.razor.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,18 @@ export function show(id, msgId) {
return
}

const msgItem = { el, animationId: null }
msg.items.push(msgItem)
const autoHide = el.getAttribute('data-bb-autohide') === 'true';
let msgItem = msg.items.find(i => i.el.id === msgId)
if (msgItem === void 0) {
msgItem = { el, animationId: null }
msg.items.push(msgItem)
}

if (msgItem.animationId) {
cancelAnimationFrame(msgItem.animationId);
}

const autoHide = el.getAttribute('data-bb-autohide') === 'true';
if (autoHide) {
// auto close
const delay = parseInt(el.getAttribute('data-bb-delay'));
let start = void 0
const autoCloseAnimation = ts => {
Expand All @@ -45,10 +51,8 @@ export function show(id, msgId) {
const hideHandler = setTimeout(function () {
clearTimeout(hideHandler);

// remove Id
msg.items.pop();
if (msg.items.length === 0) {
// call server method prepare remove dom
msg.invoke.invokeMethodAsync(msg.callback);
}
}, 500);
Expand All @@ -58,9 +62,8 @@ export function show(id, msgId) {
e.preventDefault();
e.stopPropagation();

// trigger on-dismiss event callback
const alert = e.delegateTarget.closest('.alert');
if(alert) {
if (alert) {
const alertId = alert.getAttribute('id');
msg.invoke.invokeMethodAsync('Dismiss', alertId);
}
Expand All @@ -74,6 +77,7 @@ export function dispose(id) {
msg.items.forEach(item => {
if (item.animationId) {
cancelAnimationFrame(item.animationId);
item.animationId = null;
}
});
}
Expand Down