Skip to content

Commit

Permalink
Fix popover attachment position detection
Browse files Browse the repository at this point in the history
  • Loading branch information
Scott Elwood authored and Scott Elwood committed Aug 14, 2017
1 parent 81bb9fd commit 58e1829
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
1 change: 1 addition & 0 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<style>
body {
background: #EFEFEF;
margin: 0;
padding: 30px;
}

Expand Down
6 changes: 3 additions & 3 deletions dist/popover.js
Original file line number Diff line number Diff line change
Expand Up @@ -1655,14 +1655,14 @@ var Positioner = function () {
}, {
key: 'cacheCssOffsets',
value: function cacheCssOffsets() {
var sizerClasses = ['popoverjs--popover-primary-top', 'popoverjs--popover-secondary-left', 'popoverjs--attachment-primary-left', 'popoverjs--attachment-secondary-top'];
var sizerClasses = ['popoverjs--popover-primary-bottom', 'popoverjs--popover-secondary-left', 'popoverjs--attachment-primary-top', 'popoverjs--attachment-secondary-left'];

this.togglePopoverClasses(sizerClasses, true);

this.cssCache = {
arrowSize: this.getArrowSize(),
contentSize: this.getContentSize(),
attachmentOffset: Math.abs(this.popoverElement.offsetTop),
attachmentOffset: Math.abs(this.popoverElement.offsetTop) - 1,
triggerOffset: Math.abs(this.popoverElement.offsetLeft),
contentOffset: Math.abs(this.popoverContent.offsetLeft)
};
Expand Down Expand Up @@ -1878,7 +1878,7 @@ var Positioner = function () {
}, {
key: 'isConstrainedByPrimary',
value: function isConstrainedByPrimary(side) {
var originCoordinate = this.origins.attachment[side];
var originCoordinate = this.origins.attachment[side] + this.cssCache.attachmentOffset;
var popoverSize = this.getPopoverSizeFromSideCheck(side);

if (side === 'left' || side === 'top') {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "popover.js",
"version": "0.0.6",
"version": "0.0.7",
"description": "",
"main": "dist/popover.js",
"scripts": {
Expand Down
10 changes: 5 additions & 5 deletions src/positioner.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,18 @@ class Positioner {

cacheCssOffsets() {
const sizerClasses = [
'popoverjs--popover-primary-top',
'popoverjs--popover-primary-bottom',
'popoverjs--popover-secondary-left',
'popoverjs--attachment-primary-left',
'popoverjs--attachment-secondary-top',
'popoverjs--attachment-primary-top',
'popoverjs--attachment-secondary-left',
];

this.togglePopoverClasses(sizerClasses, true);

this.cssCache = {
arrowSize: this.getArrowSize(),
contentSize: this.getContentSize(),
attachmentOffset: Math.abs(this.popoverElement.offsetTop),
attachmentOffset: Math.abs(this.popoverElement.offsetTop) - 1,
triggerOffset: Math.abs(this.popoverElement.offsetLeft),
contentOffset: Math.abs(this.popoverContent.offsetLeft),
};
Expand Down Expand Up @@ -281,7 +281,7 @@ class Positioner {
}

isConstrainedByPrimary(side) {
const originCoordinate = this.origins.attachment[side];
const originCoordinate = this.origins.attachment[side] + this.cssCache.attachmentOffset;
const popoverSize = this.getPopoverSizeFromSideCheck(side);

if (side === 'left' || side === 'top') {
Expand Down

0 comments on commit 58e1829

Please sign in to comment.