Skip to content

Commit 9c72f2b

Browse files
committed
(props) add scroll-distance
1 parent 86b97c9 commit 9c72f2b

File tree

4 files changed

+19
-11
lines changed

4 files changed

+19
-11
lines changed

README.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,10 @@ fetchMessages({ room, options }) {
244244
| `textarea-action-enabled`(18) | Boolean | - | `false` |
245245
| `responsive-breakpoint`(19) | Number | - | `900` |
246246
| `single-room`(20) | Boolean | - | `false` |
247-
| `theme`(21) | Sring | - | `light` |
248-
| `accepted-files`(22) | String | - | `*` |
249-
| `styles`(23) | Object | - | (23) |
247+
| `scroll-distance`(21) | Number | - | `60` |
248+
| `theme`(22) | Sring | - | `light` |
249+
| `accepted-files`(23) | String | - | `*` |
250+
| `styles`(24) | Object | - | (23) |
250251

251252
**(1)** `current-user-id` is required to display UI and trigger actions according to the user using the chat (ex: messages position on the right, etc.)
252253

@@ -414,13 +415,15 @@ You can then use the [textarea-action-handler](#events-api) event to call your o
414415

415416
**(20)** `single-room` can be used if you never want to show the rooms list on the left. You still need to pass the `rooms` prop as an array with a single element.
416417

417-
**(21)** `theme` can be used to change the chat theme. Currently, only `light` and `dark` are available.
418+
**(21)** `scroll-distance` can be used to change the number of pixels before `fetchMessages` event is triggered when scrolling up to load more messages, or `fetchMoreRooms` event is triggered when scrolling down to load more rooms.
418419

419-
**(22)** `accepted-files` can be used to set specifics file types allowed in chat. By default, all file types are allowed: `"*"`.
420+
**(22)** `theme` can be used to change the chat theme. Currently, only `light` and `dark` are available.
421+
422+
**(23)** `accepted-files` can be used to set specifics file types allowed in chat. By default, all file types are allowed: `"*"`.
420423

421424
Example: set `"accepted-files="image/png, image/jpeg, application/pdf"` to allow `JPG` `PNG` and `PDF` files only
422425

423-
**(23)** `styles` can be used to customize your own theme. You can find the full list [here](src/themes/index.js)
426+
**(24)** `styles` can be used to customize your own theme. You can find the full list [here](src/themes/index.js)
424427

425428
```javascript
426429
styles="{
@@ -678,8 +681,8 @@ Example:
678681
```
679682

680683
| <div style="width:230px">Slot</div> | Action | Data | Overridden slots |
681-
| ----------------------------------- | ----------------------------------------------------------- | ----------------------------------- | ------------------------------------------------------------------------------------------------------------------ |
682-
| `custom-action-icon` | Add a custom icon inside the footer | - | - | | `rooms-header` | Add a template on top of rooms list (above the search bar) | - | - |
684+
| ----------------------------------- | ----------------------------------------------------------- | ----------------------------------- | ------------------------------------------------------------------------------------------------------------------ | --- | -------------- | ---------------------------------------------------------- | --- | --- |
685+
| `custom-action-icon` | Add a custom icon inside the footer | - | - | | `rooms-header` | Add a template on top of rooms list (above the search bar) | - | - |
683686
| `room-list-item` | Replace the template of the room list items | `room` | `room-list-avatar`, `room-list-options` |
684687
| `room-list-avatar` | Replace the avatar of room list items | `room` | |
685688
| `room-list-options` | Replace the template of the list room options | `room` | `room-list-options-icon` |

src/lib/ChatWindow.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
:text-formatting="textFormatting"
1717
:link-options="linkOptions"
1818
:is-mobile="isMobile"
19+
:scroll-distance="scrollDistance"
1920
@fetch-room="fetchRoom"
2021
@fetch-more-rooms="fetchMoreRooms"
2122
@loading-more-rooms="loadingMoreRooms = $event"
@@ -55,6 +56,7 @@
5556
:loading-rooms="loadingRooms"
5657
:room-info-enabled="roomInfoEnabled"
5758
:textarea-action-enabled="textareaActionEnabled"
59+
:scroll-distance="scrollDistance"
5860
:accepted-files="acceptedFiles"
5961
:templates-text="templatesText"
6062
@toggle-rooms-list="toggleRoomsList"
@@ -143,6 +145,7 @@ export default {
143145
roomInfoEnabled: { type: Boolean, default: false },
144146
textareaActionEnabled: { type: Boolean, default: false },
145147
roomMessage: { type: String, default: '' },
148+
scrollDistance: { type: Number, default: 60 },
146149
acceptedFiles: { type: String, default: '*' },
147150
templatesText: { type: Array, default: null }
148151
},

src/lib/Room/Room.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ export default {
379379
loadingRooms: { type: Boolean, required: true },
380380
roomInfoEnabled: { type: Boolean, required: true },
381381
textareaActionEnabled: { type: Boolean, required: true },
382+
scrollDistance: { type: Number, required: true },
382383
templatesText: { type: Array, default: null }
383384
},
384385
@@ -593,7 +594,7 @@ export default {
593594
if (loader) {
594595
const options = {
595596
root: document.getElementById('messages-list'),
596-
rootMargin: '60px',
597+
rootMargin: `${this.scrollDistance}px`,
597598
threshold: 0
598599
}
599600

src/lib/RoomsList/RoomsList.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ export default {
9999
loadingRooms: { type: Boolean, required: true },
100100
roomsLoaded: { type: Boolean, required: true },
101101
room: { type: Object, required: true },
102-
roomActions: { type: Array, required: true }
102+
roomActions: { type: Array, required: true },
103+
scrollDistance: { type: Number, required: true }
103104
},
104105
105106
emits: [
@@ -169,7 +170,7 @@ export default {
169170
if (loader) {
170171
const options = {
171172
root: document.getElementById('rooms-list'),
172-
rootMargin: '60px',
173+
rootMargin: `${this.scrollDistance}px`,
173174
threshold: 0
174175
}
175176

0 commit comments

Comments
 (0)