Permalink
Browse files

Fix for Safari 6.

  • Loading branch information...
1 parent 7247639 commit 03b83e8b7f9fdf87f72d6ca33ac48f369b873572 @mbostock committed Aug 14, 2012
Showing with 13 additions and 12 deletions.
  1. +13 −12 stack.v0.js
View
25 stack.v0.js
@@ -8,7 +8,6 @@ var stack = (function() {
timeout,
duration = 250,
ease = "cubic-in-out",
- screenX,
screenY,
size,
yActual,
@@ -18,13 +17,6 @@ var stack = (function() {
yOffset,
n = section[0].length;
- // Detect whether to scroll with documentElement or body.
- body.style.height = window.innerHeight + 1 + "px";
- body.scrollTop = 1;
- if (!body.scrollTop) root = document.documentElement;
- else body.scrollTop = 0;
- body.style.height = "auto";
-
// Invert the z-index so the earliest slides are on top.
section.classed("stack", true).style("z-index", function(d, i) { return n - i; });
@@ -66,7 +58,9 @@ var stack = (function() {
.on("mousemove.stack", snap);
resize();
- setTimeout(scroll, 10);
+
+ body.scrollTop = 1;
+ setTimeout(load, 10);
// if scrolling up, jump to edge of previous slide
function leap(yNew) {
@@ -89,6 +83,13 @@ var stack = (function() {
.style("height", (n - .5) * size + yOffset + "px");
}
+ // Detect whether to scroll with documentElement or body.
+ function load() {
+ if (!body.scrollTop) root = document.documentElement;
+ else body.scrollTop = 0;
+ scroll();
+ }
+
function keydown() {
var delta;
switch (d3.event.keyCode) {
@@ -148,9 +149,9 @@ var stack = (function() {
}
function snap() {
- var x = d3.event.screenX, y = d3.event.screenY;
- if (x === screenX && y === screenY) return; // ignore move on scroll
- screenX = x, screenY = y;
+ var y = d3.event.clientY;
+ if (y === screenY) return; // ignore move on scroll
+ screenY = y;
if (yTarget != null) return; // don't snap if already snapping

0 comments on commit 03b83e8

Please sign in to comment.