Closed aleesteele closed 5 years ago
The Oceans spotlight header is not an appropriate example to use here; the use cases are entirely different. A better example from Oceans is looking at how the Scrollytelling map midway down the page is included as that's the same use case as what you're working with here. Trade Guys has a wrapper class already included in the styles that should get you started with making the content full width. However, you might need to make some calculation adjustments based on the different sized left/right margins on the post page. But re my previous comment, in no circumstances should you need to put any HTML content outside of the post body.
Please review the Codepen I sent you regarding the text. It's fine if you want to transition the opacity as the text comes into view, but the CSS properties you're using for it aren't going to accomplish the effect that we want.
The text container doesn't need to have position sticky on it. The thing that we're stickying is the container holding the plane/map SVGs. The idea is to have that section stick while the text continues to scroll over top of it. If you look at the Codepen, it has a barebones example of how the HTML should be structured and the accompanying CSS to get you started.
Regarding your comments - thank you so much, @jnschrag.
position: sticky
(and removed it from the scroll-text
class). However, I'm having some trouble with the sticky effect. The idea is that the within the boeing-scroll
div, the boeing-svg
will stick to the top of the page, while the scroll-text
boxes scroll within the div. Once the div reaches the waypoint at the top of the wrapper div, it is replaced by the next text-box. //edit: fixed somewhat.@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:
<span class="part" data-part="forward-fuselage">forward fuselage</span>
Where data-part="forward-fuselage"
can be replaced with the ID of the correct part.
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.
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.