+207
-18
lines changedFilter options
+207
-18
lines changed Original file line number Diff line number Diff line change
@@ -15,7 +15,9 @@
15
15
active-class=""
16
16
>
17
17
<strong class="text-primary">{{ page.title }}</strong> —
18
+
<b-badge v-if="page.new" variant="success">NEW</b-badge>
18
19
<span class="text-muted">{{ page.description }}</span>
20
+
<b-badge v-if="page.version" variant="secondary">v{{ page.version }}</b-badge>
19
21
</b-list-group-item>
20
22
</b-list-group>
21
23
</Section>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
1
1
import Vue from '../../utils/vue'
2
-
import { VBVisible } from '../../directives/visible'
2
+
import { VBVisible } from '../../directives/visible/visible'
3
3
import idMixin from '../../mixins/id'
4
4
import formMixin from '../../mixins/form'
5
5
import formSizeMixin from '../../mixins/form-size'
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
1
1
import Vue from '../../utils/vue'
2
2
import { getComponentConfig } from '../../utils/config'
3
3
import { hasIntersectionObserverSupport } from '../../utils/env'
4
-
import { VBVisible } from '../../directives/visible'
4
+
import { VBVisible } from '../../directives/visible/visible'
5
5
import { BImg } from './img'
6
6
7
7
const NAME = 'BImgLazy'
Original file line number Diff line number Diff line change
@@ -4,8 +4,9 @@ import { BvPlugin } from '../'
4
4
export declare const directivesPlugin: BvPlugin
5
5
6
6
// Named exports of all directives
7
-
export * from './toggle'
8
7
export * from './modal'
8
+
export * from './popover'
9
9
export * from './scrollspy'
10
+
export * from './toggle'
10
11
export * from './tooltip'
11
-
export * from './popover'
12
+
export * from './visible'
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ import { VBPopoverPlugin } from './popover'
5
5
import { VBScrollspyPlugin } from './scrollspy'
6
6
import { VBTogglePlugin } from './toggle'
7
7
import { VBTooltipPlugin } from './tooltip'
8
+
import { VBVisiblePlugin } from './visible'
8
9
9
10
// Main plugin for installing all directive plugins
10
11
export const directivesPlugin = /*#__PURE__*/ pluginFactory({
@@ -13,6 +14,7 @@ export const directivesPlugin = /*#__PURE__*/ pluginFactory({
13
14
VBPopoverPlugin,
14
15
VBScrollspyPlugin,
15
16
VBTogglePlugin,
16
-
VBTooltipPlugin
17
+
VBTooltipPlugin,
18
+
VBVisiblePlugin
17
19
}
18
20
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
1
+
# Visible
2
+
3
+
> The `v-b-visible` directive allows you to react when an element becomes visible in the viewport.
4
+
5
+
The `v-b-visible` directive was added in version `2.1.0`.
6
+
7
+
## Overview
8
+
9
+
- `v-b-visible` will call your callback method with a boolean value indicating if the element is
10
+
visible (intersecting) with the viewport.
11
+
- The directive can be placed on almost any element or component.
12
+
- Changes in visibility cqn also be detected (such as `display: none`), as long as the element is
13
+
within (or partially within) the viewport, or within the optional offset.
14
+
- Several BootstrapVue components use `v-b-visible`, such as `<b-img-lazy>`.
15
+
- The `v-b-visible` directive requires browser support of
16
+
[`IntersectionObserver`](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API).
17
+
For older browsers that do not support `IntersectionObserver`, you will need to use a
18
+
[polyfill](/docs/#js).
19
+
20
+
## Directive syntax and usage
21
+
22
+
```html
23
+
<div v-b-visible.[mod].[...]="callback">content</div>
24
+
```
25
+
26
+
Where `callback` is required:
27
+
28
+
- A function reference that will be called whenever visibility changes. The callback is passed a
29
+
single boolean argument. `true` indicates that the element is intersecting (partially or entirely
30
+
visible) in the viewport, or `false` if the element is not visible/intersecting with the viewport.
31
+
The callback will be called each time the element's visibility changes (except when hte `once`
32
+
modifier is used. See below for details)
33
+
34
+
Where `[mod]` can be (all optional):
35
+
36
+
- A positive number representing the offset (margin) in pixels _away_ from the edge of the viewport
37
+
to determine when the element is considered in (or just about to be in) the viewport. The value
38
+
adds a margin around the view port. The default value is `0`.
39
+
- The keyword `once`. When this modifier is present, the callback will be called once (with the
40
+
argument of `true` indicating the element is intersecting/visible) when the element is
41
+
intersecting with the viewport. Note the callback may be called prior to this with an argument of
42
+
`false` signifying the element is not intersecting/visible.
43
+
44
+
### Usage examples
45
+
46
+
Basic:
47
+
48
+
```html
49
+
<template>
50
+
<div v-b-visible="visibleHandler"> ... </div>
51
+
</template>
52
+
<script>
53
+
export default {
54
+
methods: {
55
+
visibleHandler(isVisible) {
56
+
if (isVisible) {
57
+
// Do something
58
+
} else {
59
+
// Do something else
60
+
}
61
+
}
62
+
}
63
+
}
64
+
</script>
65
+
```
66
+
67
+
With viewport offset modifier of 350px (if the element is outside of the physical viewport by at
68
+
least 350px, then it will be considered "visible"):
69
+
70
+
```html
71
+
<template>
72
+
<div v-b-visible.350="visibleHandler"> ... </div>
73
+
</template>
74
+
<script>
75
+
export default {
76
+
methods: {
77
+
visibleHandler(isVisible) {
78
+
if (isVisible) {
79
+
// Do something
80
+
} else {
81
+
// Do something else
82
+
}
83
+
}
84
+
}
85
+
}
86
+
</script>
87
+
```
88
+
89
+
With `once` modifier:
90
+
91
+
```html
92
+
<template>
93
+
<div v-b-visible.350="visibleHandler"> ... </div>
94
+
</template>
95
+
<script>
96
+
export default {
97
+
methods: {
98
+
visibleHandler(isVisible) {
99
+
if (isVisible) {
100
+
// This will only ever happen once, when the
101
+
// element has become visible for the first time
102
+
} else {
103
+
// This may happen zero or more times before
104
+
// the element becomes visible, but will never
105
+
// happen after the element has become visible
106
+
}
107
+
}
108
+
}
109
+
}
110
+
</script>
111
+
```
112
+
113
+
With `once` and offset modifiers:
114
+
115
+
```html
116
+
<template>
117
+
<div v-b-visible.350.once="visibleHandler"> ... </div>
118
+
</template>
119
+
<script>
120
+
export default {
121
+
methods: {
122
+
visibleHandler(isVisible) {
123
+
if (isVisible) {
124
+
// This will only ever happen once, when the
125
+
// element has become visible for the first time
126
+
} else {
127
+
// This may happen zero or more times before
128
+
// the element becomes visible, but will never
129
+
// happen after the element has become visible
130
+
}
131
+
}
132
+
}
133
+
}
134
+
</script>
135
+
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
1
+
//
2
+
// VBVisible
3
+
//
4
+
import Vue, { DirectiveOptions } from 'vue'
5
+
import { BvPlugin } from '../../'
6
+
7
+
// Plugin
8
+
export declare const VBVisiblePlugin: BvPlugin
9
+
10
+
// Directive: v-b-visible
11
+
export declare const VBVisible: DirectiveOptions
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
1
+
import { VBVisible } from './visible'
2
+
import { pluginFactory } from '../../utils/plugins'
3
+
4
+
const VBVisiblePlugin = /*#__PURE__*/ pluginFactory({
5
+
directives: { VBVisible }
6
+
})
7
+
8
+
export { VBVisiblePlugin, VBVisible }
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
1
+
{
2
+
"name": "@bootstrap-vue/v-b-visible",
3
+
"version": "0.0.0",
4
+
"meta": {
5
+
"title": "Visible",
6
+
"description": "The `v-b-visible` directive allows you to react when an element becomes visible in the viewport.",
7
+
"directive": "VBVisible",
8
+
"new": true,
9
+
"version": "2.1.0",
10
+
"expression": [
11
+
"Function"
12
+
],
13
+
"modifiers": [
14
+
{
15
+
"name": "once",
16
+
"description": "Only calls the callback once when the element becomes visible in the viewport"
17
+
},
18
+
{
19
+
"name": "{###}",
20
+
"pattern": "[0-9]+",
21
+
"description": "An offset value in pixels (where `{###}` is the number of pixels) relative to the viewport, defaults to 0. Negative values allowed"
22
+
}
23
+
]
24
+
}
25
+
}
Original file line number Diff line number Diff line change
@@ -31,10 +31,10 @@
31
31
// )
32
32
// }
33
33
34
-
import looseEqual from '../utils/loose-equal'
35
-
import { requestAF } from '../utils/dom'
36
-
import { isFunction } from '../utils/inspect'
37
-
import { keys } from '../utils/object'
34
+
import looseEqual from '../../utils/loose-equal'
35
+
import { requestAF } from '../../utils/dom'
36
+
import { isFunction } from '../../utils/inspect'
37
+
import { keys } from '../../utils/object'
38
38
39
39
const OBSERVER_PROP_NAME = '__bv__visibility_observer'
40
40
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4