Skip to content

Commit

Permalink
Fix for Safari 6.
Browse files Browse the repository at this point in the history
  • Loading branch information
mbostock committed Aug 14, 2012
1 parent 7247639 commit 03b83e8
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions stack.v0.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ var stack = (function() {
timeout, timeout,
duration = 250, duration = 250,
ease = "cubic-in-out", ease = "cubic-in-out",
screenX,
screenY, screenY,
size, size,
yActual, yActual,
Expand All @@ -18,13 +17,6 @@ var stack = (function() {
yOffset, yOffset,
n = section[0].length; 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. // Invert the z-index so the earliest slides are on top.
section.classed("stack", true).style("z-index", function(d, i) { return n - i; }); section.classed("stack", true).style("z-index", function(d, i) { return n - i; });


Expand Down Expand Up @@ -66,7 +58,9 @@ var stack = (function() {
.on("mousemove.stack", snap); .on("mousemove.stack", snap);


resize(); resize();
setTimeout(scroll, 10);
body.scrollTop = 1;
setTimeout(load, 10);


// if scrolling up, jump to edge of previous slide // if scrolling up, jump to edge of previous slide
function leap(yNew) { function leap(yNew) {
Expand All @@ -89,6 +83,13 @@ var stack = (function() {
.style("height", (n - .5) * size + yOffset + "px"); .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() { function keydown() {
var delta; var delta;
switch (d3.event.keyCode) { switch (d3.event.keyCode) {
Expand Down Expand Up @@ -148,9 +149,9 @@ var stack = (function() {
} }


function snap() { function snap() {
var x = d3.event.screenX, y = d3.event.screenY; var y = d3.event.clientY;
if (x === screenX && y === screenY) return; // ignore move on scroll if (y === screenY) return; // ignore move on scroll
screenX = x, screenY = y; screenY = y;


if (yTarget != null) return; // don't snap if already snapping if (yTarget != null) return; // don't snap if already snapping


Expand Down

0 comments on commit 03b83e8

Please sign in to comment.