Skip to content

Commit

Permalink
Merge pull request #37 from sorvell/master
Browse files Browse the repository at this point in the history
g-component and g-panels minor changes
  • Loading branch information
frankiefu committed Nov 14, 2012
2 parents 60a091a + eb8e6b7 commit 6fc1a4a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/g-component.html
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@
// filter out 'mustached' values, these are to be
// replaced with bound-data and are not runtime
// values themselves
if (value.indexOf(bindModel.mustache) >= 0) {
if (value.search(bindModel.mustache) >= 0) {
return;
}
// deserialize Boolean or Number values from attribute
Expand Down
12 changes: 7 additions & 5 deletions src/g-panels.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
var fromPanel = this.panelAtIndex(this.lastIndex),
toPanel = this.panelAtIndex(this.index),
forward = Boolean(this.index > this.lastIndex);
if (this.canTransition() && fromPanel && toPanel) {
if (this.canTransition(fromPanel, toPanel, forward)) {
this.beginTransition(fromPanel, toPanel, forward);
} else {
this.finishTransition(fromPanel, toPanel, forward);
Expand Down Expand Up @@ -144,9 +144,9 @@
get count() {
return this.getPanels().length;
},
canTransition: function() {
return Boolean(this.transitionNode &&
this.transitionNode.canTransition());
canTransition: function(inFrom, inTo, inForward) {
return Boolean(this.transitionNode && inFrom && inTo &&
this.transitionNode.canTransition(inFrom, inTo, inForward));
},
beginTransition: function(inFrom, inTo, inForward) {
if (this.transitionNode) {
Expand All @@ -168,7 +168,9 @@
// note: cannot use hidden attr for this since it's trumped by display
// setting e.g. hidden + display: -webkit-flex == showing.
enablePanelShowing: function(inPanel, inEnable) {
inPanel.style.display = inEnable ? null : 'none';
if (inPanel) {
inPanel.style.display = inEnable ? null : 'none';
}
},
next: function() {
this.index++;
Expand Down
28 changes: 16 additions & 12 deletions src/panel-transitions/g-panel-transition.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,42 @@
*/
-->
<element name="g-panel-transition">
<!-- remove blank template when polyfill issue #62 is fixed -->
<template></template>
<script>
this.component({
prototype: {
transitionClass: 'transition',
timeout: 1000,
//* indicates only one panel should be displayed at a time.
highlander: true,
// TODO(sorvell): promote to g-component?
get base() {
return this.__proto__.__proto__;
},
setup: function(inPanels) {
this.panels = inPanels;
var showing;
this.panels.getPanels().forEach(function(p, i) {
p.classList.add(this.transitionClass);
showing = !this.highlander || (i == inPanels.index);
this.panels.enablePanelShowing(p, showing);
this.setupPanel(p, i);
}, this);
this.finishListener = this.finish.bind(this);
},
teardown: function() {
this.panels.getPanels().forEach(function(p, i) {
p.classList.remove(this.transitionClass);
p.style.opacity = p.style.webkitTransform = null;
if (this.highlander) {
this.panels.enablePanelShowing(p, true);
};
this.teardownPanel(p, i);
}, 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() {
return true;
},
Expand Down

0 comments on commit 6fc1a4a

Please sign in to comment.