mirror of
https://github.com/jakejarvis/jarv.is.git
synced 2025-09-13 07:55:32 -04:00
improved touchscreen detection
This commit is contained in:
@@ -1,7 +1,15 @@
|
|||||||
// Heavily inspired by AnchorJS: https://github.com/bryanbraun/anchorjs
|
// Heavily inspired by AnchorJS:
|
||||||
|
// https://github.com/bryanbraun/anchorjs
|
||||||
|
|
||||||
|
import isTouchDevice from "is-touch-device";
|
||||||
|
|
||||||
// loop through each h2, h3, h4 in this page's content area
|
// loop through each h2, h3, h4 in this page's content area
|
||||||
document.querySelectorAll(["div#content h2", "div#content h3", "div#content h4"]).forEach((h) => {
|
// prettier-ignore
|
||||||
|
document.querySelectorAll([
|
||||||
|
"div#content h2",
|
||||||
|
"div#content h3",
|
||||||
|
"div#content h4",
|
||||||
|
]).forEach((h) => {
|
||||||
// don't add to elements without a pre-existing ID (e.g. `<h2 id="...">`)
|
// don't add to elements without a pre-existing ID (e.g. `<h2 id="...">`)
|
||||||
if (!h.hasAttribute("id")) {
|
if (!h.hasAttribute("id")) {
|
||||||
return;
|
return;
|
||||||
@@ -15,7 +23,7 @@ document.querySelectorAll(["div#content h2", "div#content h3", "div#content h4"]
|
|||||||
|
|
||||||
// if this is a touchscreen, always show the "#" icon instead waiting for hover
|
// if this is a touchscreen, always show the "#" icon instead waiting for hover
|
||||||
// NOTE: this is notoriously unreliable; see https://github.com/Modernizr/Modernizr/pull/2432
|
// NOTE: this is notoriously unreliable; see https://github.com/Modernizr/Modernizr/pull/2432
|
||||||
if ("ontouchstart" in window) {
|
if (isTouchDevice()) {
|
||||||
anchor.style.opacity = "1";
|
anchor.style.opacity = "1";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -38,6 +38,7 @@
|
|||||||
"get-stream": "^6.0.1",
|
"get-stream": "^6.0.1",
|
||||||
"html-entities": "^2.3.2",
|
"html-entities": "^2.3.2",
|
||||||
"imagemoji": "^0.1.4",
|
"imagemoji": "^0.1.4",
|
||||||
|
"is-touch-device": "^1.0.1",
|
||||||
"modern-normalize": "github:sindresorhus/modern-normalize#1fc6b5a86676b7ac8abc62d04d6080f92debc70f",
|
"modern-normalize": "github:sindresorhus/modern-normalize#1fc6b5a86676b7ac8abc62d04d6080f92debc70f",
|
||||||
"node-fetch": "^3.1.0",
|
"node-fetch": "^3.1.0",
|
||||||
"p-retry": "^5.0.0",
|
"p-retry": "^5.0.0",
|
||||||
@@ -85,7 +86,7 @@
|
|||||||
"postcss-focus": "^5.0.1",
|
"postcss-focus": "^5.0.1",
|
||||||
"postcss-loader": "^6.2.1",
|
"postcss-loader": "^6.2.1",
|
||||||
"postcss-svgo": "^5.0.3",
|
"postcss-svgo": "^5.0.3",
|
||||||
"prettier": "~2.5.0",
|
"prettier": "~2.5.1",
|
||||||
"sass": "^1.44.0",
|
"sass": "^1.44.0",
|
||||||
"sass-loader": "^12.3.0",
|
"sass-loader": "^12.3.0",
|
||||||
"simple-git-hooks": "^2.7.0",
|
"simple-git-hooks": "^2.7.0",
|
||||||
|
30
yarn.lock
30
yarn.lock
@@ -2409,6 +2409,11 @@ chalk@^4.0, chalk@^4.0.0, chalk@^4.1.0, chalk@^4.1.1, chalk@^4.1.2:
|
|||||||
ansi-styles "^4.1.0"
|
ansi-styles "^4.1.0"
|
||||||
supports-color "^7.1.0"
|
supports-color "^7.1.0"
|
||||||
|
|
||||||
|
chalk@^5.0.0:
|
||||||
|
version "5.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/chalk/-/chalk-5.0.0.tgz#bd96c6bb8e02b96e08c0c3ee2a9d90e050c7b832"
|
||||||
|
integrity sha512-/duVOqst+luxCQRKEo4bNxinsOQtMP80ZYm7mMqzuh5PociNL0PvmHFvREJ9ueYL2TxlHjBcmLCdmocx9Vg+IQ==
|
||||||
|
|
||||||
"chokidar@>=3.0.0 <4.0.0", chokidar@^3.5.2:
|
"chokidar@>=3.0.0 <4.0.0", chokidar@^3.5.2:
|
||||||
version "3.5.2"
|
version "3.5.2"
|
||||||
resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.5.2.tgz#dba3976fcadb016f66fd365021d91600d01c1e75"
|
resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.5.2.tgz#dba3976fcadb016f66fd365021d91600d01c1e75"
|
||||||
@@ -5762,6 +5767,11 @@ is-symbol@^1.0.2, is-symbol@^1.0.3:
|
|||||||
dependencies:
|
dependencies:
|
||||||
has-symbols "^1.0.2"
|
has-symbols "^1.0.2"
|
||||||
|
|
||||||
|
is-touch-device@^1.0.1:
|
||||||
|
version "1.0.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/is-touch-device/-/is-touch-device-1.0.1.tgz#9a2fd59f689e9a9bf6ae9a86924c4ba805a42eab"
|
||||||
|
integrity sha512-LAYzo9kMT1b2p19L/1ATGt2XcSilnzNlyvq6c0pbPRVisLbAPpLqr53tIJS00kvrTkj0HtR8U7+u8X0yR8lPSw==
|
||||||
|
|
||||||
is-typedarray@^1.0.0:
|
is-typedarray@^1.0.0:
|
||||||
version "1.0.0"
|
version "1.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a"
|
resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a"
|
||||||
@@ -5774,7 +5784,7 @@ is-unc-path@^1.0.0:
|
|||||||
dependencies:
|
dependencies:
|
||||||
unc-path-regex "^0.1.2"
|
unc-path-regex "^0.1.2"
|
||||||
|
|
||||||
is-unicode-supported@^1.0.0:
|
is-unicode-supported@^1.1.0:
|
||||||
version "1.1.0"
|
version "1.1.0"
|
||||||
resolved "https://registry.yarnpkg.com/is-unicode-supported/-/is-unicode-supported-1.1.0.tgz#9127b71f9fa82f52ca5c20e982e7bec0ee31ee1e"
|
resolved "https://registry.yarnpkg.com/is-unicode-supported/-/is-unicode-supported-1.1.0.tgz#9127b71f9fa82f52ca5c20e982e7bec0ee31ee1e"
|
||||||
integrity sha512-lDcxivp8TJpLG75/DpatAqNzOpDPSpED8XNtrpBHTdQ2InQ1PbW78jhwSxyxhhu+xbVSast2X38bwj8atwoUQA==
|
integrity sha512-lDcxivp8TJpLG75/DpatAqNzOpDPSpED8XNtrpBHTdQ2InQ1PbW78jhwSxyxhhu+xbVSast2X38bwj8atwoUQA==
|
||||||
@@ -6272,12 +6282,12 @@ lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.20:
|
|||||||
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==
|
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==
|
||||||
|
|
||||||
log-symbols@^5.0.0:
|
log-symbols@^5.0.0:
|
||||||
version "5.0.0"
|
version "5.1.0"
|
||||||
resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-5.0.0.tgz#7720d3c6a56c365e1f658916069ba18d941092ca"
|
resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-5.1.0.tgz#a20e3b9a5f53fac6aeb8e2bb22c07cf2c8f16d93"
|
||||||
integrity sha512-zBsSKauX7sM0kcqrf8VpMRPqcWzU6a/Wi7iEl0QlVSCiIZ4CctaLdfVdiZUn6q2/nenyt392qJqpw9FhNAwqxQ==
|
integrity sha512-l0x2DvrW294C9uDCoQe1VSU4gf529FkSZ6leBl4TiqZH/e+0R7hSfHQBNut2mNygDgHwvYHfFLn6Oxb3VWj2rA==
|
||||||
dependencies:
|
dependencies:
|
||||||
chalk "^4.1.0"
|
chalk "^5.0.0"
|
||||||
is-unicode-supported "^1.0.0"
|
is-unicode-supported "^1.1.0"
|
||||||
|
|
||||||
log-update@^4.0.0:
|
log-update@^4.0.0:
|
||||||
version "4.0.0"
|
version "4.0.0"
|
||||||
@@ -7888,10 +7898,10 @@ prettier-linter-helpers@^1.0.0:
|
|||||||
dependencies:
|
dependencies:
|
||||||
fast-diff "^1.1.2"
|
fast-diff "^1.1.2"
|
||||||
|
|
||||||
prettier@~2.5.0:
|
prettier@~2.5.1:
|
||||||
version "2.5.0"
|
version "2.5.1"
|
||||||
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.5.0.tgz#a6370e2d4594e093270419d9cc47f7670488f893"
|
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.5.1.tgz#fff75fa9d519c54cf0fce328c1017d94546bc56a"
|
||||||
integrity sha512-FM/zAKgWTxj40rH03VxzIPdXmj39SwSjwG0heUcNFwI+EMZJnY93yAiKXM3dObIKAM5TA88werc8T/EwhB45eg==
|
integrity sha512-vBZcPRUR5MZJwoyi3ZoyQlc1rXeEck8KgeC9AwwOn+exuxLxq5toTRDTSaVrXHxelDMHy9zlicw8u66yxoSUFg==
|
||||||
|
|
||||||
pretty-bytes@^5.6.0:
|
pretty-bytes@^5.6.0:
|
||||||
version "5.6.0"
|
version "5.6.0"
|
||||||
|
Reference in New Issue
Block a user