@gitlab/ui 32.65.0 → 32.68.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/dist/components/utilities/intersection_observer/intersection_observer.documentation.js +1 -20
- package/dist/components/utilities/intersection_observer/intersection_observer.js +12 -0
- package/dist/utility_classes.css +1 -1
- package/dist/utility_classes.css.map +1 -1
- package/documentation/documented_stories.js +1 -0
- package/package.json +1 -1
- package/scss_to_js/scss_variables.js +1 -0
- package/scss_to_js/scss_variables.json +5 -0
- package/src/components/utilities/intersection_observer/intersection_observer.documentation.js +0 -23
- package/src/components/utilities/intersection_observer/intersection_observer.stories.js +91 -80
- package/src/components/utilities/intersection_observer/intersection_observer.vue +15 -0
- package/src/scss/utilities.scss +44 -2
- package/src/scss/utility-mixins/flex.scss +1 -1
- package/src/scss/utility-mixins/sizing.scss +16 -0
- package/src/scss/utility-mixins/spacing.scss +6 -0
- package/src/scss/variables.scss +1 -0
- package/dist/components/utilities/intersection_observer/examples/index.js +0 -19
- package/dist/components/utilities/intersection_observer/examples/intersection_observer.image.example.js +0 -62
- package/dist/components/utilities/intersection_observer/examples/intersection_observer.last_appeared.example.js +0 -83
- package/src/components/utilities/intersection_observer/examples/index.js +0 -23
- package/src/components/utilities/intersection_observer/examples/intersection_observer.image.example.vue +0 -29
- package/src/components/utilities/intersection_observer/examples/intersection_observer.last_appeared.example.vue +0 -43
package/package.json
CHANGED
|
@@ -16,6 +16,7 @@ export const glSpacingScale13 = '6rem'
|
|
|
16
16
|
export const glSpacingScale15 = '7.5rem'
|
|
17
17
|
export const glSpacingScale20 = '10rem'
|
|
18
18
|
export const glSpacingScale26 = '13rem'
|
|
19
|
+
export const glSpacingScale28 = '14rem'
|
|
19
20
|
export const glSpacingScale62 = '31rem'
|
|
20
21
|
export const breakpointSm = '576px'
|
|
21
22
|
export const breakpointMd = '768px'
|
package/src/components/utilities/intersection_observer/intersection_observer.documentation.js
CHANGED
|
@@ -1,28 +1,5 @@
|
|
|
1
|
-
import examples from './examples';
|
|
2
1
|
import * as description from './intersection_observer.md';
|
|
3
2
|
|
|
4
3
|
export default {
|
|
5
4
|
description,
|
|
6
|
-
examples,
|
|
7
|
-
propsInfo: {
|
|
8
|
-
options: {
|
|
9
|
-
additionalInfo: 'Extra options to pass directly to the intersection observer API.',
|
|
10
|
-
},
|
|
11
|
-
},
|
|
12
|
-
events: [
|
|
13
|
-
{
|
|
14
|
-
event: 'appear',
|
|
15
|
-
description: 'Emitted when the element appears on the page',
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
event: 'disappear',
|
|
19
|
-
description: 'Emitted when the element disappears from the page',
|
|
20
|
-
},
|
|
21
|
-
],
|
|
22
|
-
slots: [
|
|
23
|
-
{
|
|
24
|
-
slot: 'default',
|
|
25
|
-
description: "The element you wish to observe, or a fallback if the observer doesn't work.",
|
|
26
|
-
},
|
|
27
|
-
],
|
|
28
5
|
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { documentedStoriesOf } from '../../../../documentation/documented_stories';
|
|
2
1
|
import { GlIntersectionObserver } from '../../../../index';
|
|
3
2
|
import readme from './intersection_observer.md';
|
|
4
3
|
|
|
@@ -31,17 +30,16 @@ const generateItems = (startingId = 0) => {
|
|
|
31
30
|
});
|
|
32
31
|
};
|
|
33
32
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return this.isInView ? 'The observer is in view' : 'The observer is not in view';
|
|
42
|
-
},
|
|
33
|
+
export const Default = () => ({
|
|
34
|
+
components,
|
|
35
|
+
data: commonData,
|
|
36
|
+
methods: commonMethods,
|
|
37
|
+
computed: {
|
|
38
|
+
visibility() {
|
|
39
|
+
return this.isInView ? 'The observer is in view' : 'The observer is not in view';
|
|
43
40
|
},
|
|
44
|
-
|
|
41
|
+
},
|
|
42
|
+
template: `
|
|
45
43
|
<div style="height: 200px; overflow-y: scroll;">
|
|
46
44
|
<h1>{{ visibility }}</h1>
|
|
47
45
|
<p>This one is a hard one to demonstrate as it's invisible by nature.</p>
|
|
@@ -55,26 +53,27 @@ documentedStoriesOf('utilities/intersection-observer', readme)
|
|
|
55
53
|
/>
|
|
56
54
|
<p>This line appears just after the observer.</p>
|
|
57
55
|
</div>
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
56
|
+
`,
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
export const BigTable = () => ({
|
|
60
|
+
components,
|
|
61
|
+
data() {
|
|
62
|
+
return {
|
|
63
|
+
values: Array(100)
|
|
64
|
+
.fill(1)
|
|
65
|
+
.map(() => Array(10).fill(0)),
|
|
66
|
+
};
|
|
67
|
+
},
|
|
68
|
+
methods: {
|
|
69
|
+
update(row, col, { intersectionRatio }) {
|
|
70
|
+
this.$set(this.values[row], col, intersectionRatio);
|
|
68
71
|
},
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
this.$set(this.values[row], col, intersectionRatio);
|
|
72
|
-
},
|
|
73
|
-
disappear(row, col) {
|
|
74
|
-
this.values[row][col] = 0;
|
|
75
|
-
},
|
|
72
|
+
disappear(row, col) {
|
|
73
|
+
this.values[row][col] = 0;
|
|
76
74
|
},
|
|
77
|
-
|
|
75
|
+
},
|
|
76
|
+
template: `
|
|
78
77
|
<div style="height: 600px; overflow-y: scroll;">
|
|
79
78
|
<table>
|
|
80
79
|
<tr v-for="(cols, row) in values" :key="row">
|
|
@@ -87,20 +86,21 @@ documentedStoriesOf('utilities/intersection-observer', readme)
|
|
|
87
86
|
</table>
|
|
88
87
|
</div>
|
|
89
88
|
`,
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
export const LazyLoadedImage = () => ({
|
|
92
|
+
components,
|
|
93
|
+
data: commonData,
|
|
94
|
+
methods: commonMethods,
|
|
95
|
+
computed: {
|
|
96
|
+
imageUrl() {
|
|
97
|
+
// If the image is in view, return the high res one. If not return nothing, or a low res one
|
|
98
|
+
return this.isInView
|
|
99
|
+
? '../../img/gitlab-summit-south-africa.jpg'
|
|
100
|
+
: '../../img/gitlab-summit-south-africa-min.jpg';
|
|
102
101
|
},
|
|
103
|
-
|
|
102
|
+
},
|
|
103
|
+
template: `
|
|
104
104
|
<div>
|
|
105
105
|
<p>The image below will load a low-res version until it appears on the poage, then it will switch out for a higher res version.</p>
|
|
106
106
|
<p>It's also set up to switch back to the low res version when it disappears off the page. This is not what you would usually do for lazily loaded images, but it helps to demonstrate the effect in this example.</p>
|
|
@@ -111,42 +111,53 @@ documentedStoriesOf('utilities/intersection-observer', readme)
|
|
|
111
111
|
<img :src="imageUrl" style="max-width: 100%; height: auto;"/>
|
|
112
112
|
</gl-intersection-observer>
|
|
113
113
|
</div>
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
114
|
+
`,
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
export const InfiniteScrolling = () => ({
|
|
118
|
+
components,
|
|
119
|
+
data: () => ({
|
|
120
|
+
items: generateItems(),
|
|
121
|
+
}),
|
|
122
|
+
computed: {
|
|
123
|
+
lastItemId() {
|
|
124
|
+
return this.items[this.items.length - 1].id;
|
|
125
|
+
},
|
|
126
|
+
endOfList() {
|
|
127
|
+
return this.lastItemId >= 1000;
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
methods: {
|
|
131
|
+
fetchMoreItems() {
|
|
132
|
+
if (!this.endOfList) {
|
|
133
|
+
this.items.push(...generateItems(this.lastItemId));
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
template: `
|
|
138
|
+
<div>
|
|
139
|
+
<h2>Infinitely scrollable list</h2>
|
|
140
|
+
<p>This data will procedurally generate 1000 items, 20 at a time</p>
|
|
141
|
+
<ul>
|
|
142
|
+
<li v-for="item in items" :key="item.id">{{ item.title }}</li>
|
|
143
|
+
</ul>
|
|
144
|
+
<gl-intersection-observer v-if="!endOfList" @appear="fetchMoreItems">
|
|
145
|
+
<button @click="fetchMoreItems">Fetch more items</button>
|
|
146
|
+
</gl-intersection-observer>
|
|
147
|
+
</div>
|
|
148
|
+
`,
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
export default {
|
|
152
|
+
title: 'utilities/intersection-observer',
|
|
153
|
+
component: GlIntersectionObserver,
|
|
154
|
+
parameters: {
|
|
155
|
+
knobs: { disable: true },
|
|
156
|
+
storyshots: { disable: true },
|
|
157
|
+
docs: {
|
|
158
|
+
description: {
|
|
159
|
+
component: readme,
|
|
137
160
|
},
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
<p>This data will procedurally generate 1000 items, 20 at a time</p>
|
|
142
|
-
<ul>
|
|
143
|
-
<li v-for="item in items" :key="item.id">{{ item.title }}</li>
|
|
144
|
-
</ul>
|
|
145
|
-
<gl-intersection-observer v-if="!endOfList" @appear="fetchMoreItems">
|
|
146
|
-
<button @click="fetchMoreItems">Fetch more items</button>
|
|
147
|
-
</gl-intersection-observer>
|
|
148
|
-
</div>
|
|
149
|
-
`,
|
|
150
|
-
}),
|
|
151
|
-
{ storyshots: false }
|
|
152
|
-
);
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
};
|
|
@@ -13,6 +13,9 @@ const getObserver = memoize(
|
|
|
13
13
|
export default {
|
|
14
14
|
name: 'GlIntersectionObserver',
|
|
15
15
|
props: {
|
|
16
|
+
/**
|
|
17
|
+
* Extra options to pass directly to the intersection observer API.
|
|
18
|
+
*/
|
|
16
19
|
options: {
|
|
17
20
|
type: Object,
|
|
18
21
|
required: false,
|
|
@@ -23,11 +26,20 @@ export default {
|
|
|
23
26
|
const observer = getObserver(this.options);
|
|
24
27
|
|
|
25
28
|
this.$el.$_gl_intersectionHandler = (entry) => {
|
|
29
|
+
/**
|
|
30
|
+
* Emitted when the element's visibility changes
|
|
31
|
+
*/
|
|
26
32
|
this.$emit('update', entry);
|
|
27
33
|
|
|
28
34
|
if (entry.isIntersecting) {
|
|
35
|
+
/**
|
|
36
|
+
* Emitted when the element appears on the page
|
|
37
|
+
*/
|
|
29
38
|
this.$emit('appear');
|
|
30
39
|
} else {
|
|
40
|
+
/**
|
|
41
|
+
* Emitted when the element disappears from the page
|
|
42
|
+
*/
|
|
31
43
|
this.$emit('disappear');
|
|
32
44
|
}
|
|
33
45
|
};
|
|
@@ -47,6 +59,9 @@ export default {
|
|
|
47
59
|
|
|
48
60
|
<template>
|
|
49
61
|
<div>
|
|
62
|
+
<!--
|
|
63
|
+
@slot The element you wish to observe, or a fallback if the observer doesn't work.
|
|
64
|
+
-->
|
|
50
65
|
<slot></slot>
|
|
51
66
|
</div>
|
|
52
67
|
</template>
|
package/src/scss/utilities.scss
CHANGED
|
@@ -3145,13 +3145,13 @@
|
|
|
3145
3145
|
}
|
|
3146
3146
|
|
|
3147
3147
|
.gl-sm-justify-content-end {
|
|
3148
|
-
@include gl-media-breakpoint-up(
|
|
3148
|
+
@include gl-media-breakpoint-up(sm) {
|
|
3149
3149
|
justify-content: flex-end;
|
|
3150
3150
|
}
|
|
3151
3151
|
}
|
|
3152
3152
|
|
|
3153
3153
|
.gl-sm-justify-content-end\! {
|
|
3154
|
-
@include gl-media-breakpoint-up(
|
|
3154
|
+
@include gl-media-breakpoint-up(sm) {
|
|
3155
3155
|
justify-content: flex-end !important;
|
|
3156
3156
|
}
|
|
3157
3157
|
}
|
|
@@ -3967,6 +3967,14 @@
|
|
|
3967
3967
|
width: $gl-spacing-scale-20 !important;
|
|
3968
3968
|
}
|
|
3969
3969
|
|
|
3970
|
+
.gl-w-28 {
|
|
3971
|
+
width: $gl-spacing-scale-28;
|
|
3972
|
+
}
|
|
3973
|
+
|
|
3974
|
+
.gl-w-28\! {
|
|
3975
|
+
width: $gl-spacing-scale-28 !important;
|
|
3976
|
+
}
|
|
3977
|
+
|
|
3970
3978
|
.gl-w-eighth {
|
|
3971
3979
|
width: 12.5%;
|
|
3972
3980
|
}
|
|
@@ -4459,6 +4467,18 @@
|
|
|
4459
4467
|
max-width: 100vw !important;
|
|
4460
4468
|
}
|
|
4461
4469
|
|
|
4470
|
+
.gl-md-max-w-15p {
|
|
4471
|
+
@include gl-media-breakpoint-up(md) {
|
|
4472
|
+
max-width: 15%;
|
|
4473
|
+
}
|
|
4474
|
+
}
|
|
4475
|
+
|
|
4476
|
+
.gl-md-max-w-15p\! {
|
|
4477
|
+
@include gl-media-breakpoint-up(md) {
|
|
4478
|
+
max-width: 15% !important;
|
|
4479
|
+
}
|
|
4480
|
+
}
|
|
4481
|
+
|
|
4462
4482
|
.gl-md-max-w-30p {
|
|
4463
4483
|
@include gl-media-breakpoint-up(md) {
|
|
4464
4484
|
max-width: 30%;
|
|
@@ -4494,6 +4514,18 @@
|
|
|
4494
4514
|
max-width: 70% !important;
|
|
4495
4515
|
}
|
|
4496
4516
|
}
|
|
4517
|
+
|
|
4518
|
+
.gl-lg-max-w-80p {
|
|
4519
|
+
@include gl-media-breakpoint-up(lg) {
|
|
4520
|
+
max-width: 80%;
|
|
4521
|
+
}
|
|
4522
|
+
}
|
|
4523
|
+
|
|
4524
|
+
.gl-lg-max-w-80p\! {
|
|
4525
|
+
@include gl-media-breakpoint-up(lg) {
|
|
4526
|
+
max-width: 80% !important;
|
|
4527
|
+
}
|
|
4528
|
+
}
|
|
4497
4529
|
.gl-p-0 {
|
|
4498
4530
|
padding: 0;
|
|
4499
4531
|
}
|
|
@@ -5616,6 +5648,16 @@
|
|
|
5616
5648
|
margin-left: #{$gl-spacing-scale-3} !important;
|
|
5617
5649
|
}
|
|
5618
5650
|
}
|
|
5651
|
+
.gl-gap-x-5 {
|
|
5652
|
+
> * + * {
|
|
5653
|
+
margin-left: #{$gl-spacing-scale-5};
|
|
5654
|
+
}
|
|
5655
|
+
}
|
|
5656
|
+
.gl-gap-x-5\! {
|
|
5657
|
+
> * + * {
|
|
5658
|
+
margin-left: #{$gl-spacing-scale-5} !important;
|
|
5659
|
+
}
|
|
5660
|
+
}
|
|
5619
5661
|
.gl-xs-mb-3 {
|
|
5620
5662
|
@include gl-media-breakpoint-down(sm) {
|
|
5621
5663
|
margin-bottom: $gl-spacing-scale-3;
|
|
@@ -65,6 +65,10 @@
|
|
|
65
65
|
width: $gl-spacing-scale-20;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
@mixin gl-w-28 {
|
|
69
|
+
width: $gl-spacing-scale-28;
|
|
70
|
+
}
|
|
71
|
+
|
|
68
72
|
@mixin gl-w-eighth {
|
|
69
73
|
width: 12.5%;
|
|
70
74
|
}
|
|
@@ -335,6 +339,12 @@
|
|
|
335
339
|
* - Utilities should strictly follow $gl-spacing-scale
|
|
336
340
|
*/
|
|
337
341
|
|
|
342
|
+
@mixin gl-md-max-w-15p {
|
|
343
|
+
@include gl-media-breakpoint-up(md) {
|
|
344
|
+
max-width: 15%;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
338
348
|
@mixin gl-md-max-w-30p {
|
|
339
349
|
@include gl-media-breakpoint-up(md) {
|
|
340
350
|
max-width: 30%;
|
|
@@ -352,3 +362,9 @@
|
|
|
352
362
|
max-width: 70%;
|
|
353
363
|
}
|
|
354
364
|
}
|
|
365
|
+
|
|
366
|
+
@mixin gl-lg-max-w-80p {
|
|
367
|
+
@include gl-media-breakpoint-up(lg) {
|
|
368
|
+
max-width: 80%;
|
|
369
|
+
}
|
|
370
|
+
}
|
package/src/scss/variables.scss
CHANGED
|
@@ -19,6 +19,7 @@ $gl-spacing-scale-13: 12 * $grid-size;
|
|
|
19
19
|
$gl-spacing-scale-15: 15 * $grid-size;
|
|
20
20
|
$gl-spacing-scale-20: 20 * $grid-size;
|
|
21
21
|
$gl-spacing-scale-26: 26 * $grid-size;
|
|
22
|
+
$gl-spacing-scale-28: 28 * $grid-size;
|
|
22
23
|
$gl-spacing-scale-62: 62 * $grid-size;
|
|
23
24
|
|
|
24
25
|
// Responsive breakpoints
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import ImageExample from './intersection_observer.image.example';
|
|
2
|
-
import LastAppearedExample from './intersection_observer.last_appeared.example';
|
|
3
|
-
|
|
4
|
-
var index = [{
|
|
5
|
-
name: 'Intersection observer',
|
|
6
|
-
items: [{
|
|
7
|
-
id: 'intersection-observer-last-appeared',
|
|
8
|
-
name: 'Last appeared at',
|
|
9
|
-
description: 'Logs when the component last appeared on the screen',
|
|
10
|
-
component: LastAppearedExample
|
|
11
|
-
}, {
|
|
12
|
-
id: 'intersection-observer-lazy-loaded-image',
|
|
13
|
-
name: 'Lazy loaded image',
|
|
14
|
-
description: "This image switches between a gif and a still image when it's on or off the screen",
|
|
15
|
-
component: ImageExample
|
|
16
|
-
}]
|
|
17
|
-
}];
|
|
18
|
-
|
|
19
|
-
export default index;
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
|
|
2
|
-
|
|
3
|
-
var script = {
|
|
4
|
-
data: () => ({
|
|
5
|
-
isInView: false
|
|
6
|
-
}),
|
|
7
|
-
computed: {
|
|
8
|
-
imageUrl() {
|
|
9
|
-
// If the image is in view, return the high res one. If not return nothing, or a low res one
|
|
10
|
-
return this.isInView ? '../../img/gitlab-summit-south-africa.jpg' : '../../img/gitlab-summit-south-africa-min.jpg';
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
},
|
|
14
|
-
methods: {
|
|
15
|
-
appear() {
|
|
16
|
-
this.isInView = true;
|
|
17
|
-
},
|
|
18
|
-
|
|
19
|
-
disappear() {
|
|
20
|
-
this.isInView = false;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
/* script */
|
|
27
|
-
const __vue_script__ = script;
|
|
28
|
-
|
|
29
|
-
/* template */
|
|
30
|
-
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('gl-intersection-observer',{on:{"appear":_vm.appear,"disappear":_vm.disappear}},[_c('img',{staticStyle:{"max-width":"100%","height":"auto"},attrs:{"src":_vm.imageUrl}})])};
|
|
31
|
-
var __vue_staticRenderFns__ = [];
|
|
32
|
-
|
|
33
|
-
/* style */
|
|
34
|
-
const __vue_inject_styles__ = undefined;
|
|
35
|
-
/* scoped */
|
|
36
|
-
const __vue_scope_id__ = undefined;
|
|
37
|
-
/* module identifier */
|
|
38
|
-
const __vue_module_identifier__ = undefined;
|
|
39
|
-
/* functional template */
|
|
40
|
-
const __vue_is_functional_template__ = false;
|
|
41
|
-
/* style inject */
|
|
42
|
-
|
|
43
|
-
/* style inject SSR */
|
|
44
|
-
|
|
45
|
-
/* style inject shadow dom */
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const __vue_component__ = __vue_normalize__(
|
|
50
|
-
{ render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
|
|
51
|
-
__vue_inject_styles__,
|
|
52
|
-
__vue_script__,
|
|
53
|
-
__vue_scope_id__,
|
|
54
|
-
__vue_is_functional_template__,
|
|
55
|
-
__vue_module_identifier__,
|
|
56
|
-
false,
|
|
57
|
-
undefined,
|
|
58
|
-
undefined,
|
|
59
|
-
undefined
|
|
60
|
-
);
|
|
61
|
-
|
|
62
|
-
export default __vue_component__;
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
|
|
2
|
-
|
|
3
|
-
var script = {
|
|
4
|
-
data: () => ({
|
|
5
|
-
appearedAt: null,
|
|
6
|
-
now: null,
|
|
7
|
-
interval: null
|
|
8
|
-
}),
|
|
9
|
-
computed: {
|
|
10
|
-
secondsSinceAppearance() {
|
|
11
|
-
if (!this.appearedAt) {
|
|
12
|
-
return 0;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
return Math.floor((this.now - this.appearedAt) / 1000);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
},
|
|
19
|
-
|
|
20
|
-
destroyed() {
|
|
21
|
-
this.clearInterval();
|
|
22
|
-
},
|
|
23
|
-
|
|
24
|
-
methods: {
|
|
25
|
-
appear() {
|
|
26
|
-
this.clearInterval();
|
|
27
|
-
this.interval = setInterval(this.tick, 1000);
|
|
28
|
-
this.tick();
|
|
29
|
-
this.appearedAt = this.now;
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
disappear() {
|
|
33
|
-
this.clearInterval();
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
clearInterval() {
|
|
37
|
-
clearInterval(this.interval);
|
|
38
|
-
},
|
|
39
|
-
|
|
40
|
-
tick() {
|
|
41
|
-
this.now = new Date().getTime();
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
/* script */
|
|
48
|
-
const __vue_script__ = script;
|
|
49
|
-
|
|
50
|
-
/* template */
|
|
51
|
-
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('gl-intersection-observer',{on:{"appear":_vm.appear,"disappear":_vm.disappear}},[_c('span',[_vm._v("Last appeared "+_vm._s(_vm.secondsSinceAppearance)+" seconds ago")])])};
|
|
52
|
-
var __vue_staticRenderFns__ = [];
|
|
53
|
-
|
|
54
|
-
/* style */
|
|
55
|
-
const __vue_inject_styles__ = undefined;
|
|
56
|
-
/* scoped */
|
|
57
|
-
const __vue_scope_id__ = undefined;
|
|
58
|
-
/* module identifier */
|
|
59
|
-
const __vue_module_identifier__ = undefined;
|
|
60
|
-
/* functional template */
|
|
61
|
-
const __vue_is_functional_template__ = false;
|
|
62
|
-
/* style inject */
|
|
63
|
-
|
|
64
|
-
/* style inject SSR */
|
|
65
|
-
|
|
66
|
-
/* style inject shadow dom */
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const __vue_component__ = __vue_normalize__(
|
|
71
|
-
{ render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
|
|
72
|
-
__vue_inject_styles__,
|
|
73
|
-
__vue_script__,
|
|
74
|
-
__vue_scope_id__,
|
|
75
|
-
__vue_is_functional_template__,
|
|
76
|
-
__vue_module_identifier__,
|
|
77
|
-
false,
|
|
78
|
-
undefined,
|
|
79
|
-
undefined,
|
|
80
|
-
undefined
|
|
81
|
-
);
|
|
82
|
-
|
|
83
|
-
export default __vue_component__;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import ImageExample from './intersection_observer.image.example.vue';
|
|
2
|
-
import LastAppearedExample from './intersection_observer.last_appeared.example.vue';
|
|
3
|
-
|
|
4
|
-
export default [
|
|
5
|
-
{
|
|
6
|
-
name: 'Intersection observer',
|
|
7
|
-
items: [
|
|
8
|
-
{
|
|
9
|
-
id: 'intersection-observer-last-appeared',
|
|
10
|
-
name: 'Last appeared at',
|
|
11
|
-
description: 'Logs when the component last appeared on the screen',
|
|
12
|
-
component: LastAppearedExample,
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
id: 'intersection-observer-lazy-loaded-image',
|
|
16
|
-
name: 'Lazy loaded image',
|
|
17
|
-
description:
|
|
18
|
-
"This image switches between a gif and a still image when it's on or off the screen",
|
|
19
|
-
component: ImageExample,
|
|
20
|
-
},
|
|
21
|
-
],
|
|
22
|
-
},
|
|
23
|
-
];
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
export default {
|
|
3
|
-
data: () => ({
|
|
4
|
-
isInView: false,
|
|
5
|
-
}),
|
|
6
|
-
computed: {
|
|
7
|
-
imageUrl() {
|
|
8
|
-
// If the image is in view, return the high res one. If not return nothing, or a low res one
|
|
9
|
-
return this.isInView
|
|
10
|
-
? '../../img/gitlab-summit-south-africa.jpg'
|
|
11
|
-
: '../../img/gitlab-summit-south-africa-min.jpg';
|
|
12
|
-
},
|
|
13
|
-
},
|
|
14
|
-
methods: {
|
|
15
|
-
appear() {
|
|
16
|
-
this.isInView = true;
|
|
17
|
-
},
|
|
18
|
-
disappear() {
|
|
19
|
-
this.isInView = false;
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
};
|
|
23
|
-
</script>
|
|
24
|
-
|
|
25
|
-
<template>
|
|
26
|
-
<gl-intersection-observer @appear="appear" @disappear="disappear">
|
|
27
|
-
<img :src="imageUrl" style="max-width: 100%; height: auto" />
|
|
28
|
-
</gl-intersection-observer>
|
|
29
|
-
</template>
|