A Team Grid Connected to Collections with Modal Slide In

(Instructions at Bottom)

Team MEmbers

Dahlia Bartell

Dahlia Bartell

CEO

Keven Sanford

Keven Sanford

CFO

Marc Farrell
Abbey Schowalter

Abbey Schowalter

Marketing Leader

Kameron Fritsch

Kameron Fritsch

Sales Leader

Laurence Cruickshank

Laurence Cruickshank

Support Rep

Viola McKenzie

Viola McKenzie

Support Rep

Domenick Carter

Domenick Carter

Support Rep

Bryce Schoen

Bryce Schoen

Support Rep

Toni Kunde

Toni Kunde

Support Rep

Dora Douglas

Dora Douglas

Support Rep

Isabella Mayer

Isabella Mayer

Sales Rep

Nathaniel Oberbrunner

Nathaniel Oberbrunner

Sales Rep

Ismael Skiles

Ismael Skiles

Support Leader

Mya Boyle

Mya Boyle

Support Rep

Frieda VonRueden

Frieda VonRueden

Sales Rep

Sarina Hamill

Sarina Hamill

Sales Rep

Cristopher Schulist

Cristopher Schulist

Sales Rep

Niko Ankunding

Niko Ankunding

Sales Rep

Kevon Reinger

Kevon Reinger

Sales Rep

Instructions

Setup

The Collection List is connected to the Team Members Collection. As most things, there are many ways to do this. However, inside the collection item, you will see a sibling div of the headshot wrap called 'team-modal__wrap' set to display:none. This is the slide in, and since it is tied to the collection item, you can add dynamic content to it.

*Note: when editing and taking off display none from the modal wrap, you may want to limit the items to 1. Otherwise it will show all slide-ins layered on top of one another. If you have a lot of items it will slow down Webflow

Trigger / Animation

The trigger to open the slide-in is on the headshot wrap. In the interactions panel, when choosing Hide/Show for team-modal__wrap, we are only selecting siblings with this class. In doing so, it will only display:flex to sibling wrap, and not any other collection item modals. The rest of the targeted elements are set to 'All Elements With This Class'. We can do this, because Webflows interactions will only see the visible elements with these classes inside of the NOW VISIBLE team-modal__wrap. So it won't trigger animations on all of the other slide-ins.

Setting 'Only siblings with this class' makes it so all other animations will only affect visible elements inside this modal.

Other Notes

Images

There is an HTML embed at the top of this page. It is custom css to fit an image in a div. It is called 'object-fit', and is set to 'cover'. This acts similarly to background-size:cover when working with background images, but allows you to set it on an actual image element instead. Useful for using alt-tags and I've read it can help with images being served at compressed sizes.

*I have this snippet in an embed so I can see the style in action within Webflow editor. If you put it in the page code you won't see its effect until viewing published site.

*** Update 12/21/19 - Webflow added Object Fit into their workflow. This code is not longer needed, however you can control position of images with object-position. For this we have 'top-center'.

Here is the code:

Object Fit
    
     
<style>

.img__cover {
	object-fit: cover; 
	object-position: top center;
}

</style>  
		
    
  
Just make sure you have the class 'img__cover' set on your images.

Stop Body Scrolling

Usually, when you have a fixed element overlaying the screen, when you continue to scroll, the entire page body keeps scrolling. We don't want this. If the team members panel exceeds the height of the browser window, we only want to scroll their bio.

In the custom code panel in the page settings, there is a script before the closing body tag. This script sets the body to overflow:hidden when the trigger is clicked. Notice the class .team--open. We use some javascript to target that class, and when it is clicked, it sets the page body to overflow:hidden, which will make it the same size as the modal wrap (100vh), which is also set to overflow:hidden -- this is to hide the panel slide-in.


Since the team-modal__body is set to overflow:scroll, we are still able to scroll the modal body itself, making it appear that only the panel is scrolling, while not allowing the page body to scroll.

The close button has a class of .team--closer. When this is clicked, the script targets the class and resets the page body to overflow:auto. and now you can scroll the page again.

Here is the script:

Stop Body Scroll
    
     
<script>

// Prevents body scroll on desktop only
Webflow.push(function() {
  $('.team--open').click(function(e) {
    e.preventDefault();
	$('body').css('overflow', 'hidden');
  });

// Reactivates body scroll on desktop only
  $('.team--closer').click(function(e) {
    e.preventDefault();
	$('body').css('overflow', 'auto');
  });
});

</script>  
		
    
  

Mobile Scrolling

To be fully honest, I'm not sure of the best way to do this. I'm not sure of the best way to do anything... But in the page settings in custom code, there is a piece of css for tablet and mobile etc. Mozilla states that this is not a standard, and it may not work for every user, but this activates scrolling on the modal body on touch screens. It seems to work fine without. But if you don't use this, I have noticed some modals getting stuck and not being able to scroll at all.

This is more of a safety precaution?

Here is the code:

Mobile Scroll
    


<style>

	.team-modal__body {
	-webkit-overflow-scrolling: touch;
	}

</style>  
		
    
  

Final Notes

I'm not positive if all of this is correct, better ways to do this etc. I've done it a few different ways.

Thanks!