diff --git a/demo/index.html b/demo/index.html index 4765d46..3cb8bc5 100644 --- a/demo/index.html +++ b/demo/index.html @@ -17,11 +17,23 @@
-

Basic flip-element Demo

- +

Basic <flip-element>

+ + + +

flip-right backface-visible

+ + @@ -109,48 +108,54 @@ type: String, value: '100%' }, - _front: { + /** If true, the child with the `front` attribute is shown, else, the child with the `back` attribute is shown. */ + isFrontSide: { type: Boolean, - value: true + value: true, + reflectToAttribute: true + }, + /** Whether to flip the back element to the right of the front element. */ + flipRight: { + type: Boolean, + value: false, + reflectToAttribute: true + }, + /** Whether a side should remain visible (but mirrored) when being flipped to the back. */ + backfaceVisible: { + type: Boolean, + value: false, + reflectToAttribute: true } }, - _applyStyles: function() { + _computeSize: function() { if (this.getContentChildren('content')) { var height = 0; var width = 0; + for (var i = 0; this.getContentChildren('content').length > i; i++) { var child = this.getContentChildren('content')[i]; - height = child.clientHeight > height ? child.clientHeight : height; - width = child.clientWidth > width ? child.clientWidth : width; - child.style['backface-visibility'] = 'hidden'; - child.style['position'] = 'absolute'; - if (child.hasAttribute('back')) { - child.style.transform = 'rotateY(180deg)'; - child.style['-moz-backface-visibility'] = 'hidden'; - } + height = Math.max(height, child.clientHeight); + width = Math.max(width, child.clientWidth); } + this._height = height ? height + 'px' : '100%'; this._width = width ? width + 'px' : '100%'; - this.updateStyles(); } }, attached: function() { var host = this; this._observer = Polymer.dom(this.$.contentNode).observeNodes(function(info) { - host._applyStyles(); + host._computeSize(); }); }, + /** + * Shows the front side if the back side is currently shown and vice versa. + */ flip: function() { - this._front = !this._front; - document.querySelector('.card'); - this.$.card.classList.toggle('flipped'); - }, - - isFrontSide: function() { - return this._front; + this.isFrontSide = !this.isFrontSide; } });