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-panels minor bug fixes #29

Merged
merged 1 commit into from
Oct 29, 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
34 changes: 16 additions & 18 deletions src/g-panels.html
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -129,19 +133,16 @@
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;
this.transitionNode.go(inFrom, inTo, inForward);
}.bind(this));
},
finishTransition: function() {
this.transitionInfo = null;
if (this.transitionNode && this.transitionNode.highlander) {
this.getPanels().forEach(function(p, i) {
p.hidden = (i != this.index);
Expand All @@ -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();
}
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/panel-transitions/g-panel-transition.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
*/
-->
<element name="g-panel-transition">
<!-- remove blank template when polyfill issue #62 is fixed -->
<template></template>
<script>
this.component({
prototype: {
Expand Down