| @@ -740,8 +740,9 @@ | ||
| 740 | 740 | function checkHeightCriteria() { |
| 741 | 741 | |
| 742 | 742 | var scrollY = scrollElement.hasOwnProperty('scrollY') ? scrollElement.scrollY : scrollElement.scrollTop; |
| 743 | 743 | scrollY = scrollY + window.innerHeight * 0.75; |
| 744 | + console.log(scrollY); | |
| 744 | 745 | |
| 745 | 746 | boxes.forEach(function (box) { |
| 746 | 747 | if (!box.mayAutoShow() || box.triggerHeight <= 0) { |
| 747 | 748 | return; |
| @@ -771,12 +772,12 @@ | ||
| 771 | 772 | function onOverlayClick(e) { |
| 772 | 773 | var x = e.offsetX; |
| 773 | 774 | var y = e.offsetY; |
| 774 | 775 | |
| 775 | - // calculate if click was less than 40px outside box to avoid closing it by accident | |
| 776 | + // calculate if click was near a box to avoid closing it (click error margin) | |
| 776 | 777 | boxes.forEach(function (box) { |
| 777 | 778 | var rect = box.element.getBoundingClientRect(); |
| 778 | - var margin = 40; | |
| 779 | + var margin = 100 + window.innerWidth * 0.05; | |
| 779 | 780 | |
| 780 | 781 | // if click was not anywhere near box, dismiss it. |
| 781 | 782 | if (x < rect.left - margin || x > rect.right + margin || y < rect.top - margin || y > rect.bottom + margin) { |
| 782 | 783 | box.dismiss(); |
| @@ -829,11 +830,10 @@ | ||
| 829 | 830 | } |
| 830 | 831 | |
| 831 | 832 | function onElementClick(e) { |
| 832 | 833 | var el = e.target || e.srcElement; |
| 833 | - if (el && el.tagName === 'A' && el.getAttribute('href').toLowerCase().indexOf('#boxzilla-') === 0) { | |
| 834 | - window.a = el; | |
| 835 | - var boxId = e.target.getAttribute('href').toLowerCase().substring("#boxzilla-".length); | |
| 834 | + if (el && el.tagName === 'A' && el.getAttribute('href').indexOf('#boxzilla-') === 0) { | |
| 835 | + var boxId = e.target.getAttribute('href').substring("#boxzilla-".length); | |
| 836 | 836 | Boxzilla.toggle(boxId); |
| 837 | 837 | } |
| 838 | 838 | } |
| 839 | 839 | |
| @@ -971,9 +971,8 @@ | ||
| 971 | 971 | |
| 972 | 972 | // expose each individual box. |
| 973 | 973 | Boxzilla.boxes = boxes; |
| 974 | 974 | |
| 975 | -// expose boxzilla object | |
| 976 | 975 | window.Boxzilla = Boxzilla; |
| 977 | 976 | |
| 978 | 977 | if (typeof module !== 'undefined' && module.exports) { |
| 979 | 978 | module.exports = Boxzilla; |