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.
Save time & money ,Ask Questions The Smart Way
Confused? Busy? Get the solution you need paull.newton+shopifyforum@gmail.com
Problem Solved? ✔Accept and Like solutions to help future merchants
Answers powered by coffee Buy Paul a ☕ Coffee for more answers or donate to eff.org
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 |
---|---|
38 | |
29 | |
13 | |
12 | |
9 |
On our Shopify Expert Marketplace, you can find many trusted third party developers and fr...
By Arno Nov 27, 2023You've downloaded the Search & Discovery app from the Shopify App store, and as you're ...
By Skye Nov 8, 2023The year-end shopping season is just around the corner. Is a flash sale on your radar? Are...
By Jasonh Nov 6, 2023