2015-06-19 09:36:51 -07:00
<!doctype html>
<!--
@license
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
< html >
< head >
< title > iron-fit-behavior tests< / title >
< meta charset = "utf-8" >
< meta http-equiv = "X-UA-Compatible" content = "IE=edge,chrome=1" >
< meta name = "viewport" content = "width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes" >
< script src = "../../webcomponentsjs/webcomponents.js" > < / script >
< script src = "../../web-component-tester/browser.js" > < / script >
< link rel = "import" href = "test-fit.html" >
< style >
body {
margin: 0;
padding: 0;
}
.absolute {
position: absolute;
top: 0;
left: 0;
}
.scrolling {
overflow: auto;
}
.sized-x {
2016-05-03 19:18:05 -07:00
width: 100px;
2015-06-19 09:36:51 -07:00
}
.sized-y {
2016-05-03 19:18:05 -07:00
height: 100px;
2016-02-24 14:18:53 -07:00
}
2015-06-19 09:36:51 -07:00
.positioned-left {
position: absolute;
left: 100px;
}
.positioned-right {
position: absolute;
right: 100px;
}
.positioned-top {
position: absolute;
top: 100px;
}
.positioned-bottom {
position: absolute;
bottom: 100px;
}
.with-max-width {
max-width: 500px;
}
.with-max-height {
max-height: 500px;
}
.with-margin {
margin: 20px;
}
2016-05-03 19:18:05 -07:00
.constrain {
position: fixed;
top: 20px;
left: 20px;
width: 150px;
height: 150px;
border: 1px solid black;
box-sizing: border-box;
}
2015-06-19 09:36:51 -07:00
< / style >
< / head >
< body >
2016-05-03 19:18:05 -07:00
< div class = "constrain" > < / div >
2016-02-24 14:18:53 -07:00
2015-06-19 09:36:51 -07:00
< test-fixture id = "absolute" >
< template >
< test-fit auto-fit-on-attach class = "absolute" >
Absolutely positioned
< / test-fit >
< / template >
< / test-fixture >
< test-fixture id = "sized-xy" >
< template >
< test-fit auto-fit-on-attach class = "sized-x sized-y" >
Sized (x/y), auto center/center
< / test-fit >
< / template >
< / test-fixture >
< test-fixture id = "sized-x" >
< template >
< test-fit auto-fit-on-attach class = "sized-x" >
Sized (x), auto center/center
< / test-fit >
< / template >
< / test-fixture >
< test-fixture id = "positioned-xy" >
< template >
< test-fit auto-fit-on-attach class = "sized-x positioned-left positioned-top" >
Sized (x/y), positioned/positioned
< / test-fit >
< / template >
< / test-fixture >
< test-fixture id = "inline-positioned-xy" >
< template >
2015-06-25 18:13:51 -07:00
< test-fit auto-fit-on-attach class = "sized-x sized-y" style = "position:absolute;left:100px;top:100px;" >
2015-06-19 09:36:51 -07:00
Sized (x/y), positioned/positioned
< / test-fit >
< / template >
< / test-fixture >
< test-fixture id = "sectioned" >
< template >
< test-fit auto-fit-on-attach class = "sized-x" >
< div >
Sized (x), auto center/center with scrolling section
< / div >
< div class = "internal" > < / div >
< / test-fit >
< / template >
< / test-fixture >
< test-fixture id = "constrain-target" >
< template >
2016-05-03 19:18:05 -07:00
< div class = "constrain" >
< test-fit auto-fit-on-attach class = "el sized-x sized-y" >
2015-06-19 09:36:51 -07:00
< div >
Auto center/center to parent element
< / div >
< / test-fit >
< / div >
< / template >
< / test-fixture >
2015-12-14 08:43:03 -07:00
< test-fixture id = "offscreen-container" >
< template >
< div style = "position: fixed; top: -1px; left: 0;" >
< test-fit auto-fit-on-attach class = "el sized-x" >
< div >
Sized (x), auto center/center, container is offscreen
< / div >
< / test-fit >
< / div >
< / template >
< / test-fixture >
2015-06-19 09:36:51 -07:00
< template id = "ipsum" >
< p > Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.< / p >
< / template >
< script >
function makeScrolling(el) {
el.classList.add('scrolling');
var template = document.getElementById('ipsum');
for (var i = 0; i < 20 ; i + + ) {
el.appendChild(template.content.cloneNode(true));
}
}
2016-05-03 19:18:05 -07:00
function intersects(r1, r2) {
return !(r2.left >= r1.right || r2.right < = r1.left || r2.top >= r1.bottom || r2.bottom < = r1.top);
}
2015-06-19 09:36:51 -07:00
suite('manual positioning', function() {
test('css positioned element is not re-positioned', function() {
var el = fixture('positioned-xy');
var rect = el.getBoundingClientRect();
assert.equal(rect.top, 100, 'top is unset');
assert.equal(rect.left, 100, 'left is unset');
2015-06-25 18:13:51 -07:00
2015-06-19 09:36:51 -07:00
});
test('inline positioned element is not re-positioned', function() {
var el = fixture('inline-positioned-xy');
var rect = el.getBoundingClientRect();
// need to measure document.body here because mocha sets a min-width on html,body, and
// the element is positioned wrt to that by css
var bodyRect = document.body.getBoundingClientRect();
2015-06-25 18:13:51 -07:00
assert.equal(rect.top, 100, 'top is unset');
assert.equal(rect.left, 100, 'left is unset');
el.refit();
rect = el.getBoundingClientRect();
assert.equal(rect.top, 100, 'top is unset after refit');
assert.equal(rect.left, 100, 'left is unset after refit');
2015-06-19 09:36:51 -07:00
});
test('position property is preserved after', function() {
var el = fixture('absolute');
assert.equal(getComputedStyle(el).position, 'absolute', 'position:absolute is preserved');
2015-06-25 18:13:51 -07:00
});
2015-06-19 09:36:51 -07:00
});
suite('fit to window', function() {
test('sized element is centered in viewport', function() {
var el = fixture('sized-xy');
var rect = el.getBoundingClientRect();
assert.closeTo(rect.left - (window.innerWidth - rect.right), 0, 5, 'centered horizontally');
assert.closeTo(rect.top - (window.innerHeight - rect.bottom), 0, 5, 'centered vertically');
});
test('sized element with margin is centered in viewport', function() {
var el = fixture('sized-xy');
el.classList.add('with-margin');
el.refit();
var rect = el.getBoundingClientRect();
assert.closeTo(rect.left - (window.innerWidth - rect.right), 0, 5, 'centered horizontally');
assert.closeTo(rect.top - (window.innerHeight - rect.bottom), 0, 5, 'centered vertically');
});
2016-02-24 14:18:53 -07:00
test('sized element with transformed parent is centered in viewport', function() {
var constrain = fixture('constrain-target');
var el = Polymer.dom(constrain).querySelector('.el');
var rectBefore = el.getBoundingClientRect();
constrain.style.transform = 'translate3d(5px, 5px, 0)';
el.center();
var rectAfter = el.getBoundingClientRect();
assert.equal(rectBefore.top, rectAfter.top, 'top ok');
assert.equal(rectBefore.bottom, rectAfter.bottom, 'bottom ok');
assert.equal(rectBefore.left, rectAfter.left, 'left ok');
assert.equal(rectBefore.right, rectAfter.right, 'right ok');
});
2015-06-19 09:36:51 -07:00
test('scrolling element is centered in viewport', function() {
var el = fixture('sized-x');
makeScrolling(el);
el.refit();
var rect = el.getBoundingClientRect();
assert.closeTo(rect.left - (window.innerWidth - rect.right), 0, 5, 'centered horizontally');
assert.closeTo(rect.top - (window.innerHeight - rect.bottom), 0, 5, 'centered vertically');
});
test('scrolling element is constrained to viewport height', function() {
var el = fixture('sized-x');
makeScrolling(el);
el.refit();
var rect = el.getBoundingClientRect();
assert.isTrue(rect.height < = window.innerHeight, 'height is less than or equal to viewport height');
});
2015-12-14 08:43:03 -07:00
test('scrolling element with offscreen container is constrained to viewport height', function() {
var container = fixture('offscreen-container');
var el = Polymer.dom(container).querySelector('.el')
makeScrolling(el);
el.refit();
var rect = el.getBoundingClientRect();
assert.isTrue(rect.height < = window.innerHeight, 'height is less than or equal to viewport height');
});
2015-06-19 09:36:51 -07:00
test('scrolling element with max-height is centered in viewport', function() {
var el = fixture('sized-x');
el.classList.add('with-max-height');
makeScrolling(el);
el.refit();
var rect = el.getBoundingClientRect();
assert.closeTo(rect.left - (window.innerWidth - rect.right), 0, 5, 'centered horizontally');
assert.closeTo(rect.top - (window.innerHeight - rect.bottom), 0, 5, 'centered vertically');
});
test('scrolling element with max-height respects max-height', function() {
var el = fixture('sized-x');
el.classList.add('with-max-height');
makeScrolling(el);
el.refit();
var rect = el.getBoundingClientRect();
assert.isTrue(rect.height < = 500, 'height is less than or equal to max-height');
});
test('css positioned, scrolling element is constrained to viewport height (top,left)', function() {
var el = fixture('positioned-xy');
makeScrolling(el);
el.refit();
var rect = el.getBoundingClientRect();
assert.isTrue(rect.height < = window.innerHeight - 100, 'height is less than or equal to viewport height');
});
test('css positioned, scrolling element is constrained to viewport height (bottom, right)', function() {
var el = fixture('sized-x');
el.classList.add('positioned-bottom');
el.classList.add('positioned-right');
el.refit();
var rect = el.getBoundingClientRect();
assert.isTrue(rect.height < = window.innerHeight - 100, 'height is less than or equal to viewport height');
});
test('sized, scrolling element with margin is centered in viewport', function() {
var el = fixture('sized-x');
el.classList.add('with-margin');
makeScrolling(el);
el.refit();
var rect = el.getBoundingClientRect();
assert.closeTo(rect.left - (window.innerWidth - rect.right), 0, 5, 'centered horizontally');
assert.closeTo(rect.top - (window.innerHeight - rect.bottom), 0, 5, 'centered vertically');
});
test('sized, scrolling element is constrained to viewport height', function() {
var el = fixture('sized-x');
el.classList.add('with-margin');
makeScrolling(el);
el.refit();
var rect = el.getBoundingClientRect();
assert.isTrue(rect.height < = window.innerHeight - 20 * 2, 'height is less than or equal to viewport height');
});
test('css positioned, scrolling element with margin is constrained to viewport height (top, left)', function() {
var el = fixture('positioned-xy');
el.classList.add('with-margin');
makeScrolling(el);
el.refit();
var rect = el.getBoundingClientRect();
assert.isTrue(rect.height < = window.innerHeight - 100 - 20 * 2, 'height is less than or equal to viewport height');
});
test('css positioned, scrolling element with margin is constrained to viewport height (bottom, right)', function() {
var el = fixture('sized-x');
el.classList.add('positioned-bottom');
el.classList.add('positioned-right');
el.classList.add('with-margin')
el.refit();
var rect = el.getBoundingClientRect();
assert.isTrue(rect.height < = window.innerHeight - 100 - 20 * 2, 'height is less than or equal to viewport height');
});
test('scrolling sizingTarget is constrained to viewport height', function() {
el = fixture('sectioned');
var internal = Polymer.dom(el).querySelector('.internal');
el.sizingTarget = internal;
makeScrolling(internal);
el.refit();
var rect = el.getBoundingClientRect();
assert.isTrue(rect.height < = window.innerHeight, 'height is less than or equal to viewport height');
});
});
suite('fit to element', function() {
test('element fits in another element', function() {
var constrain = fixture('constrain-target');
var el = Polymer.dom(constrain).querySelector('.el')
makeScrolling(el);
el.fitInto = constrain;
el.refit();
var rect = el.getBoundingClientRect();
var crect = constrain.getBoundingClientRect();
assert.isTrue(rect.height < = crect.height, 'width is less than or equal to fitInto width');
assert.isTrue(rect.height < = crect.height, 'height is less than or equal to fitInto height');
});
2015-06-25 18:13:51 -07:00
test('element centers in another element', function() {
var constrain = fixture('constrain-target');
2016-05-03 19:18:05 -07:00
var el = Polymer.dom(constrain).querySelector('.el');
2015-06-25 18:13:51 -07:00
makeScrolling(el);
el.fitInto = constrain;
el.refit();
var rect = el.getBoundingClientRect();
var crect = constrain.getBoundingClientRect();
assert.closeTo(rect.left - crect.left - (crect.right - rect.right), 0, 5, 'centered horizontally in fitInto');
assert.closeTo(rect.top - crect.top - (crect.bottom - rect.bottom), 0, 5, 'centered vertically in fitInto');
});
2016-02-24 14:18:53 -07:00
test('element with max-width centers in another element', function() {
2016-05-03 19:18:05 -07:00
var constrain = document.querySelector('.constrain');
var el = fixture('sized-xy');
el.classList.add('with-max-width');
2016-02-24 14:18:53 -07:00
el.fitInto = constrain;
el.refit();
var rect = el.getBoundingClientRect();
var crect = constrain.getBoundingClientRect();
assert.closeTo(rect.left - crect.left - (crect.right - rect.right), 0, 5, 'centered horizontally in fitInto');
assert.closeTo(rect.top - crect.top - (crect.bottom - rect.bottom), 0, 5, 'centered vertically in fitInto');
});
2015-06-19 09:36:51 -07:00
});
2016-05-03 19:18:05 -07:00
suite('horizontal/vertical align', function() {
var parent, parentRect;
var el, elRect;
var fitRect = {
left: 0,
top: 0,
right: window.innerWidth,
bottom: window.innerHeight,
width: window.innerWidth,
height: window.innerHeight
};
setup(function() {
parent = fixture('constrain-target');
parentRect = parent.getBoundingClientRect();
el = Polymer.dom(parent).querySelector('.el');
elRect = el.getBoundingClientRect();
});
test('intersects works', function() {
var base = {top: 0, bottom: 1, left:0, right: 1};
assert.isTrue(intersects(base, base), 'intersects itself');
assert.isFalse(intersects(base, {top:1, bottom: 2, left: 0, right: 1}), 'no intersect on edge');
assert.isFalse(intersects(base, {top:-2, bottom: -1, left: 0, right: 1}), 'no intersect on edge (negative values)');
assert.isFalse(intersects(base, {top:2, bottom: 3, left: 0, right: 1}), 'no intersect');
});
suite('when verticalAlign is top', function() {
test('element is aligned to the positionTarget top', function() {
el.verticalAlign = 'top';
el.refit();
var rect = el.getBoundingClientRect();
assert.equal(rect.top, parentRect.top, 'top ok');
assert.equal(rect.height, elRect.height, 'no cropping');
});
test('element is aligned to the positionTarget top without overlapping it', function() {
// Allow enough space on the parent's bottom & right.
parent.style.width = '10px';
parent.style.height = '10px';
parentRect = parent.getBoundingClientRect();
el.verticalAlign = 'top';
el.noOverlap = true;
el.refit();
var rect = el.getBoundingClientRect();
assert.isFalse(intersects(rect, parentRect), 'no overlap');
assert.equal(rect.height, elRect.height, 'no cropping');
});
test('verticalOffset is applied', function() {
el.verticalAlign = 'top';
el.verticalOffset = 10;
el.refit();
var rect = el.getBoundingClientRect();
assert.equal(rect.top, parentRect.top + 10, 'top ok');
assert.equal(rect.height, elRect.height, 'no cropping');
});
test('max-height is updated', function() {
parent.style.top = '-10px';
el.verticalAlign = 'top';
el.refit();
var rect = el.getBoundingClientRect();
assert.equal(rect.top, 0, 'top ok');
assert.isBelow(rect.height, elRect.height, 'height ok');
});
test('min-height is respected: element is hidden if does not have enough height', function() {
parent.style.top = '-10px';
el.verticalAlign = 'top';
el.style.minHeight = elRect.height + 'px';
el.refit();
var rect = el.getBoundingClientRect();
assert.isFalse(intersects(rect, fitRect), 'not visible');
});
});
suite('when verticalAlign is bottom', function() {
test('element is aligned to the positionTarget bottom', function() {
el.verticalAlign = 'bottom';
el.refit();
var rect = el.getBoundingClientRect();
assert.equal(rect.bottom, parentRect.bottom, 'bottom ok');
assert.equal(rect.height, elRect.height, 'no cropping');
});
test('element is aligned to the positionTarget bottom without overlapping it', function() {
el.verticalAlign = 'bottom';
el.noOverlap = true;
el.refit();
var rect = el.getBoundingClientRect();
assert.isFalse(intersects(rect, parentRect), 'no overlap');
assert.equal(rect.height, elRect.height, 'no cropping');
});
test('verticalOffset is applied', function() {
el.verticalAlign = 'bottom';
el.verticalOffset = 10;
el.refit();
var rect = el.getBoundingClientRect();
assert.equal(rect.bottom, parentRect.bottom - 10, 'bottom ok');
assert.equal(rect.height, elRect.height, 'no cropping');
});
test('element max-height is updated', function() {
parent.style.top = (100 - parentRect.height) + 'px';
el.verticalAlign = 'bottom';
el.refit();
var rect = el.getBoundingClientRect();
assert.equal(rect.bottom, 100, 'bottom ok');
assert.equal(rect.height, 100, 'height ok');
});
test('min-height is respected: element is hidden if does not have enough height', function() {
parent.style.top = (elRect.height - 10 - parentRect.height) + 'px';
el.verticalAlign = 'bottom';
el.style.minHeight = elRect.height + 'px';
el.refit();
var rect = el.getBoundingClientRect();
assert.isFalse(intersects(rect, fitRect), 'not visible');
});
});
suite('when verticalAlign is auto', function() {
test('element is aligned to the positionTarget top', function() {
el.verticalAlign = 'auto';
el.refit();
var rect = el.getBoundingClientRect();
assert.equal(rect.top, parentRect.top, 'auto aligned to top');
assert.equal(rect.height, elRect.height, 'no cropping');
});
test('element is aligned to the positionTarget top without overlapping it', function() {
// Allow enough space on the parent's bottom & right.
parent.style.width = '10px';
parent.style.height = '10px';
parentRect = parent.getBoundingClientRect();
el.verticalAlign = 'auto';
el.noOverlap = true;
el.refit();
var rect = el.getBoundingClientRect();
assert.equal(rect.height, elRect.height, 'no cropping');
assert.isFalse(intersects(rect, parentRect), 'no overlap');
});
test('bottom is preferred to top if it diminishes the cropped area', function() {
// This would cause a cropping of the element, so it should automatically
// align to the bottom to avoid it.
parent.style.top = '-10px';
parentRect = parent.getBoundingClientRect();
el.verticalAlign = 'auto';
el.refit();
var rect = el.getBoundingClientRect();
assert.equal(rect.bottom, parentRect.bottom, 'auto aligned to bottom');
assert.equal(rect.height, elRect.height, 'no cropping');
});
test('bottom is preferred to top if it diminishes the cropped area, without overlapping positionTarget', function() {
// This would cause a cropping of the element, so it should automatically
// align to the bottom to avoid it.
parent.style.top = '-10px';
parentRect = parent.getBoundingClientRect();
el.verticalAlign = 'auto';
el.noOverlap = true;
el.refit();
var rect = el.getBoundingClientRect();
assert.equal(rect.height, elRect.height, 'no cropping');
assert.isFalse(intersects(rect, parentRect), 'no overlap');
});
});
suite('when horizontalAlign is left', function() {
test('element is aligned to the positionTarget left', function() {
el.horizontalAlign = 'left';
el.refit();
var rect = el.getBoundingClientRect();
assert.equal(rect.left, parentRect.left, 'left ok');
assert.equal(rect.width, elRect.width, 'no cropping');
});
test('element is aligned to the positionTarget left without overlapping it', function() {
// Make space at the parent's right.
parent.style.width = '10px';
parentRect = parent.getBoundingClientRect();
el.horizontalAlign = 'left';
el.noOverlap = true;
el.refit();
var rect = el.getBoundingClientRect();
assert.isFalse(intersects(rect, parentRect), 'no overlap');
assert.equal(rect.width, elRect.width, 'no cropping');
});
test('horizontalOffset is applied', function() {
el.horizontalAlign = 'left';
el.horizontalOffset = 10;
el.refit();
var rect = el.getBoundingClientRect();
assert.equal(rect.left, parentRect.left + 10, 'left ok');
assert.equal(rect.width, elRect.width, 'no cropping');
});
test('element max-width is updated', function() {
parent.style.left = '-10px';
el.horizontalAlign = 'left';
el.refit();
var rect = el.getBoundingClientRect();
assert.equal(rect.left, 0, 'left ok');
assert.isBelow(rect.width, elRect.width, 'width ok');
});
test('min-width is respected: element is hidden if does not have enough width', function() {
parent.style.left = '-10px';
el.style.minWidth = elRect.width + 'px';
el.horizontalAlign = 'left';
el.refit();
var rect = el.getBoundingClientRect();
assert.isFalse(intersects(rect, fitRect), 'not visible');
});
});
suite('when horizontalAlign is right', function() {
test('element is aligned to the positionTarget right', function() {
el.horizontalAlign = 'right';
el.refit();
var rect = el.getBoundingClientRect();
assert.equal(rect.right, parentRect.right, 'right ok');
assert.equal(rect.width, elRect.width, 'no cropping');
});
test('element is aligned to the positionTarget right without overlapping it', function() {
// Make space at the parent's left.
parent.style.left = elRect.width + 'px';
parentRect = parent.getBoundingClientRect();
el.horizontalAlign = 'right';
el.noOverlap = true;
el.refit();
var rect = el.getBoundingClientRect();
assert.isFalse(intersects(rect, parentRect), 'no overlap');
assert.equal(rect.width, elRect.width, 'no cropping');
});
test('horizontalOffset is applied', function() {
el.horizontalAlign = 'right';
el.horizontalOffset = 10;
el.refit();
var rect = el.getBoundingClientRect();
assert.equal(rect.right, parentRect.right - 10, 'right ok');
assert.equal(rect.width, elRect.width, 'no cropping');
});
test('element max-width is updated', function() {
parent.style.left = (100 - parentRect.width) + 'px';
el.horizontalAlign = 'right';
el.refit();
var rect = el.getBoundingClientRect();
assert.equal(rect.right, 100, 'right ok');
assert.equal(rect.width, 100, 'width ok');
});
test('min-width is respected: element is hidden if does not have enough width', function() {
parent.style.left = (elRect.width - 10 - parentRect.width) + 'px';
el.horizontalAlign = 'right';
el.style.minWidth = elRect.width + 'px';
el.refit();
var rect = el.getBoundingClientRect();
assert.isFalse(intersects(rect, fitRect), 'not visible');
});
});
suite('when horizontalAlign is auto', function() {
test('element is aligned to the positionTarget left', function() {
el.horizontalAlign = 'auto';
el.refit();
var rect = el.getBoundingClientRect();
assert.equal(rect.left, parentRect.left, 'auto aligned to left');
assert.equal(rect.width, elRect.width, 'no cropping');
});
test('element is aligned to the positionTarget left without overlapping positionTarget', function() {
// Make space at the parent's left.
parent.style.left = elRect.width + 'px';
parentRect = parent.getBoundingClientRect();
el.horizontalAlign = 'auto';
el.noOverlap = true;
el.refit();
var rect = el.getBoundingClientRect();
assert.equal(rect.width, elRect.width, 'no cropping');
assert.isFalse(intersects(rect, parentRect), 'no overlap');
});
test('right is preferred to left if it diminishes the cropped area', function() {
// This would cause a cropping of the element, so it should automatically
// align to the right to avoid it.
parent.style.left = '-10px';
parentRect = parent.getBoundingClientRect();
el.horizontalAlign = 'auto';
el.refit();
var rect = el.getBoundingClientRect();
assert.equal(rect.right, parentRect.right, 'auto aligned to right');
assert.equal(rect.width, elRect.width, 'no cropping');
});
test('right is preferred to left if it diminishes the cropped area, without overlapping positionTarget', function() {
// Make space at the parent's right.
parent.style.width = '10px';
parentRect = parent.getBoundingClientRect();
el.horizontalAlign = 'auto';
el.noOverlap = true;
el.refit();
var rect = el.getBoundingClientRect();
assert.equal(rect.width, elRect.width, 'no cropping');
assert.isFalse(intersects(rect, parentRect), 'no overlap');
});
});
});
2015-06-19 09:36:51 -07:00
< / script >
< / body >
< / html >