mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-23 02:17:40 -07:00
投稿のURLプレビューポップアップを改良 (#6226)
* URLプレビューポップアップを改良 - タッチデバイスでは表示しないように - 幅をレスポンシブに * Use maxTouchPoints to detect touch device * fix
This commit is contained in:
parent
ec5a1c8a9d
commit
066b8e6f73
4 changed files with 11 additions and 1 deletions
|
@ -14,6 +14,7 @@ import Vue from 'vue';
|
||||||
import { faExternalLinkSquareAlt } from '@fortawesome/free-solid-svg-icons';
|
import { faExternalLinkSquareAlt } from '@fortawesome/free-solid-svg-icons';
|
||||||
import { url as local } from '../config';
|
import { url as local } from '../config';
|
||||||
import MkUrlPreview from './url-preview-popup.vue';
|
import MkUrlPreview from './url-preview-popup.vue';
|
||||||
|
import { isDeviceTouch } from '../scripts/is-device-touch';
|
||||||
|
|
||||||
export default Vue.extend({
|
export default Vue.extend({
|
||||||
props: {
|
props: {
|
||||||
|
@ -61,11 +62,13 @@ export default Vue.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onMouseover() {
|
onMouseover() {
|
||||||
|
if (isDeviceTouch()) return;
|
||||||
clearTimeout(this.showTimer);
|
clearTimeout(this.showTimer);
|
||||||
clearTimeout(this.hideTimer);
|
clearTimeout(this.hideTimer);
|
||||||
this.showTimer = setTimeout(this.showPreview, 500);
|
this.showTimer = setTimeout(this.showPreview, 500);
|
||||||
},
|
},
|
||||||
onMouseleave() {
|
onMouseleave() {
|
||||||
|
if (isDeviceTouch()) return;
|
||||||
clearTimeout(this.showTimer);
|
clearTimeout(this.showTimer);
|
||||||
clearTimeout(this.hideTimer);
|
clearTimeout(this.hideTimer);
|
||||||
this.hideTimer = setTimeout(this.closePreview, 500);
|
this.hideTimer = setTimeout(this.closePreview, 500);
|
||||||
|
|
|
@ -36,7 +36,7 @@ export default Vue.extend({
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
const rect = this.source.getBoundingClientRect();
|
const rect = this.source.getBoundingClientRect();
|
||||||
const x = ((rect.left + (this.source.offsetWidth / 2)) - (300 / 2)) + window.pageXOffset;
|
const x = Math.max((rect.left + (this.source.offsetWidth / 2)) - (300 / 2), 6) + window.pageXOffset;
|
||||||
const y = rect.top + this.source.offsetHeight + window.pageYOffset;
|
const y = rect.top + this.source.offsetHeight + window.pageYOffset;
|
||||||
|
|
||||||
this.top = y;
|
this.top = y;
|
||||||
|
@ -50,6 +50,7 @@ export default Vue.extend({
|
||||||
position: absolute;
|
position: absolute;
|
||||||
z-index: 11000;
|
z-index: 11000;
|
||||||
width: 500px;
|
width: 500px;
|
||||||
|
max-width: calc(90vw - 12px);
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ import { faExternalLinkSquareAlt } from '@fortawesome/free-solid-svg-icons';
|
||||||
import { toUnicode as decodePunycode } from 'punycode';
|
import { toUnicode as decodePunycode } from 'punycode';
|
||||||
import { url as local } from '../config';
|
import { url as local } from '../config';
|
||||||
import MkUrlPreview from './url-preview-popup.vue';
|
import MkUrlPreview from './url-preview-popup.vue';
|
||||||
|
import { isDeviceTouch } from '../scripts/is-device-touch';
|
||||||
|
|
||||||
export default Vue.extend({
|
export default Vue.extend({
|
||||||
props: {
|
props: {
|
||||||
|
@ -92,11 +93,13 @@ export default Vue.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onMouseover() {
|
onMouseover() {
|
||||||
|
if (isDeviceTouch()) return;
|
||||||
clearTimeout(this.showTimer);
|
clearTimeout(this.showTimer);
|
||||||
clearTimeout(this.hideTimer);
|
clearTimeout(this.hideTimer);
|
||||||
this.showTimer = setTimeout(this.showPreview, 500);
|
this.showTimer = setTimeout(this.showPreview, 500);
|
||||||
},
|
},
|
||||||
onMouseleave() {
|
onMouseleave() {
|
||||||
|
if (isDeviceTouch()) return;
|
||||||
clearTimeout(this.showTimer);
|
clearTimeout(this.showTimer);
|
||||||
clearTimeout(this.hideTimer);
|
clearTimeout(this.hideTimer);
|
||||||
this.hideTimer = setTimeout(this.closePreview, 500);
|
this.hideTimer = setTimeout(this.closePreview, 500);
|
||||||
|
|
3
src/client/scripts/is-device-touch.ts
Normal file
3
src/client/scripts/is-device-touch.ts
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
export function isDeviceTouch(): boolean {
|
||||||
|
return 'maxTouchPoints' in navigator && navigator.maxTouchPoints > 0;
|
||||||
|
}
|
Loading…
Reference in a new issue