Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

g-component and g-panels minor changes #37

Merged
merged 2 commits into from
Nov 14, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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