Skip to content

Commit

Permalink
Message: Fix removed element offsetHeight calculation bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Aras-ax committed Oct 12, 2019
1 parent 2830c04 commit 529c509
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/message/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,11 @@ const Message = function(options) {
Message.close = function(id, userOnClose) {
let len = instances.length;
let index = -1;
let removedHeight = 0;
for (let i = 0; i < len; i++) {
if (id === instances[i].id) {
index = i;
removedHeight = instances[index].$el.offsetHeight;
if (typeof userOnClose === 'function') {
userOnClose(instances[i]);
}
Expand All @@ -69,8 +71,7 @@ Message.close = function(id, userOnClose) {
}
}
if (len <= 1 || index === -1 || index > instances.length - 1) return;
const removedHeight = instances[index].$el.offsetHeight;
for (let i = index; i < len - 1 ; i++) {
for (let i = index; i < len - 1; i++) {
let dom = instances[i].$el;
dom.style['top'] =
parseInt(dom.style['top'], 10) - removedHeight - 16 + 'px';
Expand Down

0 comments on commit 529c509

Please sign in to comment.