diff --git a/src/g-panels.html b/src/g-panels.html
index 56965449c7..92fb8a6ac1 100644
--- a/src/g-panels.html
+++ b/src/g-panels.html
@@ -25,6 +25,10 @@
}
}
+ // TODO(sorvell): need key table
+ var KEY_RIGHT_ARROW = 39;
+ var KEY_LEFT_ARROW = 37;
+
this.component({
created: function() {
this.initPanels();
@@ -53,7 +57,7 @@
var fromPanel = this.panelAtIndex(this.lastIndex),
toPanel = this.panelAtIndex(this.index),
forward = Boolean(this.index > this.lastIndex);
- if (this.canTransition()) {
+ if (this.canTransition() && fromPanel && toPanel) {
this.beginTransition(fromPanel, toPanel, forward);
} else {
this.finishTransition(fromPanel, toPanel, forward);
@@ -129,11 +133,9 @@
return Boolean(this.transitionNode);
},
beginTransition: function(inFrom, inTo, inForward) {
- var old = this.transitionInfo;
- if (old && this.transitionNode) {
+ if (this.transitionNode) {
this.transitionNode.stop();
}
- this.transitionInfo = {from: inFrom, to: inTo, forward: inForward};
webkitRequestAnimationFrame(function() {
inFrom.hidden = false;
inTo.hidden = false;
@@ -141,7 +143,6 @@
}.bind(this));
},
finishTransition: function() {
- this.transitionInfo = null;
if (this.transitionNode && this.transitionNode.highlander) {
this.getPanels().forEach(function(p, i) {
p.hidden = (i != this.index);
@@ -155,19 +156,16 @@
this.index--;
},
keydownHandler: function(e) {
- if (documentIsEditing()) {
- return;
- }
- var i = this.index;
- // right arrow
- if (e.keyCode == 39) {
- this.next();
- // left arrow
- } else if (e.keyCode == 37) {
- this.previous();
- }
- if (i != this.index) {
- e.stopPropagation();
+ if (!documentIsEditing()) {
+ var beforeIndex = this.index;
+ if (e.keyCode == KEY_RIGHT_ARROW) {
+ this.next();
+ } else if (e.keyCode == KEY_LEFT_ARROW) {
+ this.previous();
+ }
+ if (beforeIndex != this.index) {
+ e.stopPropagation();
+ }
}
}
}
diff --git a/src/panel-transitions/g-panel-transition.html b/src/panel-transitions/g-panel-transition.html
index 8c03373c9a..8840e73ae5 100644
--- a/src/panel-transitions/g-panel-transition.html
+++ b/src/panel-transitions/g-panel-transition.html
@@ -6,6 +6,8 @@
*/
-->
+
+