Skip to content

Commit

Permalink
Twitterウィジットがはみ出すのを修正
Browse files Browse the repository at this point in the history
  • Loading branch information
mei23 committed Jul 6, 2020
1 parent 4274053 commit 1ecabef
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/client/app/common/views/components/url-preview.vue
Expand Up @@ -3,8 +3,8 @@
<button class="disablePlayer" @click="playerEnabled = false" :title="$t('disable-player')"><fa icon="times"/></button>
<iframe :src="player.url + (player.url.match(/\?/) ? '&autoplay=1&auto_play=1' : '?autoplay=1&auto_play=1')" :width="player.width || '100%'" :heigth="player.height || 250" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen />
</div>
<div v-else-if="tweetId && tweetExpanded" class="twitter">
<iframe ref="tweet" scrolling="no" frameborder="no" :style="{ width: '100%', height: `${tweetHeight}px` }" :src="`https://platform.twitter.com/embed/index.html?embedId=${embedId}&amp;hideCard=false&amp;hideThread=false&amp;lang=en&amp;theme=${$store.state.device.darkmode ? 'dark' : 'light'}&amp;id=${tweetId}`"></iframe>
<div v-else-if="tweetId && tweetExpanded" class="twitter" ref="twitter">
<iframe ref="tweet" scrolling="no" frameborder="no" :style="{ 'margin-top': '8px', left: `${tweetLeft}px`, width: `${tweetLeft < 0 ? 'auto' : '100%'}`, height: `${tweetHeight}px` }" :src="`https://platform.twitter.com/embed/index.html?embedId=${embedId}&amp;hideCard=false&amp;hideThread=false&amp;lang=en&amp;theme=${$store.state.device.darkmode ? 'dark' : 'light'}&amp;id=${tweetId}`"></iframe>
</div>
<div v-else class="mk-url-preview">
<a :class="{ mini: narrow, compact }" :href="url" rel="nofollow noopener" target="_blank" :title="url" v-if="!fetching">
Expand Down Expand Up @@ -81,6 +81,7 @@ export default Vue.extend({
tweetExpanded: this.detail,
embedId: `embed${Math.random().toString().replace(/\D/,'')}`,
tweetHeight: 150,
tweetLeft: 0,
playerEnabled: false,
misskeyUrl,
faTwitter
Expand Down Expand Up @@ -124,6 +125,12 @@ export default Vue.extend({
(window as any).addEventListener('message', this.adjustTweetHeight);
},
mounted() {
// 300pxないと絶対右にはみ出るので左に移動してしまう
const areaWidth = (this.$el as HTMLElement)?.clientWidth;
if (areaWidth && areaWidth < 300) this.tweetLeft = areaWidth - 290;
},
methods: {
isBlokedUrl(url: URL) {
if (url.pathname.match(/\.(?:jpg|gif|png)$/)) return true;
Expand Down

0 comments on commit 1ecabef

Please sign in to comment.