Skip to content

Commit 4a1abf3

Browse files
author
Joel Steres
committed
Position north side placements using bottom css
As requested in #151 referencing issue #31 for rationale
1 parent a1184f4 commit 4a1abf3

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

src/placementcalculator.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function PlacementCalculator() {
3939
switch (placement) {
4040
case 'n':
4141
coords.set('left', position.left - (tipWidth / 2) - session.positionCompensation.left);
42-
coords.set('top', position.top - tipHeight - offset - session.positionCompensation.top);
42+
coords.set('bottom', session.windowHeight - position.top + offset - session.positionCompensation.bottom);
4343
break;
4444
case 'e':
4545
coords.set('left', position.left + offset - session.positionCompensation.left);
@@ -54,19 +54,19 @@ function PlacementCalculator() {
5454
coords.set('right', session.windowWidth - position.left + offset - session.positionCompensation.right);
5555
break;
5656
case 'nw':
57-
coords.set('top', position.top - tipHeight - offset - session.positionCompensation.top);
57+
coords.set('bottom', session.windowHeight - position.top + offset - session.positionCompensation.bottom);
5858
coords.set('right', session.windowWidth - position.left - session.positionCompensation.right - 20);
5959
break;
6060
case 'nw-alt':
6161
coords.set('left', position.left - session.positionCompensation.left);
62-
coords.set('top', position.top - tipHeight - offset - session.positionCompensation.top);
62+
coords.set('bottom', session.windowHeight - position.top + offset - session.positionCompensation.bottom);
6363
break;
6464
case 'ne':
6565
coords.set('left', position.left - session.positionCompensation.left - 20);
66-
coords.set('top', position.top - tipHeight - offset - session.positionCompensation.top);
66+
coords.set('bottom', session.windowHeight - position.top + offset - session.positionCompensation.bottom);
6767
break;
6868
case 'ne-alt':
69-
coords.set('top', position.top - tipHeight - offset - session.positionCompensation.top);
69+
coords.set('bottom', session.windowHeight - position.top + offset - session.positionCompensation.bottom);
7070
coords.set('right', session.windowWidth - position.left - session.positionCompensation.right);
7171
break;
7272
case 'sw':

test/unit/placementcalculator.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ $(function() {
4040
case 'n':
4141
case 'ne':
4242
case 'nw-alt':
43+
assert.strictEqual(coords.top, 'auto', key + ': top property is set to auto');
44+
assert.strictEqual($.isNumeric(coords.left), true, key + ': left property is set to a number');
45+
assert.strictEqual(coords.right, 'auto', key + ': right property is set to auto');
46+
assert.strictEqual($.isNumeric(coords.bottom), true, key + ': bottom property is set to a number');
47+
break;
4348
case 'e':
4449
case 's':
4550
case 'se':
@@ -52,13 +57,18 @@ $(function() {
5257
case 'w':
5358
case 'sw':
5459
case 'se-alt':
55-
case 'nw':
56-
case 'ne-alt':
5760
assert.strictEqual($.isNumeric(coords.top), true, key + ': top property is set to a number');
5861
assert.strictEqual(coords.left, 'auto', key + ': left property is set to auto');
5962
assert.strictEqual($.isNumeric(coords.right), true, key + ': right property is set to a number');
6063
assert.strictEqual(coords.bottom, 'auto', key + ': bottom property is set to auto');
6164
break;
65+
case 'nw':
66+
case 'ne-alt':
67+
assert.strictEqual(coords.top, 'auto', key + ': top property is set to auto');
68+
assert.strictEqual(coords.left, 'auto', key + ': left property is set to auto');
69+
assert.strictEqual($.isNumeric(coords.right), true, key + ': right property is set to a number');
70+
assert.strictEqual($.isNumeric(coords.bottom), true, key + ': bottom property is set to a number');
71+
break;
6272
}
6373
});
6474
});

0 commit comments

Comments
 (0)