Liquid, JavaScript, themes, sales channels
I started building out a site about a month ago and I was modifying the Dawn theme. I found a function in global.js that set a viewport height property using window.innerHeight. It was used multiple times in stylesheets.
function viewportHeight() {
const doc = document.documentElement;
doc.style.setProperty('--viewport-height', `${window.innerHeight}px`);
}
window.addEventListener('resize', viewportHeight);
viewportHeight();
I've started another site and went to use that variable but it's not there. The function isn't there and there's no reference to it online. Now I'm not sure if I wrote it myself and completely forgot that I did it, but that wouldn't explain it being used throughout various stylesheets. So I'm sure it was a thing, but tbh I really don't know now.
So now I'd like to know if it was removed for a particular reason (if it was a thing) before I throw it back in and start using it.
I'm so confused.
I had a look in the first commit of the repo for the Dawn theme I initialised. I've actually found the '--viewport-height' being set in the MenuDrawer class in global.js. It's checking if the platform is an iPhone, and then setting the property for stylesheets to reference. It's actually pretty neat.
My confusion must have been when I added the function myself (not knowing it already catered for it), and then seeing references to the property afterwards and being confused as parts of the base stylesheet were referencing the exact property I was setting, therefore getting confused if I actually did add the function myself. lol.
Thanks for the reply anyway.
User | RANK |
---|---|
22 | |
22 | |
10 | |
9 | |
7 |
Thanks to all Community members that participated in our inaugural 2 week AMA on the new E...
By Jacqui Mar 10, 2023Upskill and stand out with the new Shopify Foundations Certification program
By SarahF_Shopify Mar 6, 2023One of the key components to running a successful online business is having clear and co...
By Ollie Mar 6, 2023