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

Ch/qa scrolling #458

Merged
merged 6 commits into from
Jan 3, 2018
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion packages/microcosm-www-next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"gatsby-link": "^1.6.22",
"gatsby-plugin-react-helmet": "^1.0.8",
"gatsby-plugin-sass": "^1.0.12",
"react-intersection-observer": "^2.0.3"
"intersection-observer": "^0.5.0"
},
"keywords": [
"gatsby"
Expand Down
1 change: 1 addition & 0 deletions packages/microcosm-www-next/src/layouts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Link from 'gatsby-link'
import Helmet from 'react-helmet'
import VigetLogo from '../components/viget-logo'

import 'intersection-observer'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

polyfill

import '../stylesheets/app.scss'

const Navigation = () => (
Expand Down
30 changes: 23 additions & 7 deletions packages/microcosm-www-next/src/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ export default class IndexPage extends React.Component {
}
}

componentWillMount() {
this.sections = this.createSectionsArray()
}

componentDidMount() {
this.setVars()
this.beginObserve()
Expand All @@ -27,6 +31,16 @@ export default class IndexPage extends React.Component {
}
}

createSectionsArray() {
let arr = []

for (let i = 0; i < this.state.numSections; i++) {
arr.push(i + 1)
}

return arr
}

beginObserve() {
//create new Observer instance
let observer = new IntersectionObserver(
Expand All @@ -35,7 +49,9 @@ export default class IndexPage extends React.Component {
)

//start observing each graphic
this.graphics.forEach(graphic => observer.observe(graphic))
for (let i = 0; i < this.graphics.length; i++) {
Copy link
Author

@ccchwang ccchwang Dec 22, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed this to a for loop because it wasn't working in IE

observer.observe(this.graphics[i])
}
}

onIntersection = observed => {
Expand Down Expand Up @@ -90,7 +106,9 @@ export default class IndexPage extends React.Component {

<div className="toggle-container">
<h3
className={'section__content__subheading -bottom' + browserClass}
className={
'section__content__subheading -bottom' + browserClass
}
>
Meanwhile, in
</h3>
Expand All @@ -102,11 +120,9 @@ export default class IndexPage extends React.Component {
</div>

<div className="section__graphic">
{Array(this.state.numSections)
.fill()
.map((el, i) => (
<Graphic key={i} section={i + 1} graphicUrl={graphicUrl} />
))}
{this.sections.map(el => (
<Graphic key={el} section={el} graphicUrl={graphicUrl} />
))}
</div>
</section>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ $split-bg-height-desktop: 291px;

body {
background-color: color(bg-1-bottom);
position: relative;
transition: transition(background-color);

&::before { //top of half split bg
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ $cta-bottom-padding: 6px;

@include breakpoint(large-desktop-up) {
position: fixed;

@media (max-height: 900px) { // if browser is shorter than 900px, don't fix footer to bottom
position: absolute;
}
}

.wrapper {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,49 @@ $section-top-padding-desktop: $nav-height + 110px;

@include breakpoint(large-desktop-up) {
display: flex;
justify-content: space-between;
padding-top: $section-top-padding-desktop;

@supports (position: sticky) or (position: -webkit-sticky) {
justify-content: space-between;
}
}
}

// CONTENT

.section__content {
height: 100%;
position: sticky;
top: $section-top-padding-mobile;
padding-right: 20px;
position: fixed;
width: 100%;

@include breakpoint(large-desktop-up) {
flex-basis: 45%;
order: 2;
top: $section-top-padding-desktop;
right: 2%;
width: 45%;
}

@supports (position: sticky) or (position: -webkit-sticky) {
padding-right: 0;
position: -webkit-sticky;
position: sticky;
top: $section-top-padding-mobile;

@include breakpoint(large-desktop-up) {
order: 2;
top: $section-top-padding-desktop;
}
}
}


// CONTENT - containers

.text-container {
margin: 0 auto rem(50);
margin-bottom: rem(50);
max-width: 550px;

@include breakpoint(medium-desktop-down) {
margin: 0 auto rem(50);
padding-left: rem(40);
}
}
Expand Down Expand Up @@ -151,9 +168,17 @@ $section-top-padding-desktop: $nav-height + 110px;
// GRAPHIC

.section__graphic {
@include breakpoint(medium-desktop-down) {
padding-top: 30vh;
}

@include breakpoint(large-desktop-up) {
flex-basis: 600px;
}

@supports (position: sticky) or (position: -webkit-sticky) {
padding-top: 0;
}
}

.section__graphic__figure {
Expand Down