Last change
on this file since 571e0df was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
823 bytes
|
Line | |
---|
1 | var utils = require('../utils')
|
---|
2 | , nodes = require('../nodes');
|
---|
3 |
|
---|
4 | /**
|
---|
5 | * Return the opposites of the given `positions`.
|
---|
6 | *
|
---|
7 | * Examples:
|
---|
8 | *
|
---|
9 | * opposite-position(top left)
|
---|
10 | * // => bottom right
|
---|
11 | *
|
---|
12 | * @param {Expression} positions
|
---|
13 | * @return {Expression}
|
---|
14 | * @api public
|
---|
15 | */
|
---|
16 |
|
---|
17 | (module.exports = function oppositePosition(positions){
|
---|
18 | var expr = [];
|
---|
19 | utils.unwrap(positions).nodes.forEach(function(pos, i){
|
---|
20 | utils.assertString(pos, 'position ' + i);
|
---|
21 | pos = (function(){ switch (pos.string) {
|
---|
22 | case 'top': return 'bottom';
|
---|
23 | case 'bottom': return 'top';
|
---|
24 | case 'left': return 'right';
|
---|
25 | case 'right': return 'left';
|
---|
26 | case 'center': return 'center';
|
---|
27 | default: throw new Error('invalid position ' + pos);
|
---|
28 | }})();
|
---|
29 | expr.push(new nodes.Literal(pos));
|
---|
30 | });
|
---|
31 | return expr;
|
---|
32 | }).raw = true;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.