Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Double quotes, hashchange, don't snap when position is already set

  • Loading branch information...
commit 4ecab1bbddc74a0eb7754d3c20fd5db7a48ba933 1 parent f6e0669
@tmcw tmcw authored
Showing with 10 additions and 6 deletions.
  1. +10 −6 stack.v0.js
View
16 stack.v0.js
@@ -45,7 +45,7 @@ var stack = (function() {
.each("end", function() { yTarget = null; self.on("scroll.stack", scroll); });
}
- location.replace('#' + y1);
+ location.replace("#" + y1);
return stack;
};
@@ -57,13 +57,12 @@ var stack = (function() {
.on("keydown.stack", keydown)
.on("resize.stack", resize)
.on("scroll.stack", scroll)
- .on("mousemove.stack", snap);
+ .on("mousemove.stack", snap)
+ .on("hashchange.stack", hashchange);
resize();
scroll();
-
- var hash = +location.hash.slice(1);
- if (!isNaN(hash)) stack.position(hash);
+ hashchange();
// if scrolling up, jump to edge of previous slide
function leap(yNew) {
@@ -86,6 +85,11 @@ var stack = (function() {
.style("height", (n - .5) * size + yOffset + "px");
}
+ function hashchange() {
+ var hash = +location.hash.slice(1);
+ if (!isNaN(hash)) stack.position(hash);
+ }
+
function keydown() {
var delta;
switch (d3.event.keyCode) {
@@ -165,7 +169,7 @@ var stack = (function() {
if (y1 > y0 && y1 - y0 < .5 - yOffset / size) scrollTo(0, y1 * size);
// else transition
- else stack.position(y1);
+ else if (y1 !== y0) stack.position(y1);
}
function tween(y) {
Please sign in to comment.
Something went wrong with that request. Please try again.