Skip to content

Commit

Permalink
Position north side placements using bottom css
Browse files Browse the repository at this point in the history
As requested in #151 referencing issue #31 for rationale
  • Loading branch information
Joel Steres committed Oct 17, 2016
1 parent a1184f4 commit 4a1abf3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/placementcalculator.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function PlacementCalculator() {
switch (placement) {
case 'n':
coords.set('left', position.left - (tipWidth / 2) - session.positionCompensation.left);
coords.set('top', position.top - tipHeight - offset - session.positionCompensation.top);
coords.set('bottom', session.windowHeight - position.top + offset - session.positionCompensation.bottom);
break;
case 'e':
coords.set('left', position.left + offset - session.positionCompensation.left);
Expand All @@ -54,19 +54,19 @@ function PlacementCalculator() {
coords.set('right', session.windowWidth - position.left + offset - session.positionCompensation.right);
break;
case 'nw':
coords.set('top', position.top - tipHeight - offset - session.positionCompensation.top);
coords.set('bottom', session.windowHeight - position.top + offset - session.positionCompensation.bottom);
coords.set('right', session.windowWidth - position.left - session.positionCompensation.right - 20);
break;
case 'nw-alt':
coords.set('left', position.left - session.positionCompensation.left);
coords.set('top', position.top - tipHeight - offset - session.positionCompensation.top);
coords.set('bottom', session.windowHeight - position.top + offset - session.positionCompensation.bottom);
break;
case 'ne':
coords.set('left', position.left - session.positionCompensation.left - 20);
coords.set('top', position.top - tipHeight - offset - session.positionCompensation.top);
coords.set('bottom', session.windowHeight - position.top + offset - session.positionCompensation.bottom);
break;
case 'ne-alt':
coords.set('top', position.top - tipHeight - offset - session.positionCompensation.top);
coords.set('bottom', session.windowHeight - position.top + offset - session.positionCompensation.bottom);
coords.set('right', session.windowWidth - position.left - session.positionCompensation.right);
break;
case 'sw':
Expand Down
14 changes: 12 additions & 2 deletions test/unit/placementcalculator.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ $(function() {
case 'n':
case 'ne':
case 'nw-alt':
assert.strictEqual(coords.top, 'auto', key + ': top property is set to auto');
assert.strictEqual($.isNumeric(coords.left), true, key + ': left property is set to a number');
assert.strictEqual(coords.right, 'auto', key + ': right property is set to auto');
assert.strictEqual($.isNumeric(coords.bottom), true, key + ': bottom property is set to a number');
break;
case 'e':
case 's':
case 'se':
Expand All @@ -52,13 +57,18 @@ $(function() {
case 'w':
case 'sw':
case 'se-alt':
case 'nw':
case 'ne-alt':
assert.strictEqual($.isNumeric(coords.top), true, key + ': top property is set to a number');
assert.strictEqual(coords.left, 'auto', key + ': left property is set to auto');
assert.strictEqual($.isNumeric(coords.right), true, key + ': right property is set to a number');
assert.strictEqual(coords.bottom, 'auto', key + ': bottom property is set to auto');
break;
case 'nw':
case 'ne-alt':
assert.strictEqual(coords.top, 'auto', key + ': top property is set to auto');
assert.strictEqual(coords.left, 'auto', key + ': left property is set to auto');
assert.strictEqual($.isNumeric(coords.right), true, key + ': right property is set to a number');
assert.strictEqual($.isNumeric(coords.bottom), true, key + ': bottom property is set to a number');
break;
}
});
});
Expand Down

0 comments on commit 4a1abf3

Please sign in to comment.