@empathyco/x-components 3.0.0-alpha.39 → 3.0.0-alpha.40
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/core/index.js +1 -1
- package/docs/API-reference/api/x-adapter.empathynextquery.md +1 -0
- package/docs/API-reference/api/x-adapter.empathynextquery.source.md +11 -0
- package/docs/API-reference/api/x-components.cancelfetchandsavesearchresponsewire.md +1 -1
- package/docs/API-reference/api/x-components.fetchandsavesearchresponsewire.md +1 -1
- package/docs/API-reference/api/x-components.getnewandupdatedkeys.md +27 -0
- package/docs/API-reference/api/x-components.increasepageappendingresults.md +1 -1
- package/docs/API-reference/api/x-components.md +7 -6
- package/docs/API-reference/api/x-components.resetappending.md +1 -1
- package/docs/API-reference/api/x-components.resetspellcheckquery.md +1 -1
- package/docs/API-reference/api/x-components.resetstatewire.md +13 -0
- package/docs/API-reference/api/x-components.saveoriginwire.md +1 -1
- package/docs/API-reference/api/x-components.scroll.md +1 -3
- package/docs/API-reference/api/x-components.scrollmixin.md +1 -0
- package/docs/API-reference/api/x-components.scrollmixin.reseton.md +13 -0
- package/docs/API-reference/api/x-components.searchactions.md +1 -0
- package/docs/API-reference/api/x-components.searchactions.resetstate.md +24 -0
- package/docs/API-reference/api/x-components.searchxevents.md +1 -0
- package/docs/API-reference/api/x-components.searchxevents.searchrequestupdated.md +13 -0
- package/docs/API-reference/api/x-components.setpagesize.md +1 -1
- package/docs/API-reference/api/x-components.setquerytagginginfo.md +13 -0
- package/docs/API-reference/api/x-components.setrelatedtags.md +1 -1
- package/docs/API-reference/api/x-components.setsearchextraparams.md +1 -1
- package/docs/API-reference/api/x-components.setsearchpage.md +1 -1
- package/docs/API-reference/api/x-components.setsearchquery.md +1 -1
- package/docs/API-reference/api/x-components.setselectedfilters.md +1 -1
- package/docs/API-reference/api/x-components.setsort.md +1 -1
- package/docs/API-reference/api/x-components.seturlparams.md +1 -1
- package/docs/API-reference/api/x-components.slidingpanel.md +2 -12
- package/docs/API-reference/api/x-components.slidingpanel.resetoncontentchange.md +13 -0
- package/docs/API-reference/api/x-components.slidingpanel.scrollfactor.md +1 -1
- package/docs/API-reference/api/x-components.slidingpanel.showbuttons.md +1 -1
- package/docs/API-reference/api/x-components.taggingmutations.md +1 -0
- package/docs/API-reference/api/x-components.taggingmutations.setquerytagginginfo.md +24 -0
- package/docs/API-reference/api/x-components.taggingstate.md +1 -0
- package/docs/API-reference/api/x-components.taggingstate.querytagginginfo.md +13 -0
- package/docs/API-reference/api/x-components.taggingxevents.md +1 -0
- package/docs/API-reference/api/x-components.taggingxevents.searchtaggingreceived.md +13 -0
- package/docs/API-reference/api/x-components.trackquerywire.md +1 -1
- package/docs/API-reference/api/x-components.watchedinternalsearchrequest.md +21 -0
- package/docs/API-reference/api/x-components.watchedinternalsearchrequest.newrequest.md +11 -0
- package/docs/API-reference/api/x-components.watchedinternalsearchrequest.oldrequest.md +11 -0
- package/docs/API-reference/api/x-components.wiremetadata.md +1 -0
- package/docs/API-reference/api/x-components.wiremetadata.oldvalue.md +13 -0
- package/docs/API-reference/api/x-types.nextquery.iscurated.md +13 -0
- package/docs/API-reference/api/x-types.nextquery.md +6 -0
- package/docs/API-reference/components/common/scroll/x-components.base-scroll.md +52 -33
- package/docs/API-reference/components/common/x-components.sliding-panel.md +192 -33
- package/docs/API-reference/components/scroll/x-components.scroll.md +5 -8
- package/js/components/scroll/base-scroll.vue.js +2 -2
- package/js/components/scroll/base-scroll.vue.js.map +1 -1
- package/js/components/scroll/scroll.mixin.js +12 -6
- package/js/components/scroll/scroll.mixin.js.map +1 -1
- package/js/components/sliding-panel.vue.js +2 -2
- package/js/components/sliding-panel.vue.js.map +1 -1
- package/js/components/sliding-panel.vue_rollup-plugin-vue=script.js +56 -40
- package/js/components/sliding-panel.vue_rollup-plugin-vue=script.js.map +1 -1
- package/js/index.js +3 -3
- package/js/plugins/x-emitters.js +3 -3
- package/js/plugins/x-emitters.js.map +1 -1
- package/js/utils/object.js +17 -1
- package/js/utils/object.js.map +1 -1
- package/js/x-modules/facets/wiring.js +3 -0
- package/js/x-modules/facets/wiring.js.map +1 -1
- package/js/x-modules/related-tags/wiring.js +3 -0
- package/js/x-modules/related-tags/wiring.js.map +1 -1
- package/js/x-modules/scroll/components/scroll.vue.js +14 -13
- package/js/x-modules/scroll/components/scroll.vue.js.map +1 -1
- package/js/x-modules/scroll/components/scroll.vue_rollup-plugin-vue=script.js +2 -9
- package/js/x-modules/scroll/components/scroll.vue_rollup-plugin-vue=script.js.map +1 -1
- package/js/x-modules/search/store/actions/increase-page-apending-results.action.js +1 -1
- package/js/x-modules/search/store/actions/increase-page-apending-results.action.js.map +1 -1
- package/js/x-modules/search/store/actions/reset-state.action.js +32 -0
- package/js/x-modules/search/store/actions/reset-state.action.js.map +1 -0
- package/js/x-modules/search/store/emitters.js +6 -0
- package/js/x-modules/search/store/emitters.js.map +1 -1
- package/js/x-modules/search/store/module.js +2 -0
- package/js/x-modules/search/store/module.js.map +1 -1
- package/js/x-modules/search/wiring.js +15 -32
- package/js/x-modules/search/wiring.js.map +1 -1
- package/js/x-modules/tagging/store/emitters.js +2 -4
- package/js/x-modules/tagging/store/emitters.js.map +1 -1
- package/js/x-modules/tagging/store/module.js +5 -1
- package/js/x-modules/tagging/store/module.js.map +1 -1
- package/js/x-modules/tagging/wiring.js +15 -6
- package/js/x-modules/tagging/wiring.js.map +1 -1
- package/package.json +4 -4
- package/report/x-adapter.api.json +26 -0
- package/report/x-components.api.json +449 -290
- package/report/x-components.api.md +51 -34
- package/report/x-types.api.json +28 -1
- package/search/index.js +1 -1
- package/tagging/index.js +1 -1
- package/types/components/scroll/scroll.mixin.d.ts +7 -0
- package/types/components/scroll/scroll.mixin.d.ts.map +1 -1
- package/types/components/sliding-panel.vue.d.ts +35 -18
- package/types/components/sliding-panel.vue.d.ts.map +1 -1
- package/types/utils/object.d.ts +11 -0
- package/types/utils/object.d.ts.map +1 -1
- package/types/wiring/wiring.types.d.ts +2 -0
- package/types/wiring/wiring.types.d.ts.map +1 -1
- package/types/x-modules/facets/wiring.d.ts +3 -0
- package/types/x-modules/facets/wiring.d.ts.map +1 -1
- package/types/x-modules/related-tags/wiring.d.ts +3 -0
- package/types/x-modules/related-tags/wiring.d.ts.map +1 -1
- package/types/x-modules/scroll/components/scroll.vue.d.ts +2 -17
- package/types/x-modules/scroll/components/scroll.vue.d.ts.map +1 -1
- package/types/x-modules/search/events.types.d.ts +5 -0
- package/types/x-modules/search/events.types.d.ts.map +1 -1
- package/types/x-modules/search/store/actions/reset-state.action.d.ts +11 -0
- package/types/x-modules/search/store/actions/reset-state.action.d.ts.map +1 -0
- package/types/x-modules/search/store/emitters.d.ts +4 -0
- package/types/x-modules/search/store/emitters.d.ts.map +1 -1
- package/types/x-modules/search/store/module.d.ts.map +1 -1
- package/types/x-modules/search/store/types.d.ts +7 -1
- package/types/x-modules/search/store/types.d.ts.map +1 -1
- package/types/x-modules/search/types.d.ts +10 -0
- package/types/x-modules/search/types.d.ts.map +1 -1
- package/types/x-modules/search/wiring.d.ts +37 -59
- package/types/x-modules/search/wiring.d.ts.map +1 -1
- package/types/x-modules/tagging/events.types.d.ts +6 -0
- package/types/x-modules/tagging/events.types.d.ts.map +1 -1
- package/types/x-modules/tagging/store/emitters.d.ts +1 -0
- package/types/x-modules/tagging/store/emitters.d.ts.map +1 -1
- package/types/x-modules/tagging/store/module.d.ts.map +1 -1
- package/types/x-modules/tagging/store/types.d.ts +10 -0
- package/types/x-modules/tagging/store/types.d.ts.map +1 -1
- package/types/x-modules/tagging/wiring.d.ts +14 -5
- package/types/x-modules/tagging/wiring.d.ts.map +1 -1
- package/docs/API-reference/api/x-components.resetfacets.md +0 -13
- package/docs/API-reference/api/x-components.resetpage.md +0 -13
- package/docs/API-reference/api/x-components.resetsort.md +0 -13
- package/docs/API-reference/api/x-components.scroll.distancetobottom.md +0 -13
- package/docs/API-reference/api/x-components.scroll.throttlems.md +0 -13
- package/docs/API-reference/api/x-components.slidingpanel._refs.md +0 -15
- package/docs/API-reference/api/x-components.slidingpanel.beforedestroy.md +0 -15
- package/docs/API-reference/api/x-components.slidingpanel.isscrollatend.md +0 -13
- package/docs/API-reference/api/x-components.slidingpanel.isscrollatstart.md +0 -13
- package/docs/API-reference/api/x-components.slidingpanel.mounted.md +0 -15
- package/docs/API-reference/api/x-components.slidingpanel.scrollobserver.md +0 -13
|
@@ -20,5 +20,6 @@ export interface WireMetadata
|
|
|
20
20
|
| [id?](./x-components.wiremetadata.id.md) | string | <i>(Optional)</i> The id of the component origin. |
|
|
21
21
|
| [location?](./x-components.wiremetadata.location.md) | [FeatureLocation](./x-components.featurelocation.md) | <i>(Optional)</i> The [FeatureLocation](./x-components.featurelocation.md) from where the event has been emitted. |
|
|
22
22
|
| [moduleName](./x-components.wiremetadata.modulename.md) | [XModuleName](./x-components.xmodulename.md) \| null | The [XModule](./x-components.xmodule.md) name that emitted the event or <code>null</code> if it has been emitted from an unknown module. |
|
|
23
|
+
| [oldValue?](./x-components.wiremetadata.oldvalue.md) | unknown | <i>(Optional)</i> The old value of a watched selector triggering an emitter. |
|
|
23
24
|
| [target?](./x-components.wiremetadata.target.md) | HTMLElement | <i>(Optional)</i> The DOM element that triggered the event emission. |
|
|
24
25
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [@empathyco/x-components](./x-components.md) > [WireMetadata](./x-components.wiremetadata.md) > [oldValue](./x-components.wiremetadata.oldvalue.md)
|
|
4
|
+
|
|
5
|
+
## WireMetadata.oldValue property
|
|
6
|
+
|
|
7
|
+
The old value of a watched selector triggering an emitter.
|
|
8
|
+
|
|
9
|
+
<b>Signature:</b>
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
oldValue?: unknown;
|
|
13
|
+
```
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [@empathyco/x-types](./x-types.md) > [NextQuery](./x-types.nextquery.md) > [isCurated](./x-types.nextquery.iscurated.md)
|
|
4
|
+
|
|
5
|
+
## NextQuery.isCurated property
|
|
6
|
+
|
|
7
|
+
If it's a curated next query.
|
|
8
|
+
|
|
9
|
+
<b>Signature:</b>
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
isCurated?: boolean;
|
|
13
|
+
```
|
|
@@ -13,3 +13,9 @@ export interface NextQuery extends NamedModel<'NextQuery'>, Required<Previewable
|
|
|
13
13
|
```
|
|
14
14
|
<b>Extends:</b> [NamedModel](./x-types.namedmodel.md)<!-- --><'NextQuery'>, Required<[Previewable](./x-types.previewable.md)<!-- -->>
|
|
15
15
|
|
|
16
|
+
## Properties
|
|
17
|
+
|
|
18
|
+
| Property | Type | Description |
|
|
19
|
+
| --- | --- | --- |
|
|
20
|
+
| [isCurated?](./x-types.nextquery.iscurated.md) | boolean | <i>(Optional)</i> If it's a curated next query. |
|
|
21
|
+
|
|
@@ -11,12 +11,13 @@ knowing when the user scrolls, the direction of scroll and if user reaches the s
|
|
|
11
11
|
|
|
12
12
|
## Props
|
|
13
13
|
|
|
14
|
-
| Name | Description | Type | Default
|
|
15
|
-
| ------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------- |
|
|
16
|
-
| <code>distanceToBottom</code> | Distance to the end of the scroll that when reached will emit the<br />`scroll:about-to-end` event. | <code>number</code> | <code>100</code>
|
|
17
|
-
| <code>firstElementThresholdPx</code> | Positive vertical distance to still consider that the an element is the first one visible.<br />For example, if set to 100, after scrolling 100 pixels, the first rendered element<br />will still be considered the first one. | <code>number</code> | <code>100</code>
|
|
18
|
-
| <code>throttleMs</code> | Time duration to ignore the subsequent scroll events after an emission.<br />Higher values will decrease events precision but can prevent performance issues. | <code>number</code> | <code>100</code>
|
|
19
|
-
| <code>resetOnChange</code> | If true (default), sets the scroll position to the top when certain events are emitted. | <code>boolean</code> | <code>true</code>
|
|
14
|
+
| Name | Description | Type | Default |
|
|
15
|
+
| ------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
16
|
+
| <code>distanceToBottom</code> | Distance to the end of the scroll that when reached will emit the<br />`scroll:about-to-end` event. | <code>number</code> | <code>100</code> |
|
|
17
|
+
| <code>firstElementThresholdPx</code> | Positive vertical distance to still consider that the an element is the first one visible.<br />For example, if set to 100, after scrolling 100 pixels, the first rendered element<br />will still be considered the first one. | <code>number</code> | <code>100</code> |
|
|
18
|
+
| <code>throttleMs</code> | Time duration to ignore the subsequent scroll events after an emission.<br />Higher values will decrease events precision but can prevent performance issues. | <code>number</code> | <code>100</code> |
|
|
19
|
+
| <code>resetOnChange</code> | If true (default), sets the scroll position to the top when certain events are emitted. | <code>boolean</code> | <code>true</code> |
|
|
20
|
+
| <code>resetOn</code> | List of events that should reset the scroll when emitted. | <code>XEvent</code> | <code>() => [<br /> 'SearchBoxQueryChanged',<br /> 'SortChanged',<br /> 'SelectedFiltersChanged',<br /> 'SelectedRelatedTagsChanged',<br /> 'UserChangedExtraParams'<br />]</code> |
|
|
20
21
|
|
|
21
22
|
## Events
|
|
22
23
|
|
|
@@ -36,10 +37,10 @@ knowing when the user scrolls, the direction of scroll and if user reaches the s
|
|
|
36
37
|
|
|
37
38
|
## Example
|
|
38
39
|
|
|
39
|
-
The BaseScroll is a component that
|
|
40
|
-
does the necessary calculations for knowing the direction of scroll, if the scroll has
|
|
41
|
-
start or to end, and is about to reaching to end. The components emits the next events
|
|
42
|
-
movement that realize the user:
|
|
40
|
+
The `BaseScroll` is a component that manages the state of scroll of a specified element. The
|
|
41
|
+
component does the necessary calculations for knowing the direction of scroll, if the scroll has
|
|
42
|
+
reached to start or to end, and is about to reaching to end. The components emits the next events
|
|
43
|
+
depending of movement that realize the user:
|
|
43
44
|
|
|
44
45
|
```vue
|
|
45
46
|
<template>
|
|
@@ -49,8 +50,8 @@ movement that realize the user:
|
|
|
49
50
|
@scroll:at-start="scrollAtStart"
|
|
50
51
|
@scroll:almost-at-end="scrollAlmostAtEnd"
|
|
51
52
|
@scroll:at-end="scrollAtEnd"
|
|
52
|
-
throttleMs="1000"
|
|
53
|
-
distanceToBottom="200"
|
|
53
|
+
:throttleMs="1000"
|
|
54
|
+
:distanceToBottom="200"
|
|
54
55
|
>
|
|
55
56
|
<template>
|
|
56
57
|
<div class="content-scroll">
|
|
@@ -96,15 +97,7 @@ Set to false the reset scroll on query change feature which is true by default.
|
|
|
96
97
|
|
|
97
98
|
```vue
|
|
98
99
|
<template>
|
|
99
|
-
<BaseScroll
|
|
100
|
-
@scroll="scroll"
|
|
101
|
-
@scroll:direction-change="scrollDirectionChange"
|
|
102
|
-
@scroll:at-start="scrollAtStart"
|
|
103
|
-
@scroll:almost-at-end="scrollAlmostAtEnd"
|
|
104
|
-
@scroll:at-end="scrollAtEnd"
|
|
105
|
-
throttleMs="1000"
|
|
106
|
-
distanceToBottom="200"
|
|
107
|
-
>
|
|
100
|
+
<BaseScroll @scroll="scroll" :resetOnChange="false">
|
|
108
101
|
<template>
|
|
109
102
|
<div class="content-scroll">
|
|
110
103
|
<span>content1</span>
|
|
@@ -125,18 +118,44 @@ export default {
|
|
|
125
118
|
methods: {
|
|
126
119
|
scroll(position) {
|
|
127
120
|
console.log("scroll", position);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
</script>
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Reset scroll
|
|
128
|
+
|
|
129
|
+
You can configure which events reset the scroll position using the `resetOn` prop.
|
|
130
|
+
|
|
131
|
+
```vue
|
|
132
|
+
<template>
|
|
133
|
+
<BaseScroll @scroll="scroll" :resetOn="resetScrollEvents">
|
|
134
|
+
<template>
|
|
135
|
+
<div class="content-scroll">
|
|
136
|
+
<span>content1</span>
|
|
137
|
+
<span>content1</span>
|
|
138
|
+
</div>
|
|
139
|
+
</template>
|
|
140
|
+
</BaseScroll>
|
|
141
|
+
</template>
|
|
142
|
+
|
|
143
|
+
<script>
|
|
144
|
+
import { BaseScroll } from "@empathyco/x-components";
|
|
145
|
+
|
|
146
|
+
export default {
|
|
147
|
+
name: "ScrollTest",
|
|
148
|
+
components: {
|
|
149
|
+
BaseScroll
|
|
150
|
+
},
|
|
151
|
+
data() {
|
|
152
|
+
return {
|
|
153
|
+
resetScrollEvents: ["UserAcceptedAQuery"]
|
|
154
|
+
};
|
|
155
|
+
},
|
|
156
|
+
methods: {
|
|
157
|
+
scroll(position) {
|
|
158
|
+
console.log("scroll", position);
|
|
140
159
|
}
|
|
141
160
|
}
|
|
142
161
|
};
|
|
@@ -6,15 +6,17 @@ title: SlidingPanel
|
|
|
6
6
|
|
|
7
7
|
# SlidingPanel
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
navigable
|
|
9
|
+
This component allows for any other component or element inside it to be horizontally
|
|
10
|
+
navigable. It also implements customizable buttons as well as other minor customizations to its
|
|
11
|
+
general behavior.
|
|
11
12
|
|
|
12
13
|
## Props
|
|
13
14
|
|
|
14
|
-
| Name
|
|
15
|
-
|
|
|
16
|
-
| <code>scrollFactor</code>
|
|
17
|
-
| <code>showButtons</code>
|
|
15
|
+
| Name | Description | Type | Default |
|
|
16
|
+
| --------------------------------- | ------------------------------------------------------------------------------------------------------------------- | -------------------- | ----------------- |
|
|
17
|
+
| <code>scrollFactor</code> | Scroll factor that will dictate how much the scroll moves when pressing a navigation button. | <code>number</code> | <code>0.7</code> |
|
|
18
|
+
| <code>showButtons</code> | Would make the navigation buttons visible when they're needed or always hide them. | <code>boolean</code> | <code>true</code> |
|
|
19
|
+
| <code>resetOnContentChange</code> | When true, whenever the DOM content in the sliding panel slot changes, it will reset<br />the scroll position to 0. | <code>boolean</code> | <code>true</code> |
|
|
18
20
|
|
|
19
21
|
## Slots
|
|
20
22
|
|
|
@@ -24,57 +26,214 @@ navigable horizontally using two navigational buttons.
|
|
|
24
26
|
| <code>default</code> | (Required) Sliding panel content | None |
|
|
25
27
|
| <code>sliding-panel-right-button</code> | Right button content | None |
|
|
26
28
|
|
|
27
|
-
##
|
|
29
|
+
## Events
|
|
28
30
|
|
|
29
|
-
This component
|
|
30
|
-
also implements customizable buttons as well as other minor customizations to its general behavior.
|
|
31
|
-
The component uses the method `scrollBy` from `Element` to function, and it doesn't work properly in
|
|
32
|
-
all browsers. A polyfill for the `scrollBy` would be needed for the component to behave as expected
|
|
33
|
-
in those browsers.
|
|
31
|
+
This component emits no events.
|
|
34
32
|
|
|
35
|
-
|
|
33
|
+
## See it in action
|
|
36
34
|
|
|
37
35
|
Simplest implementation of the component, just a list-based component inside its slot.
|
|
38
36
|
|
|
39
37
|
```vue
|
|
40
|
-
<
|
|
41
|
-
<
|
|
42
|
-
</
|
|
38
|
+
<template>
|
|
39
|
+
<SlidingPanel>
|
|
40
|
+
<div class="item">Item 1</div>
|
|
41
|
+
<div class="item">Item 2</div>
|
|
42
|
+
<div class="item">Item 3</div>
|
|
43
|
+
<div class="item">Item 4</div>
|
|
44
|
+
</SlidingPanel>
|
|
45
|
+
</template>
|
|
46
|
+
|
|
47
|
+
<script>
|
|
48
|
+
import { SlidingPanel } from "@empathyco/x-components";
|
|
49
|
+
|
|
50
|
+
export default {
|
|
51
|
+
name: "SlidingPanelDemo",
|
|
52
|
+
components: {
|
|
53
|
+
SlidingPanel
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
</script>
|
|
57
|
+
|
|
58
|
+
<style>
|
|
59
|
+
.x-sliding-panel {
|
|
60
|
+
width: 200px;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.item {
|
|
64
|
+
display: inline-block;
|
|
65
|
+
width: 100px;
|
|
66
|
+
}
|
|
67
|
+
</style>
|
|
43
68
|
```
|
|
44
69
|
|
|
45
|
-
###
|
|
70
|
+
### Play with props
|
|
46
71
|
|
|
47
|
-
|
|
72
|
+
#### Modifying scroll buttons travel distance
|
|
73
|
+
|
|
74
|
+
Edit how much the scroll travels when navigating with the buttons by changing the `scrollFactor`
|
|
75
|
+
prop.
|
|
48
76
|
|
|
49
77
|
```vue
|
|
50
|
-
<
|
|
51
|
-
<
|
|
52
|
-
</
|
|
78
|
+
<template>
|
|
79
|
+
<SlidingPanel :scrollFactor="1.5">
|
|
80
|
+
<div class="item">Item 1</div>
|
|
81
|
+
<div class="item">Item 2</div>
|
|
82
|
+
<div class="item">Item 3</div>
|
|
83
|
+
<div class="item">Item 4</div>
|
|
84
|
+
</SlidingPanel>
|
|
85
|
+
</template>
|
|
86
|
+
|
|
87
|
+
<script>
|
|
88
|
+
import { SlidingPanel } from "@empathyco/x-components";
|
|
89
|
+
|
|
90
|
+
export default {
|
|
91
|
+
name: "SlidingPanelDemo",
|
|
92
|
+
components: {
|
|
93
|
+
SlidingPanel
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
</script>
|
|
97
|
+
|
|
98
|
+
<style>
|
|
99
|
+
.x-sliding-panel {
|
|
100
|
+
width: 200px;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.item {
|
|
104
|
+
display: inline-block;
|
|
105
|
+
width: 100px;
|
|
106
|
+
}
|
|
107
|
+
</style>
|
|
53
108
|
```
|
|
54
109
|
|
|
110
|
+
#### Hiding scroll buttons
|
|
111
|
+
|
|
55
112
|
Hide the navigational buttons completely by setting the `showButtons` prop to `false`. This is
|
|
56
113
|
intended to be used when other scrolling options are available, like in mobile, where you can scroll
|
|
57
114
|
just by swiping.
|
|
58
115
|
|
|
59
116
|
```vue
|
|
60
|
-
<
|
|
61
|
-
<
|
|
62
|
-
</
|
|
117
|
+
<template>
|
|
118
|
+
<SlidingPanel :showButtons="false">
|
|
119
|
+
<div class="item">Item 1</div>
|
|
120
|
+
<div class="item">Item 2</div>
|
|
121
|
+
<div class="item">Item 3</div>
|
|
122
|
+
<div class="item">Item 4</div>
|
|
123
|
+
</SlidingPanel>
|
|
124
|
+
</template>
|
|
125
|
+
|
|
126
|
+
<script>
|
|
127
|
+
import { SlidingPanel } from "@empathyco/x-components";
|
|
128
|
+
|
|
129
|
+
export default {
|
|
130
|
+
name: "SlidingPanelDemo",
|
|
131
|
+
components: {
|
|
132
|
+
SlidingPanel
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
</script>
|
|
136
|
+
|
|
137
|
+
<style>
|
|
138
|
+
.x-sliding-panel {
|
|
139
|
+
width: 200px;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.item {
|
|
143
|
+
display: inline-block;
|
|
144
|
+
width: 100px;
|
|
145
|
+
}
|
|
146
|
+
</style>
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
#### Disabling reset the scroll when content changes
|
|
150
|
+
|
|
151
|
+
By default, whenever the content of the sliding panel changes, it auto resets its scroll position.
|
|
152
|
+
You can disable this behavior setting the `resetOnContentChange` prop to `false`.
|
|
153
|
+
|
|
154
|
+
```vue
|
|
155
|
+
<template>
|
|
156
|
+
<div>
|
|
157
|
+
<button @click="items++">Add item</button>
|
|
158
|
+
<label>
|
|
159
|
+
<input type="checkbox" v-model="resetOnContentChange" />
|
|
160
|
+
Reset content onchange
|
|
161
|
+
</label>
|
|
162
|
+
<SlidingPanel :resetOnContentChange="resetOnContentChange">
|
|
163
|
+
<div class="item" v-for="item in items" :key="item">Item {{ item }}</div>
|
|
164
|
+
</SlidingPanel>
|
|
165
|
+
</div>
|
|
166
|
+
</template>
|
|
167
|
+
|
|
168
|
+
<script>
|
|
169
|
+
import { SlidingPanel } from "@empathyco/x-components";
|
|
170
|
+
|
|
171
|
+
export default {
|
|
172
|
+
name: "SlidingPanelDemo",
|
|
173
|
+
components: {
|
|
174
|
+
SlidingPanel
|
|
175
|
+
},
|
|
176
|
+
data() {
|
|
177
|
+
return {
|
|
178
|
+
items: 4,
|
|
179
|
+
resetOnContentChange: false
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
</script>
|
|
184
|
+
|
|
185
|
+
<style>
|
|
186
|
+
.x-sliding-panel {
|
|
187
|
+
width: 200px;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
.item {
|
|
191
|
+
display: inline-block;
|
|
192
|
+
width: 100px;
|
|
193
|
+
}
|
|
194
|
+
</style>
|
|
63
195
|
```
|
|
64
196
|
|
|
197
|
+
## Extending the component
|
|
198
|
+
|
|
65
199
|
### Overriding Button content
|
|
66
200
|
|
|
67
201
|
By default the buttons show an arrow depicting the direction the scroll would go to when clicked,
|
|
68
202
|
but this content can be customized with anything, from characters to SVG and images.
|
|
69
203
|
|
|
70
204
|
```vue
|
|
71
|
-
<
|
|
72
|
-
<
|
|
73
|
-
Left
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
</
|
|
205
|
+
<template>
|
|
206
|
+
<SlidingPanel>
|
|
207
|
+
<template #sliding-panel-left-button>Left</template>
|
|
208
|
+
<template #default>
|
|
209
|
+
<div class="item">Item 1</div>
|
|
210
|
+
<div class="item">Item 2</div>
|
|
211
|
+
<div class="item">Item 3</div>
|
|
212
|
+
<div class="item">Item 4</div>
|
|
213
|
+
</template>
|
|
214
|
+
<template #sliding-panel-right-button>Right</template>
|
|
215
|
+
</SlidingPanel>
|
|
216
|
+
</template>
|
|
217
|
+
|
|
218
|
+
<script>
|
|
219
|
+
import { SlidingPanel } from "@empathyco/x-components";
|
|
220
|
+
|
|
221
|
+
export default {
|
|
222
|
+
name: "SlidingPanelDemo",
|
|
223
|
+
components: {
|
|
224
|
+
SlidingPanel
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
</script>
|
|
228
|
+
|
|
229
|
+
<style>
|
|
230
|
+
.x-sliding-panel {
|
|
231
|
+
width: 200px;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
.item {
|
|
235
|
+
display: inline-block;
|
|
236
|
+
width: 100px;
|
|
237
|
+
}
|
|
238
|
+
</style>
|
|
80
239
|
```
|
|
@@ -6,17 +6,14 @@ title: Scroll
|
|
|
6
6
|
|
|
7
7
|
# Scroll
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
reaches the start or end.
|
|
9
|
+
Scrollable container that emits scroll related X Events. It exposes all the listeners
|
|
10
|
+
and props from the {@link BaseScroll} component.
|
|
12
11
|
|
|
13
12
|
## Props
|
|
14
13
|
|
|
15
|
-
| Name
|
|
16
|
-
|
|
|
17
|
-
| <code>
|
|
18
|
-
| <code>distanceToBottom</code> | Distance to the end of the scroll that when reached will emit the<br />`scroll:about-to-end` event. | <code>number</code> | <code></code> |
|
|
19
|
-
| <code>id</code> | Id to identify the component. | <code>string</code> | <code>MainScrollId</code> |
|
|
14
|
+
| Name | Description | Type | Default |
|
|
15
|
+
| --------------- | ----------------------------- | ------------------- | ------------------------- |
|
|
16
|
+
| <code>id</code> | Id to identify the component. | <code>string</code> | <code>MainScrollId</code> |
|
|
20
17
|
|
|
21
18
|
## Slots
|
|
22
19
|
|
|
@@ -27,11 +27,11 @@ __vue_render__._withStripped = true;
|
|
|
27
27
|
/* style */
|
|
28
28
|
var __vue_inject_styles__ = function (inject) {
|
|
29
29
|
if (!inject) { return }
|
|
30
|
-
inject("data-v-
|
|
30
|
+
inject("data-v-437d066c_0", { source: ".x-base-scroll[data-v-437d066c] {\n overflow-y: var(--x-string-overflow-scroll, auto);\n}", map: undefined, media: undefined });
|
|
31
31
|
|
|
32
32
|
};
|
|
33
33
|
/* scoped */
|
|
34
|
-
var __vue_scope_id__ = "data-v-
|
|
34
|
+
var __vue_scope_id__ = "data-v-437d066c";
|
|
35
35
|
/* module identifier */
|
|
36
36
|
var __vue_module_identifier__ = undefined;
|
|
37
37
|
/* functional template */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-scroll.vue.js","sources":["../../../../src/components/scroll/base-scroll.vue"],"sourcesContent":["<template>\n <div @scroll=\"throttledStoreScrollData\" class=\"x-scroll x-base-scroll\" data-test=\"base-scroll\">\n <slot />\n </div>\n</template>\n\n<script lang=\"ts\">\n import { mixins } from 'vue-class-component';\n import { Component } from 'vue-property-decorator';\n import ScrollMixin from './scroll.mixin';\n\n /**\n * Base scroll component that depending on the user interactivity emits different events for\n * knowing when the user scrolls, the direction of scroll and if user reaches the start or end.\n *\n * @public\n */\n @Component\n export default class BaseScroll extends mixins(ScrollMixin) {}\n</script>\n\n<style lang=\"scss\" scoped>\n .x-base-scroll {\n overflow-y: var(--x-string-overflow-scroll, auto);\n }\n</style>\n\n<docs lang=\"mdx\">\n## Example\n\nThe BaseScroll is a component that
|
|
1
|
+
{"version":3,"file":"base-scroll.vue.js","sources":["../../../../src/components/scroll/base-scroll.vue"],"sourcesContent":["<template>\n <div @scroll=\"throttledStoreScrollData\" class=\"x-scroll x-base-scroll\" data-test=\"base-scroll\">\n <slot />\n </div>\n</template>\n\n<script lang=\"ts\">\n import { mixins } from 'vue-class-component';\n import { Component } from 'vue-property-decorator';\n import ScrollMixin from './scroll.mixin';\n\n /**\n * Base scroll component that depending on the user interactivity emits different events for\n * knowing when the user scrolls, the direction of scroll and if user reaches the start or end.\n *\n * @public\n */\n @Component\n export default class BaseScroll extends mixins(ScrollMixin) {}\n</script>\n\n<style lang=\"scss\" scoped>\n .x-base-scroll {\n overflow-y: var(--x-string-overflow-scroll, auto);\n }\n</style>\n\n<docs lang=\"mdx\">\n## Example\n\nThe `BaseScroll` is a component that manages the state of scroll of a specified element. The\ncomponent does the necessary calculations for knowing the direction of scroll, if the scroll has\nreached to start or to end, and is about to reaching to end. The components emits the next events\ndepending of movement that realize the user:\n\n```vue\n<template>\n <BaseScroll\n @scroll=\"scroll\"\n @scroll:direction-change=\"scrollDirectionChange\"\n @scroll:at-start=\"scrollAtStart\"\n @scroll:almost-at-end=\"scrollAlmostAtEnd\"\n @scroll:at-end=\"scrollAtEnd\"\n :throttleMs=\"1000\"\n :distanceToBottom=\"200\"\n >\n <template>\n <div class=\"content-scroll\">\n <span>content1</span>\n <span>content1</span>\n </div>\n </template>\n </BaseScroll>\n</template>\n\n<script>\n import { BaseScroll } from '@empathyco/x-components';\n\n export default {\n name: 'ScrollTest',\n components: {\n BaseScroll\n },\n methods: {\n scroll(position) {\n console.log('scroll', position);\n },\n scrollDirectionChange(direction) {\n console.log('scroll:direction-change', direction);\n },\n scrollAtStart() {\n console.log('scroll:at-start');\n },\n scrollAlmostAtEnd(distance) {\n console.log('scroll:almost-at-end', distance);\n },\n scrollAtEnd() {\n console.log('scroll:at-end');\n }\n }\n };\n</script>\n```\n\n### Avoid reset scroll on query change\n\nSet to false the reset scroll on query change feature which is true by default.\n\n```vue\n<template>\n <BaseScroll @scroll=\"scroll\" :resetOnChange=\"false\">\n <template>\n <div class=\"content-scroll\">\n <span>content1</span>\n <span>content1</span>\n </div>\n </template>\n </BaseScroll>\n</template>\n\n<script>\n import { BaseScroll } from '@empathyco/x-components';\n\n export default {\n name: 'ScrollTest',\n components: {\n BaseScroll\n },\n methods: {\n scroll(position) {\n console.log('scroll', position);\n }\n }\n };\n</script>\n```\n\n### Reset scroll\n\nYou can configure which events reset the scroll position using the `resetOn` prop.\n\n```vue\n<template>\n <BaseScroll @scroll=\"scroll\" :resetOn=\"resetScrollEvents\">\n <template>\n <div class=\"content-scroll\">\n <span>content1</span>\n <span>content1</span>\n </div>\n </template>\n </BaseScroll>\n</template>\n\n<script>\n import { BaseScroll } from '@empathyco/x-components';\n\n export default {\n name: 'ScrollTest',\n components: {\n BaseScroll\n },\n data() {\n return {\n resetScrollEvents: ['UserAcceptedAQuery']\n };\n },\n methods: {\n scroll(position) {\n console.log('scroll', position);\n }\n }\n };\n</script>\n```\n\n## Vue Events:\n\n- `scroll`: the event is emitted after the user scrolls in this container. The payload is the scroll\n top distance in pixels.\n- `scroll:direction-change`: the event is emitted when the user changes the scroll direction. The\n payload is the new scrolling direction.\n- `scroll:at-start`: the event is emitted when the user scrolls up to the initial position of the\n scroll.\n- `scroll:almost-at-end`: the event is emitted when the user is about to reach the bottom part of\n the scroll.\n- `scroll:at-end`: the event is emitted when the user has reached the bottom part of the scroll.\n</docs>\n"],"names":["const"],"mappings":";;;;;AAEAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -237,12 +237,18 @@ var ScrollMixin = /** @class */ (function (_super) {
|
|
|
237
237
|
Prop({ type: Boolean, default: true })
|
|
238
238
|
], ScrollMixin.prototype, "resetOnChange", void 0);
|
|
239
239
|
__decorate([
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
240
|
+
Prop({
|
|
241
|
+
default: function () { return [
|
|
242
|
+
'SearchBoxQueryChanged',
|
|
243
|
+
'SortChanged',
|
|
244
|
+
'SelectedFiltersChanged',
|
|
245
|
+
'SelectedRelatedTagsChanged',
|
|
246
|
+
'UserChangedExtraParams'
|
|
247
|
+
]; }
|
|
248
|
+
})
|
|
249
|
+
], ScrollMixin.prototype, "resetOn", void 0);
|
|
250
|
+
__decorate([
|
|
251
|
+
XOn(function (instance) { return instance.resetOn; })
|
|
246
252
|
], ScrollMixin.prototype, "resetScroll", null);
|
|
247
253
|
__decorate([
|
|
248
254
|
Watch('currentPosition')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scroll.mixin.js","sources":["../../../../src/components/scroll/scroll.mixin.ts"],"sourcesContent":["import Vue from 'vue';\nimport { Component, Prop, Watch } from 'vue-property-decorator';\nimport { throttle } from '../../utils/throttle';\nimport { XOn } from '../decorators/bus.decorators';\nimport { ScrollDirection } from './scroll.types';\n\n/**\n * Mixin to share Scroll logic.\n *\n * @public\n */\n@Component\n/* eslint-disable @typescript-eslint/unbound-method */\nexport default class ScrollMixin extends Vue {\n /**\n * The scrolling container reference.\n *\n * @public\n */\n public $el!: HTMLElement;\n /**\n * Distance to the end of the scroll that when reached will emit the\n * `scroll:about-to-end` event.\n *\n * @public\n */\n @Prop({ default: 100 })\n public distanceToBottom!: number;\n /**\n * Positive vertical distance to still consider that the an element is the first one visible.\n * For example, if set to 100, after scrolling 100 pixels, the first rendered element\n * will still be considered the first one.\n */\n @Prop({ default: 100 })\n public firstElementThresholdPx!: number;\n /**\n * Time duration to ignore the subsequent scroll events after an emission.\n * Higher values will decrease events precision but can prevent performance issues.\n *\n * @public\n */\n @Prop({ default: 100 })\n public throttleMs!: number;\n\n /**\n * If true (default), sets the scroll position to the top when certain events are emitted.\n *\n * @public\n */\n @Prop({ type: Boolean, default: true })\n protected resetOnChange!: boolean;\n /**\n * Property for getting the client height of scroll.\n *\n * @internal\n */\n protected clientHeight = 0;\n /**\n * Property for getting the current position of scroll.\n *\n * @internal\n */\n protected currentPosition = 0;\n /**\n * Property for getting the direction of scroll.\n *\n * @internal\n */\n protected direction!: ScrollDirection;\n /**\n * Property for getting the previous position of scroll.\n *\n * @internal\n */\n protected previousPosition = 0;\n /**\n * Property for getting the scroll height.\n *\n * @internal\n */\n protected scrollHeight = 0;\n\n /**\n * Throttled version of the function that stores the DOM scroll related properties.\n * The duration of the throttle is configured through the\n * {@link ScrollMixin.throttleMs}.\n *\n * @returns A throttled version of the function to store the scroll data.\n * @internal\n */\n protected get throttledStoreScrollData(): () => void {\n return throttle(this.storeScrollData, this.throttleMs);\n }\n\n /**\n * Returns distance missing to end position position.\n *\n * @returns A number for knowing the distance missing to end position position.\n * @internal\n */\n protected get distanceToEnd(): number {\n return this.scrollEndPosition - this.currentPosition;\n }\n\n /**\n * Returns `true` when the amount of pixels scrolled is greater than\n * the {@link ScrollMixin.distanceToBottom}.\n *\n * @returns A boolean for knowing if the user is about to reaching to the end.\n * @internal\n */\n protected get hasScrollAlmostReachedEnd(): boolean {\n return !this.hasScrollReachedStart && this.distanceToBottom > this.distanceToEnd;\n }\n\n /**\n * Returns `true` when there is no more content to scroll.\n *\n * @returns A boolean for knowing if the user scrolls to the end.\n * @internal\n */\n protected get hasScrollReachedEnd(): boolean {\n return this.currentPosition === this.scrollEndPosition;\n }\n\n /**\n * Returns `true` when the scroll is at the initial position.\n *\n * @returns A boolean for knowing if the user scrolls to the start.\n * @internal\n */\n protected get hasScrollReachedStart(): boolean {\n return this.currentPosition === 0;\n }\n\n /**\n * Returns direction of scroll based in {@link ScrollDirection}.\n *\n * @returns The scroll direction.\n * @internal\n */\n protected get scrollDirection(): ScrollDirection {\n return this.currentPosition > this.previousPosition ? 'DOWN' : 'UP';\n }\n\n /**\n * Returns end position of scroll.\n *\n * @returns A number for knowing end position of scroll.\n * @internal\n */\n protected get scrollEndPosition(): number {\n return this.scrollHeight - this.clientHeight;\n }\n\n /**\n * Initialises DOM dependant scroll properties.\n *\n * @internal\n */\n mounted(): void {\n this.$nextTick().then(() => {\n if (!this.$el) {\n // TODO Replace with Empathy's logger\n // eslint-disable-next-line no-console\n console.warn(\n '[ScrollMixin]',\n 'Components using this mixin must set `this.$el` to the HTML node that is scrolling.'\n );\n } else {\n this.storeScrollData();\n }\n });\n }\n\n /**\n * Resets the scroll position.\n *\n * @internal\n */\n @XOn([\n 'SearchBoxQueryChanged',\n 'SortChanged',\n 'SelectedFiltersChanged',\n 'SelectedRelatedTagsChanged'\n ])\n resetScroll(): void {\n this.$nextTick().then(() => {\n if (this.resetOnChange) {\n this.$el.scrollTo({ top: 0 });\n }\n });\n }\n\n /**\n * Emits the `scroll` event.\n *\n * @param _newScrollPosition - The new position of scroll.\n * @param oldScrollPosition - The old position of scroll.\n * @internal\n */\n @Watch('currentPosition')\n protected emitScroll(_newScrollPosition: number, oldScrollPosition: number): void {\n this.$emit('scroll', this.currentPosition);\n this.previousPosition = oldScrollPosition;\n }\n\n /**\n * Emits the 'scroll:at-start' event when the user reaches the start.\n *\n * @param isScrollAtStart - For knowing if the user reaches at start.\n * @internal\n */\n @Watch('hasScrollReachedStart')\n protected emitScrollReachedAtStart(isScrollAtStart: boolean): void {\n this.$emit('scroll:at-start', isScrollAtStart);\n }\n\n /**\n * Emits the 'scroll:almost-at-end' event when the user is about to reach to end.\n *\n * @param isScrollAlmostAtEnd - For knowing if the user is about to reach to end.\n * @internal\n */\n @Watch('hasScrollAlmostReachedEnd')\n protected emitScrollAlmostAtEnd(isScrollAlmostAtEnd: boolean): void {\n this.$emit('scroll:almost-at-end', isScrollAlmostAtEnd);\n }\n\n /**\n * Emits the 'scroll:at-end' event when the user reaches the end.\n *\n * @param isScrollAtEnd - For knowing if the user reaches at end.\n * @internal\n */\n @Watch('hasScrollReachedEnd')\n protected emitScrollAtEnd(isScrollAtEnd: boolean): void {\n this.$emit('scroll:at-end', isScrollAtEnd);\n }\n\n /**\n * Emits the `scroll:direction-change` event when the scrolling direction has changed.\n *\n * @param direction - The new direction of scroll.\n * @internal\n */\n @Watch('scrollDirection')\n protected emitScrollDirection(direction: ScrollDirection): void {\n this.$emit('scroll:direction-change', direction);\n }\n\n /**\n * Updates scroll related properties.\n *\n * @internal\n */\n protected storeScrollData(): void {\n if (this.$el) {\n this.currentPosition = this.$el.scrollTop;\n this.scrollHeight = this.$el.scrollHeight;\n this.clientHeight = this.$el.clientHeight;\n }\n }\n}\n/* eslint-enable @typescript-eslint/unbound-method */\n"],"names":[],"mappings":";;;;;;AAMA;;;;;AAOA;IAAyC,+BAAG;;IAA5C;QAAA,qEA0PC;;;;;;QA/MW,kBAAY,GAAG,CAAC,CAAC;;;;;;QAMjB,qBAAe,GAAG,CAAC,CAAC;;;;;;QAYpB,sBAAgB,GAAG,CAAC,CAAC;;;;;;QAMrB,kBAAY,GAAG,CAAC,CAAC;;KAuL5B;IA7KC,sBAAc,iDAAwB;;;;;;;;;aAAtC;YACE,OAAO,QAAQ,CAAC,IAAI,CAAC,eAAe,EAAE,IAA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QANC,GAAG,CAAC;YACH,uBAAuB;YACvB,aAAa;YACb,wBAAwB;YACxB,4BAA4B;SAC7B,CAAC;kDAOD;IAUD;QADC,KAAK,CAAC,iBAAiB,CAAC;iDAIxB;IASD;QADC,KAAK,CAAC,uBAAuB,CAAC;+DAG9B;IASD;QADC,KAAK,CAAC,2BAA2B,CAAC;4DAGlC;IASD;QADC,KAAK,CAAC,qBAAqB,CAAC;sDAG5B;IASD;QADC,KAAK,CAAC,iBAAiB,CAAC;0DAGxB;IA5OkB,WAAW;QAF/B,SAAS;;OAEW,WAAW,CA0P/B;IAAD,kBAAC;CAAA,CA1PwC,GAAG,GA0P3C;AACD;;;;"}
|
|
1
|
+
{"version":3,"file":"scroll.mixin.js","sources":["../../../../src/components/scroll/scroll.mixin.ts"],"sourcesContent":["import Vue from 'vue';\nimport { Component, Prop, Watch } from 'vue-property-decorator';\nimport { throttle } from '../../utils/throttle';\nimport { XEvent } from '../../wiring/events.types';\nimport { XOn } from '../decorators/bus.decorators';\nimport { ScrollDirection } from './scroll.types';\n\n/**\n * Mixin to share Scroll logic.\n *\n * @public\n */\n@Component\n/* eslint-disable @typescript-eslint/unbound-method */\nexport default class ScrollMixin extends Vue {\n /**\n * The scrolling container reference.\n *\n * @public\n */\n public $el!: HTMLElement;\n /**\n * Distance to the end of the scroll that when reached will emit the\n * `scroll:about-to-end` event.\n *\n * @public\n */\n @Prop({ default: 100 })\n public distanceToBottom!: number;\n /**\n * Positive vertical distance to still consider that the an element is the first one visible.\n * For example, if set to 100, after scrolling 100 pixels, the first rendered element\n * will still be considered the first one.\n */\n @Prop({ default: 100 })\n public firstElementThresholdPx!: number;\n /**\n * Time duration to ignore the subsequent scroll events after an emission.\n * Higher values will decrease events precision but can prevent performance issues.\n *\n * @public\n */\n @Prop({ default: 100 })\n public throttleMs!: number;\n\n /**\n * If true (default), sets the scroll position to the top when certain events are emitted.\n *\n * @public\n */\n @Prop({ type: Boolean, default: true })\n protected resetOnChange!: boolean;\n\n /**\n * List of events that should reset the scroll when emitted.\n *\n * @public\n */\n @Prop({\n default: () => [\n 'SearchBoxQueryChanged',\n 'SortChanged',\n 'SelectedFiltersChanged',\n 'SelectedRelatedTagsChanged',\n 'UserChangedExtraParams'\n ]\n })\n public resetOn!: XEvent;\n\n /**\n * Property for getting the client height of scroll.\n *\n * @internal\n */\n protected clientHeight = 0;\n /**\n * Property for getting the current position of scroll.\n *\n * @internal\n */\n protected currentPosition = 0;\n /**\n * Property for getting the direction of scroll.\n *\n * @internal\n */\n protected direction!: ScrollDirection;\n /**\n * Property for getting the previous position of scroll.\n *\n * @internal\n */\n protected previousPosition = 0;\n /**\n * Property for getting the scroll height.\n *\n * @internal\n */\n protected scrollHeight = 0;\n\n /**\n * Throttled version of the function that stores the DOM scroll related properties.\n * The duration of the throttle is configured through the\n * {@link ScrollMixin.throttleMs}.\n *\n * @returns A throttled version of the function to store the scroll data.\n * @internal\n */\n protected get throttledStoreScrollData(): () => void {\n return throttle(this.storeScrollData, this.throttleMs);\n }\n\n /**\n * Returns distance missing to end position position.\n *\n * @returns A number for knowing the distance missing to end position position.\n * @internal\n */\n protected get distanceToEnd(): number {\n return this.scrollEndPosition - this.currentPosition;\n }\n\n /**\n * Returns `true` when the amount of pixels scrolled is greater than\n * the {@link ScrollMixin.distanceToBottom}.\n *\n * @returns A boolean for knowing if the user is about to reaching to the end.\n * @internal\n */\n protected get hasScrollAlmostReachedEnd(): boolean {\n return !this.hasScrollReachedStart && this.distanceToBottom > this.distanceToEnd;\n }\n\n /**\n * Returns `true` when there is no more content to scroll.\n *\n * @returns A boolean for knowing if the user scrolls to the end.\n * @internal\n */\n protected get hasScrollReachedEnd(): boolean {\n return this.currentPosition === this.scrollEndPosition;\n }\n\n /**\n * Returns `true` when the scroll is at the initial position.\n *\n * @returns A boolean for knowing if the user scrolls to the start.\n * @internal\n */\n protected get hasScrollReachedStart(): boolean {\n return this.currentPosition === 0;\n }\n\n /**\n * Returns direction of scroll based in {@link ScrollDirection}.\n *\n * @returns The scroll direction.\n * @internal\n */\n protected get scrollDirection(): ScrollDirection {\n return this.currentPosition > this.previousPosition ? 'DOWN' : 'UP';\n }\n\n /**\n * Returns end position of scroll.\n *\n * @returns A number for knowing end position of scroll.\n * @internal\n */\n protected get scrollEndPosition(): number {\n return this.scrollHeight - this.clientHeight;\n }\n\n /**\n * Initialises DOM dependant scroll properties.\n *\n * @internal\n */\n mounted(): void {\n this.$nextTick().then(() => {\n if (!this.$el) {\n // TODO Replace with Empathy's logger\n // eslint-disable-next-line no-console\n console.warn(\n '[ScrollMixin]',\n 'Components using this mixin must set `this.$el` to the HTML node that is scrolling.'\n );\n } else {\n this.storeScrollData();\n }\n });\n }\n\n /**\n * Resets the scroll position.\n *\n * @internal\n */\n @XOn(instance => (instance as ScrollMixin).resetOn)\n resetScroll(): void {\n this.$nextTick().then(() => {\n if (this.resetOnChange) {\n this.$el.scrollTo({ top: 0 });\n }\n });\n }\n\n /**\n * Emits the `scroll` event.\n *\n * @param _newScrollPosition - The new position of scroll.\n * @param oldScrollPosition - The old position of scroll.\n * @internal\n */\n @Watch('currentPosition')\n protected emitScroll(_newScrollPosition: number, oldScrollPosition: number): void {\n this.$emit('scroll', this.currentPosition);\n this.previousPosition = oldScrollPosition;\n }\n\n /**\n * Emits the 'scroll:at-start' event when the user reaches the start.\n *\n * @param isScrollAtStart - For knowing if the user reaches at start.\n * @internal\n */\n @Watch('hasScrollReachedStart')\n protected emitScrollReachedAtStart(isScrollAtStart: boolean): void {\n this.$emit('scroll:at-start', isScrollAtStart);\n }\n\n /**\n * Emits the 'scroll:almost-at-end' event when the user is about to reach to end.\n *\n * @param isScrollAlmostAtEnd - For knowing if the user is about to reach to end.\n * @internal\n */\n @Watch('hasScrollAlmostReachedEnd')\n protected emitScrollAlmostAtEnd(isScrollAlmostAtEnd: boolean): void {\n this.$emit('scroll:almost-at-end', isScrollAlmostAtEnd);\n }\n\n /**\n * Emits the 'scroll:at-end' event when the user reaches the end.\n *\n * @param isScrollAtEnd - For knowing if the user reaches at end.\n * @internal\n */\n @Watch('hasScrollReachedEnd')\n protected emitScrollAtEnd(isScrollAtEnd: boolean): void {\n this.$emit('scroll:at-end', isScrollAtEnd);\n }\n\n /**\n * Emits the `scroll:direction-change` event when the scrolling direction has changed.\n *\n * @param direction - The new direction of scroll.\n * @internal\n */\n @Watch('scrollDirection')\n protected emitScrollDirection(direction: ScrollDirection): void {\n this.$emit('scroll:direction-change', direction);\n }\n\n /**\n * Updates scroll related properties.\n *\n * @internal\n */\n protected storeScrollData(): void {\n if (this.$el) {\n this.currentPosition = this.$el.scrollTop;\n this.scrollHeight = this.$el.scrollHeight;\n this.clientHeight = this.$el.clientHeight;\n }\n }\n}\n/* eslint-enable @typescript-eslint/unbound-method */\n"],"names":[],"mappings":";;;;;;AAOA;;;;;AAOA;IAAyC,+BAAG;;IAA5C;QAAA,qEAsQC;;;;;;QA1MW,kBAAY,GAAG,CAAC,CAAC;;;;;;QAMjB,qBAAe,GAAG,CAAC,CAAC;;;;;;QAYpB,sBAAgB,GAAG,CAAC,CAAC;;;;;;QAMrB,kBAAY,GAAG,CAAC,CAAC;;KAkL5B;IAxKC,sBAAc,iDAAwB;;;;;;;;;aAAtC;YACE,OAAO,QAAQ,CAAC,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;SACxD;;;OAAA;IAQD,sBAAc,sCAAa;;;;;;;aAA3B;YACE,OAAO,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,eAAe,CAAC;SACtD;;;OAAA;IASD,sBAAc,kDAAyB;;;;;;;;aAAvC;YACE,OAAO,CAAC,IAAI,CAAC,qBAAqB,IAAI,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,aAAa,CAAC;SAClF;;;OAAA;IAQD,sBAAc,4CAAmB;;;;;;;aAAjC;YACE,OAAO,IAAI,CAAC,eAAe,KAAK,IAAI,CAAC,iBAAiB,CAAC;SACxD;;;OAAA;IAQD,sBAAc,8CAAqB;;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KAAK,CAAC,iBAAiB,CAAC;0DAGxB;IAxPkB,WAAW;QAF/B,SAAS;;OAEW,WAAW,CAsQ/B;IAAD,kBAAC;CAAA,CAtQwC,GAAG,GAsQ3C;AACD;;;;"}
|
|
@@ -77,11 +77,11 @@ __vue_render__._withStripped = true;
|
|
|
77
77
|
/* style */
|
|
78
78
|
var __vue_inject_styles__ = function (inject) {
|
|
79
79
|
if (!inject) { return }
|
|
80
|
-
inject("data-v-
|
|
80
|
+
inject("data-v-561f2662_0", { source: ".x-sliding-panel[data-v-561f2662] {\n align-items: center;\n display: flex;\n flex-flow: row nowrap;\n height: 100%;\n position: relative;\n}\n.x-sliding-panel__button[data-v-561f2662] {\n opacity: 0;\n pointer-events: none;\n position: absolute;\n transition: all ease-out 0.2s;\n z-index: 2;\n /* To overlay the design system gradient with z-index:1 */\n}\n.x-sliding-panel__button-left[data-v-561f2662] {\n left: 0;\n}\n.x-sliding-panel__button-right[data-v-561f2662] {\n right: 0;\n}\n.x-sliding-panel__scroll[data-v-561f2662] {\n display: flex;\n flex: 100%;\n flex-flow: row nowrap;\n overflow: auto;\n scrollbar-width: none;\n -ms-overflow-style: none;\n}\n.x-sliding-panel__scroll[data-v-561f2662]::-webkit-scrollbar {\n display: none;\n}\n.x-sliding-panel:not(.x-sliding-panel--show-buttons-on-hover):not(.x-sliding-panel--at-start) .x-sliding-panel__button-left[data-v-561f2662] {\n opacity: 1;\n pointer-events: all;\n}\n.x-sliding-panel:not(.x-sliding-panel--show-buttons-on-hover):not(.x-sliding-panel--at-end) .x-sliding-panel__button-right[data-v-561f2662] {\n opacity: 1;\n pointer-events: all;\n}", map: undefined, media: undefined });
|
|
81
81
|
|
|
82
82
|
};
|
|
83
83
|
/* scoped */
|
|
84
|
-
var __vue_scope_id__ = "data-v-
|
|
84
|
+
var __vue_scope_id__ = "data-v-561f2662";
|
|
85
85
|
/* module identifier */
|
|
86
86
|
var __vue_module_identifier__ = undefined;
|
|
87
87
|
/* functional template */
|