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.
As a business owner, have you ever wondered when your customer's first impression of yo...
By Skye Jun 6, 2023We're excited to announce improvements to the threaded messaging experience in our communi...
By TyW May 31, 2023Thank you to everyone who participated in our AMA with Klaviyo. It was great to see so man...
By Jacqui May 30, 2023