Skip to content

Commit

Permalink
Merge pull request #59 from serebrov/52-optional-vue-virtual-scroller
Browse files Browse the repository at this point in the history
[#52] optional vue virtual scroller
  • Loading branch information
serebrov authored Sep 20, 2019
2 parents 8d61c54 + bdd640a commit 543a504
Show file tree
Hide file tree
Showing 9 changed files with 18,990 additions and 12 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ This was the reason to fork and change it, the demo is [here](https://serebrov.g
Major changes are:

- Reworked emoji index class: use same index (so same data) for all components.
- Added [vue-virtual-scroller](https://github.com/Akryum/vue-virtual-scroller) for emoji categories
- Added [vue-virtual-scroller](https://github.com/Akryum/vue-virtual-scroller) for emoji categories (note: there is `StaticPicker` version that doesn't use virtual scroller)
- Render emojis in categories without `Emoji` component, there are a lot of emojis to render and there is a noticeable slow down even with virtual scrolling when we render a component per emoji.
- Frozen objects with emoji data to disable Vue change tracking
- Do not create `EmojiIndex` globally, before it was loaded (along with the emoji data) even when it was not actually used
Expand Down Expand Up @@ -357,6 +357,14 @@ let index = new EmojiIndex(data, {
}
```

### StaticPicker

Same as `Picker`, but doesn't use [vue-virtual-scroller](https://github.com/Akryum/vue-virtual-scroller).
It is a bit slower, but easier to customize (especially, if you need a custom scroll bar style).

Note: `vue-virtual-scroller` also may lead to rendering problems when `Picker` is used inside the dialog (in particluar, QDialog from Quasar Framework).
The `StaticPicker` might also be useful here, see #57 for other workarounds (disable animation, trigger vue-virtual-scroller update after rendering).

### Emoji

```js
Expand Down
19 changes: 16 additions & 3 deletions css/emoji-mart.css
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@
border-bottom-right-radius: 5px;
}

.emoji-mart-scroll {
position: relative;
overflow-y: scroll;
flex: 1;
padding: 0 6px 6px 6px;
z-index: 0; /* Fix for rendering sticky positioned category labels on Chrome */
will-change: transform; /* avoids "repaints on scroll" in mobile Chrome */
-webkit-overflow-scrolling: touch;
}

.emoji-mart-anchors {
display: flex;
flex-direction: row;
Expand Down Expand Up @@ -175,12 +185,15 @@
}

.emoji-mart-category-label {
/* z-index: 2; */
/* position: relative; */
/* position: -webkit-sticky; */
position: sticky;
top: 0;
}
.emoji-mart-static .emoji-mart-category-label {
z-index: 2;
position: relative;
/* position: sticky; */
/* position: -webkit-sticky; */
}

.emoji-mart-category-label span {
display: block;
Expand Down
11 changes: 8 additions & 3 deletions docs/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@
<div class="row"></div>
<h2>Custom Search And Preview Templates Example</h2>
<div class="row">
<Picker :data="index" :native="true">
Also here we use "StaticPicker" which does not use virtual scroller (it is
slower, but easier to customize with css)
</div>
<div class="row">
<StaticPicker :data="index" :native="true">
<template slot="searchTemplate" slot-scope="slotProps">
<input
type="text"
Expand Down Expand Up @@ -109,7 +113,7 @@
</div>
</div>
</template>
</Picker>
</StaticPicker>
</div>

<div class="row"></div>
Expand All @@ -127,7 +131,7 @@

<script>
import data from '../data/all.json'
import { Picker, Emoji, EmojiIndex } from '../src'
import { Picker, StaticPicker, Emoji, EmojiIndex } from '../src'
import '../css/emoji-mart.css'
import { QBtn, QDialog } from 'quasar-framework/dist/quasar.mat.esm'
Expand Down Expand Up @@ -203,6 +207,7 @@ export default {
},
components: {
Picker,
StaticPicker,
Emoji,
QBtn,
QDialog,
Expand Down
Loading

0 comments on commit 543a504

Please sign in to comment.