Last active
June 20, 2022 10:41
-
-
Save kobitoDevelopment/a76c6efe32fcad6d12a7c7f475489f9c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (function () { | |
| const setSize = 360; // 希望のviewport下限を設定 | |
| const viewport = document.querySelector("meta[name='viewport']"); | |
| function adjustViewport() { | |
| /* | |
| 三項演算子(条件演算子) | |
| condition ? exprIfTrue(trueに変換できる値) : exprIfFalse(falseに変換できる値) | |
| */ | |
| const value = window.outerWidth > setSize ? "width=device-width,initial-scale=1" : "width=" + setSize; | |
| if (viewport.getAttribute("content") !== value) { | |
| viewport.setAttribute("content", value); | |
| } | |
| } | |
| addEventListener("resize", adjustViewport); | |
| adjustViewport(); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment