Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
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.
Contact paull.newton+shopifyforum@gmail.com for the solutions you need
Save time & money ,Ask Questions The Smart Way
Problem Solved? ✔Accept and Like solutions to help future merchants
Answers powered by coffee Thank Paul with 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.
Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024Hey Community! It’s time to share some appreciation and celebrate what we have accomplis...
By JasonH Nov 14, 2024