Skip to content

Commit

Permalink
was broken in IE 11
Browse files Browse the repository at this point in the history
  • Loading branch information
macfarlandian committed Jan 7, 2021
1 parent 2c6a44a commit fef6345
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 4 additions & 0 deletions spotlight-client/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@
{
"name": "styled-components",
"message": "Please import from styled-components/macro."
},
{
"name": "react-spring",
"message": "For IE 11 support, please import from react-spring/web.cjs"
}
],
"patterns": ["!styled-components/macro"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { Link, useParams } from "@reach/router";
import { format } from "d3-format";
import { rem } from "polished";
import React, { useEffect } from "react";
import { animated, useSpring } from "react-spring";
import { animated, useSpring } from "react-spring/web.cjs";
import styled from "styled-components/macro";
import { NAV_BAR_HEIGHT } from "../constants";
import getUrlForResource from "../routerUtils/getUrlForResource";
Expand Down
10 changes: 5 additions & 5 deletions spotlight-client/src/SystemNarrativePage/SystemNarrativePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import HTMLReactParser from "html-react-parser";
import { rem } from "polished";
import React, { useCallback, useEffect, useRef, useState } from "react";
import { InView } from "react-intersection-observer";
import { useSpring } from "react-spring";
import { useSpring } from "react-spring/web.cjs";
import styled from "styled-components/macro";
import { NAV_BAR_HEIGHT } from "../constants";
import SystemNarrative from "../contentModels/SystemNarrative";
Expand Down Expand Up @@ -98,11 +98,11 @@ const SystemNarrativePage: React.FC<{
[isScrolling]
);
const [, setScrollSpring] = useSpring(() => ({
onFrame: (props: { top: number }) => window.scrollTo({ top: props.top }),
onFrame: (props: { top: number }) => window.scrollTo(0, props.top),
// set the flag while animation is in progress
onRest: () => setIsScrolling(false),
onStart: () => setIsScrolling(true),
to: { top: window.scrollY },
to: { top: window.pageYOffset },
}));

const { tenantId, narrativeTypeId } = normalizeRouteParams(routeParams);
Expand All @@ -117,14 +117,14 @@ const SystemNarrativePage: React.FC<{
);
if (desiredSection) {
scrollDestination =
window.scrollY + desiredSection.getBoundingClientRect().top;
window.pageYOffset + desiredSection.getBoundingClientRect().top;
}

// in practice this should always be defined, this is just type safety
if (scrollDestination !== undefined) {
setScrollSpring({
to: { top: scrollDestination - NAV_BAR_HEIGHT },
from: { top: window.scrollY },
from: { top: window.pageYOffset },
reset: true,
});

Expand Down

0 comments on commit fef6345

Please sign in to comment.