Skip to content

Instantly share code, notes, and snippets.

@zlwaterfield
Last active October 26, 2019 22:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zlwaterfield/20a8d510d01f7e9f36c54af3a48379de to your computer and use it in GitHub Desktop.
Save zlwaterfield/20a8d510d01f7e9f36c54af3a48379de to your computer and use it in GitHub Desktop.
scale() {
// At 350px screen width the pathHeight coefficient should be 1
const startPathHeight = 1;
const startScreenWidth = 350;
// At 450px screen width the pathHeight coefficient should be .69
const midPathHeight = .69;
const midScreenWidth = 450;
// At 600px screen width the pathHeight coefficient should be .48
const endPathHeight = .48;
const endScreenWidth = 600;
const lgWidth = 1204;
const onResize = () => {
let pathHeight;
if (window.innerWidth < midScreenWidth) {
pathHeight = startPathHeight + (((startPathHeight - midPathHeight) / (Math.pow(midScreenWidth, .1) - Math.pow(startScreenWidth, .1))) * (Math.pow(startScreenWidth, .1) - Math.pow(window.innerWidth, .1)));
} else if (window.innerWidth < endScreenWidth) {
pathHeight = midPathHeight + (((midPathHeight - endPathHeight) / (Math.pow(endScreenWidth, .1) - Math.pow(midScreenWidth, .1))) * (Math.pow(midScreenWidth, .1) - Math.pow(window.innerWidth, .1)));
} else if (window.innerWidth > lgWidth) {
pathHeight = 8;
} else {
pathHeight = 78 - 2 * Math.sqrt(window.innerWidth);
}
this.pathHeight = +pathHeight.toFixed(4);
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment