Skip to content

Commit 38b38ef

Browse files
committed
Media query for mobile side
1 parent 8020ae0 commit 38b38ef

File tree

7 files changed

+29
-5
lines changed

7 files changed

+29
-5
lines changed

example/public/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta charset="utf-8">
55
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6-
<meta name="viewport" content="width=device-width,initial-scale=1.0">
6+
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0"/>
77
<title>vue-virtual-scroll-list</title>
88
<link rel="icon" href="<%= BASE_URL %>favicon.png">
99
<link rel="stylesheet" href="<%= BASE_URL %>milligram.css" />

example/src/App.vue

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<div id="app">
33
<div id="nav">
4-
<router-link to="/">documentation</router-link>
4+
<router-link to="/">home</router-link>
55
<router-link to="/fixed-size">fixed size</router-link>
66
<router-link to="/dynamic-size">dynamic size</router-link>
77
<router-link to="/horizontal">horizontal</router-link>
@@ -21,14 +21,25 @@ body {
2121
margin: 0 auto;
2222
padding: 0 2em;
2323
width: 776px;
24+
@media (max-width: 640px) {
25+
padding: 3px;
26+
width: 100%;
27+
}
2428
}
2529
2630
#nav {
2731
padding: 1em 0;
32+
@media (max-width: 640px) {
33+
padding: 0;
34+
}
2835
a {
2936
margin-right: 1.5em;
3037
margin-bottom: .5em;
3138
display: inline-block;
39+
@media (max-width: 640px) {
40+
margin-bottom: 0;
41+
margin-right: 1em;
42+
}
3243
}
3344
.router-link-exact-active,
3445
.router-link-exact-active:hover {

example/src/common/ua.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
const ua = navigator.userAgent
2+
const Android = !!ua.match(/Android/i)
3+
const iOS = !!ua.match(/iPhone|iPad|iPod/i)
4+
export const isMobile = Android || iOS

example/src/components/Corner.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<a :href="url" class="github-corner" aria-label="View source on GitHub">
2+
<a v-if="!isMobile" :href="url" class="github-corner" aria-label="View source on GitHub">
33
<svg :width="size" :height="size" viewBox="0 0 250 250" style="fill:#9b4dca; color:#fff; position: absolute; top: 0; border: 0; right: 0; z-index: 1000;" aria-hidden="true">
44
<path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z" />
55
<path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" style="transform-origin: 130px 106px;" fill="currentColor" class="octo-arm" />
@@ -9,6 +9,7 @@
99
</template>
1010

1111
<script>
12+
import { isMobile } from '../common/ua'
1213
import getCodeUrl from '../common/get-code-url'
1314
1415
export default {
@@ -17,7 +18,8 @@ export default {
1718
data () {
1819
return {
1920
url: '',
20-
size: 80
21+
size: 80,
22+
isMobile
2123
}
2224
},
2325

example/src/components/Introduction.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,8 @@ export default {
2121
padding: .5em 1em;
2222
border-radius: 3px;
2323
background-color: ghostwhite;
24+
@media (max-width: 640px) {
25+
display: none;
26+
}
2427
}
2528
</style>

example/src/components/Tab.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ export default {
5656
display: flex;
5757
margin-bottom: 1em;
5858
position: relative;
59+
@media (max-width: 640px) {
60+
display: none;
61+
}
5962
.tab-item {
6063
font-size: 14px;
6164
font-weight: 400;

example/src/views/dynamic-size/Main.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import Item from './Item'
2828
import Code from './Code'
2929
30+
import { isMobile } from '../../common/ua'
3031
import { Random } from '../../common/mock'
3132
import genUniqueId from '../../common/gen-unique-id'
3233
import { TOTAL_COUNT, TAB_TYPE, DEFAULT_TAB } from '../../common/const'
@@ -39,7 +40,7 @@ while (count--) {
3940
index,
4041
name: Random.name(),
4142
id: genUniqueId(index),
42-
desc: Random.paragraph(Random.integer(0, 3))
43+
desc: Random.paragraph(Random.integer(0, isMobile ? 1 : 3))
4344
})
4445
}
4546

0 commit comments

Comments
 (0)