CSIS-iLab / trade_guys

Trade Guys landing page/web hub
https://tradeguys.csis.org
MIT License
0 stars 3 forks source link

Boeing viz/starting waypoints #69

Closed aleesteele closed 5 years ago

aleesteele commented 5 years ago

I'm currently editing this for code explanations - was helping Sarah with a longform issue!

Note; unfortunately I have to run for a while, and this isn't totally, really ready to be PR'd, but some of the logic here needs some explanations, I think.

jnschrag commented 5 years ago
aleesteele commented 5 years ago

Regarding your comments - thank you so much, @jnschrag.

jnschrag commented 5 years ago

@aleesteele

Thank you for submitting this and removing the unnecessary logic. The idea to group the plane parts along with their labels is a good one, and something we discussed early on so I'm glad you're implementing it. However, there are a few syntax bugs in the CSS & JS that are preventing this from working and allowing me to check this more thoroughly.

There's also still some confusion over the fundamental structure of how this should be set up. I know this is something you're still working on per your note above, but since we're running out of time to get this finished, I've created this Codepen which implements the structure and the basic CSS for how this should be set up. Please use this code as a starting point and restructure your code accordingly. I've left comments that hopefully explain a little bit more how this code works.

If you follow the Codepen above, you should only need to use Waypoints to trigger the hiding/showing of the new plane parts, which will simplify your JS quite a bit. You do not need it to trigger the sticky position or to update any text.

I wanted to talk about how to implement the JS part in-person, but since that wasn't possible this week, here is something to consider. Rather than selecting every element and manually calling each new Waypoint, think of how you can use loops to make this task easier. I would approach it like this:

All together, it should look something like this:

// Select all of the scrollytelling text
const paragraphs = Array.from(document.querySelectorAll('.scroll-text'))

// Loop through each of the paragraphs to apply a Waypoint that is triggered when they come into view
paragraphs.forEach(paragraph => {
  // Get all the parts in that paragraph
  const parts = paragraph.querySelectorAll('.part')
  new Waypoint({
    element: paragraph,
    handler: direction => {
      Array.from(parts).forEach(part => {
        // Get Data attribute and use that to select the part of the plane. Then adjust the class as necessary.
      })
    }
  })
})

If you're unclear about any of the code here, please talk with Leeza who can give you further clarity or we can discuss this when we get back.