@lemonadejs/modal 2.7.0 → 2.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +15 -18
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -215,10 +215,8 @@ if (!lemonade && typeof (require) === 'function') {
215
215
  // Minimize modals
216
216
  minimizedModals.push(self);
217
217
 
218
- let rect = self.el.getBoundingClientRect();
219
-
220
- self.el.top = rect.top;
221
- self.el.left = rect.left;
218
+ self.el.top = self.el.offsetTop;
219
+ self.el.left = self.el.offsetLeft;
222
220
 
223
221
  if (! self.el.style.top) {
224
222
  self.el.style.top = self.el.top + 'px';
@@ -259,13 +257,13 @@ if (!lemonade && typeof (require) === 'function') {
259
257
 
260
258
  const removeMargin = function(self) {
261
259
  if (self.el.style.marginLeft) {
262
- let y = self.left + parseInt(self.el.style.marginLeft);
260
+ let y = self.el.offsetLeft;
263
261
  self.el.style.marginLeft = '';
264
262
  self.left = y;
265
263
  }
266
264
 
267
265
  if (self.el.style.marginTop) {
268
- let x = self.top + parseInt(self.el.style.marginTop);
266
+ let x = self.el.offsetTop;
269
267
  self.el.style.marginTop = '';
270
268
  self.top = x;
271
269
  }
@@ -277,25 +275,24 @@ if (!lemonade && typeof (require) === 'function') {
277
275
  }
278
276
 
279
277
  self.el.style.marginLeft = '';
280
- let rect = self.el.getBoundingClientRect();
281
278
  let viewportWidth = window.innerWidth;
282
279
  let margin = 10;
283
280
 
284
281
  if (self.position) {
285
282
  if (self.position === 'absolute') {
286
283
  viewportWidth = document.documentElement.clientWidth;
287
- } else {
284
+ } else if (self.position !== 'center') {
288
285
  margin = 0;
289
286
  }
290
287
  }
291
288
 
292
- let rightEdgeDistance = viewportWidth - (rect.right);
289
+ let rightEdgeDistance = viewportWidth - (self.el.offsetLeft + self.el.offsetWidth);
293
290
  let transformX = 0;
294
- if (rightEdgeDistance < margin) {
291
+ if (rightEdgeDistance < 0) {
295
292
  transformX = rightEdgeDistance - margin;
296
293
  }
297
- if (rect.left < margin) {
298
- transformX = margin - rect.left;
294
+ if (self.el.offsetLeft < 0) {
295
+ transformX = margin - self.el.offsetLeft;
299
296
  }
300
297
  if (transformX !== 0) {
301
298
  self.el.style.marginLeft = transformX + 'px';
@@ -308,25 +305,25 @@ if (!lemonade && typeof (require) === 'function') {
308
305
  }
309
306
 
310
307
  self.el.style.marginTop = '';
311
- let rect = self.el.getBoundingClientRect();
312
308
  let viewportHeight = window.innerHeight;
313
309
  let margin = 10;
314
310
 
315
311
  if (self.position) {
316
312
  if (self.position === 'absolute') {
317
313
  viewportHeight = document.documentElement.clientHeight;
318
- } else {
314
+ } else if (self.position !== 'center') {
319
315
  margin = 0;
320
316
  }
321
317
  }
322
318
 
323
- let bottomEdgeDistance = viewportHeight - (rect.bottom);
319
+ let bottomEdgeDistance = viewportHeight - (self.el.offsetTop + self.el.offsetHeight);
324
320
  let transformY = 0;
325
- if (bottomEdgeDistance < margin) {
321
+ if (bottomEdgeDistance < 0) {
326
322
  transformY = bottomEdgeDistance - margin;
327
323
  }
328
- if (rect.top < margin) {
329
- transformY = margin - rect.top;
324
+
325
+ if (self.el.offsetTop < 0) {
326
+ transformY = margin - self.el.offsetTop;
330
327
  }
331
328
  if (transformY !== 0) {
332
329
  self.el.style.marginTop = transformY + 'px';
package/package.json CHANGED
@@ -17,5 +17,5 @@
17
17
  },
18
18
  "main": "dist/index.js",
19
19
  "types": "dist/index.d.ts",
20
- "version": "2.7.0"
20
+ "version": "2.7.1"
21
21
  }