Merge pull request #37 from sorvell/master

g-component and g-panels minor changes
This commit is contained in:
Frankie Fu
2012-11-14 11:25:29 -08:00
3 changed files with 24 additions and 18 deletions

View File

@@ -300,7 +300,7 @@ license that can be found in the LICENSE file.
// filter out 'mustached' values, these are to be // filter out 'mustached' values, these are to be
// replaced with bound-data and are not runtime // replaced with bound-data and are not runtime
// values themselves // values themselves
if (value.indexOf(bindModel.mustache) >= 0) { if (value.search(bindModel.mustache) >= 0) {
return; return;
} }
// deserialize Boolean or Number values from attribute // deserialize Boolean or Number values from attribute

View File

@@ -66,7 +66,7 @@
var fromPanel = this.panelAtIndex(this.lastIndex), var fromPanel = this.panelAtIndex(this.lastIndex),
toPanel = this.panelAtIndex(this.index), toPanel = this.panelAtIndex(this.index),
forward = Boolean(this.index > this.lastIndex); forward = Boolean(this.index > this.lastIndex);
if (this.canTransition() && fromPanel && toPanel) { if (this.canTransition(fromPanel, toPanel, forward)) {
this.beginTransition(fromPanel, toPanel, forward); this.beginTransition(fromPanel, toPanel, forward);
} else { } else {
this.finishTransition(fromPanel, toPanel, forward); this.finishTransition(fromPanel, toPanel, forward);
@@ -144,9 +144,9 @@
get count() { get count() {
return this.getPanels().length; return this.getPanels().length;
}, },
canTransition: function() { canTransition: function(inFrom, inTo, inForward) {
return Boolean(this.transitionNode && return Boolean(this.transitionNode && inFrom && inTo &&
this.transitionNode.canTransition()); this.transitionNode.canTransition(inFrom, inTo, inForward));
}, },
beginTransition: function(inFrom, inTo, inForward) { beginTransition: function(inFrom, inTo, inForward) {
if (this.transitionNode) { if (this.transitionNode) {
@@ -168,7 +168,9 @@
// note: cannot use hidden attr for this since it's trumped by display // note: cannot use hidden attr for this since it's trumped by display
// setting e.g. hidden + display: -webkit-flex == showing. // setting e.g. hidden + display: -webkit-flex == showing.
enablePanelShowing: function(inPanel, inEnable) { enablePanelShowing: function(inPanel, inEnable) {
inPanel.style.display = inEnable ? null : 'none'; if (inPanel) {
inPanel.style.display = inEnable ? null : 'none';
}
}, },
next: function() { next: function() {
this.index++; this.index++;

View File

@@ -6,8 +6,6 @@
*/ */
--> -->
<element name="g-panel-transition"> <element name="g-panel-transition">
<!-- remove blank template when polyfill issue #62 is fixed -->
<template></template>
<script> <script>
this.component({ this.component({
prototype: { prototype: {
@@ -15,29 +13,35 @@
timeout: 1000, timeout: 1000,
//* indicates only one panel should be displayed at a time. //* indicates only one panel should be displayed at a time.
highlander: true, highlander: true,
// TODO(sorvell): promote to g-component?
get base() { get base() {
return this.__proto__.__proto__; return this.__proto__.__proto__;
}, },
setup: function(inPanels) { setup: function(inPanels) {
this.panels = inPanels; this.panels = inPanels;
var showing;
this.panels.getPanels().forEach(function(p, i) { this.panels.getPanels().forEach(function(p, i) {
p.classList.add(this.transitionClass); this.setupPanel(p, i);
showing = !this.highlander || (i == inPanels.index);
this.panels.enablePanelShowing(p, showing);
}, this); }, this);
this.finishListener = this.finish.bind(this); this.finishListener = this.finish.bind(this);
}, },
teardown: function() { teardown: function() {
this.panels.getPanels().forEach(function(p, i) { this.panels.getPanels().forEach(function(p, i) {
p.classList.remove(this.transitionClass); this.teardownPanel(p, i);
p.style.opacity = p.style.webkitTransform = null;
if (this.highlander) {
this.panels.enablePanelShowing(p, true);
};
}, this); }, this);
}, },
setupPanel: function(inPanel, inIndex) {
if (this.transitionClass) {
inPanel.classList.add(this.transitionClass);
}
var showing = !this.highlander || (inIndex == this.panels.index);
this.panels.enablePanelShowing(inPanel, showing);
},
teardownPanel: function(inPanel, inIndex) {
inPanel.classList.remove(this.transitionClass);
inPanel.style.opacity = inPanel.style.webkitTransform = null;
if (this.highlander) {
this.panels.enablePanelShowing(inPanel, true);
};
},
canTransition: function() { canTransition: function() {
return true; return true;
}, },