update components

This commit is contained in:
Luke Pulverenti 2016-04-27 00:22:32 -04:00
parent ff79304dee
commit 2ff0f16136
11 changed files with 99 additions and 68 deletions

View file

@ -1,6 +1,6 @@
{
"name": "iron-overlay-behavior",
"version": "1.6.3",
"version": "1.6.4",
"license": "http://polymer.github.io/LICENSE.txt",
"description": "Provides a behavior for making an element an overlay",
"private": true,
@ -35,11 +35,11 @@
},
"ignore": [],
"homepage": "https://github.com/polymerelements/iron-overlay-behavior",
"_release": "1.6.3",
"_release": "1.6.4",
"_resolution": {
"type": "version",
"tag": "v1.6.3",
"commit": "5b331ebaefe3214937b94ba19769154efee46244"
"tag": "v1.6.4",
"commit": "983654132fd8281c3da07d79eea8a0f5b28e7a4f"
},
"_source": "git://github.com/polymerelements/iron-overlay-behavior.git",
"_target": "^1.0.0",

View file

@ -1,6 +1,6 @@
{
"name": "iron-overlay-behavior",
"version": "1.6.3",
"version": "1.6.4",
"license": "http://polymer.github.io/LICENSE.txt",
"description": "Provides a behavior for making an element an overlay",
"private": true,

View file

@ -113,7 +113,9 @@ context. You should place this element as a child of `<body>` whenever possible.
},
/**
* Returns the reason this dialog was last closed.
* Contains the reason(s) this overlay was last closed (see `iron-overlay-closed`).
* `IronOverlayBehavior` provides the `canceled` reason; implementers of the
* behavior can provide other reasons in addition to `canceled`.
*/
closingReason: {
// was a getter before, but needs to be a property so other
@ -322,16 +324,23 @@ context. You should place this element as a child of `<body>` whenever possible.
this._manager.addOrRemoveOverlay(this);
this.__isAnimating = true;
// requestAnimationFrame for non-blocking rendering
if (this.__openChangedAsync) {
window.cancelAnimationFrame(this.__openChangedAsync);
}
// Defer any animation-related code on attached
// (_openedChanged gets called again on attached).
if (!this.isAttached) {
return;
}
this.__isAnimating = true;
if (this.opened) {
if (this.withBackdrop) {
this.backdropElement.prepare();
}
// requestAnimationFrame for non-blocking rendering
this.__openChangedAsync = window.requestAnimationFrame(function() {
this.__openChangedAsync = null;
this._prepareRenderOpened();
@ -574,24 +583,26 @@ context. You should place this element as a child of `<body>` whenever possible.
Polymer.IronOverlayBehavior = [Polymer.IronFitBehavior, Polymer.IronResizableBehavior, Polymer.IronOverlayBehaviorImpl];
/**
* Fired after the `iron-overlay` opens.
* @event iron-overlay-opened
*/
* Fired after the overlay opens.
* @event iron-overlay-opened
*/
/**
* Fired when the `iron-overlay` is canceled, but before it is closed.
* Cancel the event to prevent the `iron-overlay` from closing.
* @event iron-overlay-canceled
* @param {Event} event The closing of the `iron-overlay` can be prevented
* by calling `event.preventDefault()`. The `event.detail` is the original event that originated
* the canceling (e.g. ESC keyboard event or click event outside the `iron-overlay`).
*/
* Fired when the overlay is canceled, but before it is closed.
* @event iron-overlay-canceled
* @param {Event} event The closing of the overlay can be prevented
* by calling `event.preventDefault()`.
* @param {Event} event.detail It is the original event that originated
* the canceling (e.g. ESC keyboard event or click event outside the overlay).
*/
/**
* Fired after the `iron-overlay` closes.
* @event iron-overlay-closed
* @param {{canceled: (boolean|undefined)}} closingReason Contains `canceled` (whether the overlay was canceled).
*/
* Fired after the overlay closes.
* @event iron-overlay-closed
* @param {Event} event The event
* @param {Object} event.detail It is the `closingReason` property (contains
* `canceled`, whether the overlay was canceled).
*/
})();
</script>

View file

@ -339,6 +339,12 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
var overlay = /** @type {?} */ (this.currentOverlay());
// Check if clicked outside of top overlay.
if (overlay && this._overlayInPath(Polymer.dom(event).path) !== overlay) {
if (overlay.withBackdrop) {
// There's no need to stop the propagation as the backdrop element
// already got this mousedown/touchstart event. Calling preventDefault
// on this event ensures that click/tap won't be triggered at all.
event.preventDefault();
}
overlay._onCaptureClick(event);
}
},

View file

@ -155,6 +155,21 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
assert.equal(getComputedStyle(overlay).display, 'none', 'overlay starts hidden');
});
test('_renderOpened called only after is attached', function(done) {
var overlay = document.createElement('test-overlay');
// The overlay is ready at this point, but not yet attached.
var spy = sinon.spy(overlay, '_renderOpened');
// This triggers _openedChanged.
overlay.opened = true;
// Even if not attached yet, overlay should be the current overlay!
assert.equal(overlay, overlay._manager.currentOverlay(), 'currentOverlay ok');
// Wait long enough for requestAnimationFrame callback.
overlay.async(function() {
assert.isFalse(spy.called, '_renderOpened not called');
done();
}, 100);
});
test('overlay open/close events', function(done) {
var nevents = 0;
@ -751,6 +766,27 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
done();
});
});
test('withBackdrop = true prevents click outside event', function(done) {
runAfterOpen(overlay, function() {
overlay.addEventListener('iron-overlay-canceled', function(event) {
assert.isTrue(event.detail.defaultPrevented, 'click event prevented');
done();
});
MockInteractions.tap(document.body);
});
});
test('withBackdrop = false does not prevent click outside event', function(done) {
overlay.withBackdrop = false;
runAfterOpen(overlay, function() {
overlay.addEventListener('iron-overlay-canceled', function(event) {
assert.isFalse(event.detail.defaultPrevented, 'click event not prevented');
done();
});
MockInteractions.tap(document.body);
});
});
});
suite('multiple overlays', function() {