Fixed scrolling behaviour with auto embed.

This commit is contained in:
flash 2024-05-16 20:07:14 +00:00
parent 3247a46d19
commit f4b43290bb
4 changed files with 90 additions and 78 deletions

128
package-lock.json generated
View file

@ -5,7 +5,7 @@
"packages": {
"": {
"dependencies": {
"@swc/core": "^1.5.3",
"@swc/core": "^1.5.7",
"autoprefixer": "^10.4.19",
"cssnano": "^6.1.2",
"html-minifier-terser": "^7.2.0",
@ -65,13 +65,13 @@
}
},
"node_modules/@swc/core": {
"version": "1.5.3",
"resolved": "https://registry.npmjs.org/@swc/core/-/core-1.5.3.tgz",
"integrity": "sha512-pSEglypnBGLHBoBcv3aYS7IM2t2LRinubYMyP88UoFIcD2pear2CeB15CbjJ2IzuvERD0ZL/bthM7cDSR9g+aQ==",
"version": "1.5.7",
"resolved": "https://registry.npmjs.org/@swc/core/-/core-1.5.7.tgz",
"integrity": "sha512-U4qJRBefIJNJDRCCiVtkfa/hpiZ7w0R6kASea+/KLp+vkus3zcLSB8Ub8SvKgTIxjWpwsKcZlPf5nrv4ls46SQ==",
"hasInstallScript": true,
"dependencies": {
"@swc/counter": "^0.1.2",
"@swc/types": "^0.1.5"
"@swc/types": "0.1.7"
},
"engines": {
"node": ">=10"
@ -81,16 +81,16 @@
"url": "https://opencollective.com/swc"
},
"optionalDependencies": {
"@swc/core-darwin-arm64": "1.5.3",
"@swc/core-darwin-x64": "1.5.3",
"@swc/core-linux-arm-gnueabihf": "1.5.3",
"@swc/core-linux-arm64-gnu": "1.5.3",
"@swc/core-linux-arm64-musl": "1.5.3",
"@swc/core-linux-x64-gnu": "1.5.3",
"@swc/core-linux-x64-musl": "1.5.3",
"@swc/core-win32-arm64-msvc": "1.5.3",
"@swc/core-win32-ia32-msvc": "1.5.3",
"@swc/core-win32-x64-msvc": "1.5.3"
"@swc/core-darwin-arm64": "1.5.7",
"@swc/core-darwin-x64": "1.5.7",
"@swc/core-linux-arm-gnueabihf": "1.5.7",
"@swc/core-linux-arm64-gnu": "1.5.7",
"@swc/core-linux-arm64-musl": "1.5.7",
"@swc/core-linux-x64-gnu": "1.5.7",
"@swc/core-linux-x64-musl": "1.5.7",
"@swc/core-win32-arm64-msvc": "1.5.7",
"@swc/core-win32-ia32-msvc": "1.5.7",
"@swc/core-win32-x64-msvc": "1.5.7"
},
"peerDependencies": {
"@swc/helpers": "^0.5.0"
@ -102,9 +102,9 @@
}
},
"node_modules/@swc/core-darwin-arm64": {
"version": "1.5.3",
"resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.5.3.tgz",
"integrity": "sha512-kRmmV2XqWegzGXvJfVVOj10OXhLgaVOOBjaX3p3Aqg7Do5ksg+bY5wi1gAN/Eul7B08Oqf7GG7WJevjDQGWPOg==",
"version": "1.5.7",
"resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.5.7.tgz",
"integrity": "sha512-bZLVHPTpH3h6yhwVl395k0Mtx8v6CGhq5r4KQdAoPbADU974Mauz1b6ViHAJ74O0IVE5vyy7tD3OpkQxL/vMDQ==",
"cpu": [
"arm64"
],
@ -117,9 +117,9 @@
}
},
"node_modules/@swc/core-darwin-x64": {
"version": "1.5.3",
"resolved": "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.5.3.tgz",
"integrity": "sha512-EYs0+ovaRw6ZN9GBr2nIeC7gUXWA0q4RYR+Og3Vo0Qgv2Mt/XudF44A2lPK9X7M3JIfu6JjnxnTuvsK1Lqojfw==",
"version": "1.5.7",
"resolved": "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.5.7.tgz",
"integrity": "sha512-RpUyu2GsviwTc2qVajPL0l8nf2vKj5wzO3WkLSHAHEJbiUZk83NJrZd1RVbEknIMO7+Uyjh54hEh8R26jSByaw==",
"cpu": [
"x64"
],
@ -132,9 +132,9 @@
}
},
"node_modules/@swc/core-linux-arm-gnueabihf": {
"version": "1.5.3",
"resolved": "https://registry.npmjs.org/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.5.3.tgz",
"integrity": "sha512-RBVUTidSf4wgPdv98VrgJ4rMzMDN/3LBWdT7l+R7mNFH+mtID7ZAhTON0o/m1HkECgAgi1xcbTOVAw1xgd5KLA==",
"version": "1.5.7",
"resolved": "https://registry.npmjs.org/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.5.7.tgz",
"integrity": "sha512-cTZWTnCXLABOuvWiv6nQQM0hP6ZWEkzdgDvztgHI/+u/MvtzJBN5lBQ2lue/9sSFYLMqzqff5EHKlFtrJCA9dQ==",
"cpu": [
"arm"
],
@ -147,9 +147,9 @@
}
},
"node_modules/@swc/core-linux-arm64-gnu": {
"version": "1.5.3",
"resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.5.3.tgz",
"integrity": "sha512-DCC6El3MiTYfv98CShxz/g2s4Pxn6tV0mldCQ0UdRqaN2ApUn7E+zTrqaj5bk7yII3A43WhE9Mr6wNPbXUeVyg==",
"version": "1.5.7",
"resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.5.7.tgz",
"integrity": "sha512-hoeTJFBiE/IJP30Be7djWF8Q5KVgkbDtjySmvYLg9P94bHg9TJPSQoC72tXx/oXOgXvElDe/GMybru0UxhKx4g==",
"cpu": [
"arm64"
],
@ -162,9 +162,9 @@
}
},
"node_modules/@swc/core-linux-arm64-musl": {
"version": "1.5.3",
"resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.5.3.tgz",
"integrity": "sha512-p04ysjYXEyaCGpJvwHm0T0nkPawXtdKBTThWnlh8M5jYULVNVA1YmC9azG2Avs1GDaLgBPVUgodmFYpdSupOYA==",
"version": "1.5.7",
"resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.5.7.tgz",
"integrity": "sha512-+NDhK+IFTiVK1/o7EXdCeF2hEzCiaRSrb9zD7X2Z7inwWlxAntcSuzZW7Y6BRqGQH89KA91qYgwbnjgTQ22PiQ==",
"cpu": [
"arm64"
],
@ -177,9 +177,9 @@
}
},
"node_modules/@swc/core-linux-x64-gnu": {
"version": "1.5.3",
"resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.5.3.tgz",
"integrity": "sha512-/l4KJu0xwYm6tcVSOvF8RbXrIeIHJAhWnKvuX4ZnYKFkON968kB8Ghx+1yqBQcZf36tMzSuZUC5xBUA9u66lGA==",
"version": "1.5.7",
"resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.5.7.tgz",
"integrity": "sha512-25GXpJmeFxKB+7pbY7YQLhWWjkYlR+kHz5I3j9WRl3Lp4v4UD67OGXwPe+DIcHqcouA1fhLhsgHJWtsaNOMBNg==",
"cpu": [
"x64"
],
@ -192,9 +192,9 @@
}
},
"node_modules/@swc/core-linux-x64-musl": {
"version": "1.5.3",
"resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.5.3.tgz",
"integrity": "sha512-54DmSnrTXq4fYEKNR0nFAImG3+FxsHlQ6Tol/v3l+rxmg2K0FeeDOpH7wTXeWhMGhFlGrLIyLSnA+SzabfoDIA==",
"version": "1.5.7",
"resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.5.7.tgz",
"integrity": "sha512-0VN9Y5EAPBESmSPPsCJzplZHV26akC0sIgd3Hc/7S/1GkSMoeuVL+V9vt+F/cCuzr4VidzSkqftdP3qEIsXSpg==",
"cpu": [
"x64"
],
@ -207,9 +207,9 @@
}
},
"node_modules/@swc/core-win32-arm64-msvc": {
"version": "1.5.3",
"resolved": "https://registry.npmjs.org/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.5.3.tgz",
"integrity": "sha512-piUMqoHNwDXChBfaaFIMzYgoxepfd8Ci1uXXNVEnuiRKz3FiIcNLmvXaBD7lKUwKcnGgVziH/CrndX6SldKQNQ==",
"version": "1.5.7",
"resolved": "https://registry.npmjs.org/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.5.7.tgz",
"integrity": "sha512-RtoNnstBwy5VloNCvmvYNApkTmuCe4sNcoYWpmY7C1+bPR+6SOo8im1G6/FpNem8AR5fcZCmXHWQ+EUmRWJyuA==",
"cpu": [
"arm64"
],
@ -222,9 +222,9 @@
}
},
"node_modules/@swc/core-win32-ia32-msvc": {
"version": "1.5.3",
"resolved": "https://registry.npmjs.org/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.5.3.tgz",
"integrity": "sha512-zV5utPYBUzYhBOomCByAjKAvfVBcOCJtnszx7Zlfz7SAv/cGm8D1QzPDCvv6jDhIlUtLj6KyL8JXeFr+f95Fjw==",
"version": "1.5.7",
"resolved": "https://registry.npmjs.org/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.5.7.tgz",
"integrity": "sha512-Xm0TfvcmmspvQg1s4+USL3x8D+YPAfX2JHygvxAnCJ0EHun8cm2zvfNBcsTlnwYb0ybFWXXY129aq1wgFC9TpQ==",
"cpu": [
"ia32"
],
@ -237,9 +237,9 @@
}
},
"node_modules/@swc/core-win32-x64-msvc": {
"version": "1.5.3",
"resolved": "https://registry.npmjs.org/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.5.3.tgz",
"integrity": "sha512-QmUiXiPIV5gBADfDh8e2jKynEhyRC+dcKP/zF9y5KqDUErYzlhocLd68uYS4uIegP6AylYlmigHgcaktGEE9VQ==",
"version": "1.5.7",
"resolved": "https://registry.npmjs.org/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.5.7.tgz",
"integrity": "sha512-tp43WfJLCsKLQKBmjmY/0vv1slVywR5Q4qKjF5OIY8QijaEW7/8VwPyUyVoJZEnDgv9jKtUTG5PzqtIYPZGnyg==",
"cpu": [
"x64"
],
@ -257,9 +257,9 @@
"integrity": "sha512-e2BR4lsJkkRlKZ/qCHPw9ZaSxc0MVUd7gtbtaB7aMvHeJVYe8sOB8DBZkP2DtISHGSku9sCK6T6cnY0CtXrOCQ=="
},
"node_modules/@swc/types": {
"version": "0.1.6",
"resolved": "https://registry.npmjs.org/@swc/types/-/types-0.1.6.tgz",
"integrity": "sha512-/JLo/l2JsT/LRd80C3HfbmVpxOAJ11FO2RCEslFrgzLltoP9j8XIbsyDcfCt2WWyX+CM96rBoNM+IToAkFOugg==",
"version": "0.1.7",
"resolved": "https://registry.npmjs.org/@swc/types/-/types-0.1.7.tgz",
"integrity": "sha512-scHWahbHF0eyj3JsxG9CFJgFdFNaVQCNAimBlT6PzS3n/HptxqREjsm4OH6AN3lYcffZYSPxXW8ua2BEHp0lJQ==",
"dependencies": {
"@swc/counter": "^0.1.3"
}
@ -381,9 +381,9 @@
}
},
"node_modules/caniuse-lite": {
"version": "1.0.30001616",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001616.tgz",
"integrity": "sha512-RHVYKov7IcdNjVHJFNY/78RdG4oGVjbayxv8u5IO74Wv7Hlq4PnJE6mo/OjFijjVFNy5ijnCt6H3IIo4t+wfEw==",
"version": "1.0.30001620",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001620.tgz",
"integrity": "sha512-WJvYsOjd1/BYUY6SNGUosK9DUidBPDTnOARHp3fSmFO1ekdxaY6nKRttEVrfMmYi80ctS0kz1wiWmm14fVc3ew==",
"funding": [
{
"type": "opencollective",
@ -647,9 +647,9 @@
}
},
"node_modules/electron-to-chromium": {
"version": "1.4.757",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.757.tgz",
"integrity": "sha512-jftDaCknYSSt/+KKeXzH3LX5E2CvRLm75P3Hj+J/dv3CL0qUYcOt13d5FN1NiL5IJbbhzHrb3BomeG2tkSlZmw=="
"version": "1.4.773",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.773.tgz",
"integrity": "sha512-87eHF+h3PlCRwbxVEAw9KtK3v7lWfc/sUDr0W76955AdYTG4bV/k0zrl585Qnj/skRMH2qOSiE+kqMeOQ+LOpw=="
},
"node_modules/entities": {
"version": "4.5.0",
@ -805,9 +805,9 @@
}
},
"node_modules/picocolors": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz",
"integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ=="
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.1.tgz",
"integrity": "sha512-anP1Z8qwhkbmu7MFP5iTt+wQKXgwzf7zTyGlcdzabySa9vd0Xt392U0rVmz9poOaBj0uHJKyyo9/upk0HrEQew=="
},
"node_modules/postcss": {
"version": "8.4.38",
@ -1282,9 +1282,9 @@
}
},
"node_modules/svgo": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/svgo/-/svgo-3.2.0.tgz",
"integrity": "sha512-4PP6CMW/V7l/GmKRKzsLR8xxjdHTV4IMvhTnpuHwwBazSIlw5W/5SmPjN8Dwyt7lKbSJrRDgp4t9ph0HgChFBQ==",
"version": "3.3.2",
"resolved": "https://registry.npmjs.org/svgo/-/svgo-3.3.2.tgz",
"integrity": "sha512-OoohrmuUlBs8B8o6MB2Aevn+pRIH9zDALSR+6hhqVfa6fRwG/Qw9VUMSMW9VNg2CFc/MTIfabtdOVl9ODIJjpw==",
"dependencies": {
"@trysound/sax": "0.2.0",
"commander": "^7.2.0",
@ -1341,9 +1341,9 @@
"integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q=="
},
"node_modules/update-browserslist-db": {
"version": "1.0.15",
"resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.15.tgz",
"integrity": "sha512-K9HWH62x3/EalU1U6sjSZiylm9C8tgq2mSvshZpqc7QE69RaA2qjhkW2HlNA0tFpEbtyFz7HTqbSdN4MSwUodA==",
"version": "1.0.16",
"resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.16.tgz",
"integrity": "sha512-KVbTxlBYlckhF5wgfyZXTWnMn7MMZjMu9XG8bPlliUOP9ThaF4QnhP8qrjrH7DRzHfSk0oQv1wToW+iA5GajEQ==",
"funding": [
{
"type": "opencollective",
@ -1360,7 +1360,7 @@
],
"dependencies": {
"escalade": "^3.1.2",
"picocolors": "^1.0.0"
"picocolors": "^1.0.1"
},
"bin": {
"update-browserslist-db": "cli.js"

View file

@ -1,6 +1,6 @@
{
"dependencies": {
"@swc/core": "^1.5.3",
"@swc/core": "^1.5.7",
"autoprefixer": "^10.4.19",
"cssnano": "^6.1.2",
"html-minifier-terser": "^7.2.0",

View file

@ -195,10 +195,10 @@ Umi.Parsing = (function() {
};
const toggleImage = function(element) {
const url = element.parentElement.title,
container = element.parentElement.getElementsByTagName('span')[0],
anchor = container.getElementsByTagName('a')[0],
isEmbedded = container.title !== 'link';
const url = element.parentElement.title;
const container = element.parentElement.getElementsByTagName('span')[0];
const anchor = container.getElementsByTagName('a')[0];
const isEmbedded = container.title !== 'link';
if(isEmbedded) {
container.title = 'link';
@ -220,6 +220,10 @@ Umi.Parsing = (function() {
maxHeight: '50vh',
verticalAlign: 'middle',
},
onload: () => {
if(mami.settings.get('autoScroll'))
container.scrollIntoView({ inline: 'end' });
},
},
});
@ -234,9 +238,9 @@ Umi.Parsing = (function() {
}
};
const toggleAudio = function(element) {
const url = element.parentElement.title,
container = element.parentElement.getElementsByTagName('span')[0],
isEmbedded = container.title !== 'link';
const url = element.parentElement.title;
const container = element.parentElement.getElementsByTagName('span')[0];
const isEmbedded = container.title !== 'link';
if(isEmbedded) {
container.title = 'link';
@ -263,14 +267,18 @@ Umi.Parsing = (function() {
attrs: {
src: url,
controls: true,
onloadedmetadata: () => {
if(mami.settings.get('autoScroll'))
container.scrollIntoView({ inline: 'end' });
},
},
}));
}
};
const toggleVideo = function(element) {
const url = element.parentElement.title,
container = element.parentElement.getElementsByTagName('span')[0],
isEmbedded = container.title !== 'link';
const url = element.parentElement.title;
const container = element.parentElement.getElementsByTagName('span')[0];
const isEmbedded = container.title !== 'link';
if(isEmbedded) {
container.title = 'link';
@ -301,6 +309,10 @@ Umi.Parsing = (function() {
maxWidth: '800px',
maxHeight: '600px',
},
onloadedmetadata: () => {
if(mami.settings.get('autoScroll'))
container.scrollIntoView({ inline: 'end' });
},
},
});
@ -315,8 +327,8 @@ Umi.Parsing = (function() {
}
};
const toggleSpoiler = function(element) {
const container = element.parentElement,
target = container.querySelector('span');
const container = element.parentElement;
const target = container.querySelector('span');
if(container.dataset.revealed === 'yes') {
container.dataset.revealed = 'no';

View file

@ -331,7 +331,7 @@ Umi.UI.Messages = (function() {
}
if(mami.settings.get('autoScroll'))
msgsList.scrollTop = msgsList.scrollHeight;
eBase.scrollIntoView({ inline: 'end' });
}
let isMentioned = false;