@lemonadejs/modal 2.8.0 → 2.8.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 -11
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -282,19 +282,21 @@ if (!lemonade && typeof (require) === 'function') {
282
282
  if (self.position === 'absolute') {
283
283
  let w = document.documentElement.offsetWidth;
284
284
  if (w > viewportWidth) {
285
- viewportWidth = w;
285
+ //viewportWidth = w;
286
286
  }
287
287
  } else if (self.position !== 'center') {
288
288
  margin = 0;
289
289
  }
290
290
  }
291
291
 
292
- let rightEdgeDistance = viewportWidth - (self.el.offsetLeft + self.el.offsetWidth);
292
+ let el = self.el.getBoundingClientRect();
293
+
294
+ let rightEdgeDistance = viewportWidth - (el.left + el.width);
293
295
  let transformX = 0;
294
296
 
295
297
  if (self.position === 'absolute') {
296
- if (rightEdgeDistance < 5) {
297
- transformX = (-1 * self.el.offsetWidth) - margin;
298
+ if (rightEdgeDistance < 0) {
299
+ transformX = rightEdgeDistance - margin - 10; // 10 is the scroll width
298
300
  }
299
301
  } else {
300
302
  if (rightEdgeDistance < 0) {
@@ -302,8 +304,8 @@ if (!lemonade && typeof (require) === 'function') {
302
304
  }
303
305
  }
304
306
 
305
- if (self.el.offsetLeft < 0) {
306
- transformX = margin - self.el.offsetLeft;
307
+ if (el.left < 0) {
308
+ transformX = margin - el.left;
307
309
  }
308
310
  if (transformX !== 0) {
309
311
  self.el.style.marginLeft = transformX + 'px';
@@ -323,19 +325,21 @@ if (!lemonade && typeof (require) === 'function') {
323
325
  if (self.position === 'absolute') {
324
326
  let h = document.documentElement.offsetHeight;
325
327
  if (h > viewportHeight) {
326
- viewportHeight = h;
328
+ //viewportHeight = h;
327
329
  }
328
330
  } else if (self.position !== 'center') {
329
331
  margin = 0;
330
332
  }
331
333
  }
332
334
 
333
- let bottomEdgeDistance = viewportHeight - (self.el.offsetTop + self.el.offsetHeight);
335
+ let el = self.el.getBoundingClientRect();
336
+
337
+ let bottomEdgeDistance = viewportHeight - (el.top + el.height);
334
338
  let transformY = 0;
335
339
 
336
340
  if (self.position === 'absolute') {
337
341
  if (bottomEdgeDistance < 5) {
338
- transformY = (-1 * self.el.offsetHeight) - margin;
342
+ transformY = (-1 * el.height) - margin - 20;
339
343
  }
340
344
  } else {
341
345
  if (bottomEdgeDistance < 0) {
@@ -343,8 +347,8 @@ if (!lemonade && typeof (require) === 'function') {
343
347
  }
344
348
  }
345
349
 
346
- if (self.el.offsetTop < 0) {
347
- transformY = margin - self.el.offsetTop;
350
+ if (el.top < 0) {
351
+ transformY = margin - el.top;
348
352
  }
349
353
  if (transformY !== 0) {
350
354
  self.el.style.marginTop = transformY + 'px';
package/package.json CHANGED
@@ -13,9 +13,9 @@
13
13
  "modal js"
14
14
  ],
15
15
  "dependencies": {
16
- "lemonadejs": "^4.2.1"
16
+ "lemonadejs": "^4.2.2"
17
17
  },
18
18
  "main": "dist/index.js",
19
19
  "types": "dist/index.d.ts",
20
- "version": "2.8.0"
20
+ "version": "2.8.1"
21
21
  }