Skip to content

Commit 214a500

Browse files
committed
feat(ui): new Transitions for prev/next
1 parent 9892c9f commit 214a500

File tree

5 files changed

+82
-4
lines changed

5 files changed

+82
-4
lines changed

demo/src/examples/Transition.vue

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<template>
2+
<div style="max-width: 800px; width: 100%;">
3+
<q-icon-picker
4+
v-model="value"
5+
icon-set="material-icons"
6+
:pagination.sync="pagination"
7+
animated
8+
style="height: 220px;"
9+
/>
10+
</div>
11+
</template>
12+
13+
<script>
14+
export default {
15+
data () {
16+
return {
17+
value: '',
18+
pagination: {
19+
itemsPerPage: 60,
20+
page: 0
21+
}
22+
}
23+
}
24+
}
25+
</script>

demo/src/pages/Examples.vue

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ Icon sets contain hundreds, even thousands of icons. This page utilizes several
1212
<example-viewer title="Tooltips" file="Tooltips" :location-url="locationUrl" :js-paths="jsPaths" :css-paths="cssPaths" />
1313
<example-viewer title="Color" file="Color" :location-url="locationUrl" :js-paths="jsPaths" :css-paths="cssPaths" />
1414
<example-viewer title="Selected Color" file="SelectedColor" :location-url="locationUrl" :js-paths="jsPaths" :css-paths="cssPaths" />
15+
<example-viewer title="Transition" file="Transition" :location-url="locationUrl" :js-paths="jsPaths" :css-paths="cssPaths">
16+
<q-markdown>
17+
To turn on transitions, use the `animated` property. To change the type of transition, use the `transition-prev` and `transition-next` properties.
18+
</q-markdown>
19+
</example-viewer>
1520

1621
<example-title title="Advanced" />
1722
<example-viewer title="Filter" file="Filter2" :location-url="locationUrl" :js-paths="jsPaths" :css-paths="cssPaths">
@@ -28,17 +33,17 @@ The `icons` property allows you to use a customized set of icons.
2833
<example-viewer title="Pagination" file="Pagination" :location-url="locationUrl" :js-paths="jsPaths" :css-paths="cssPaths">
2934
<q-markdown class="q-ma-md">
3035
You can use the `pagination` property to control the number of icons displayed at one time. Don't forget to put the `.sync` modifier on the `pagination` property (ie: `:pagination.sync="pagination"`) so the data can flow both ways.
31-
3236
</q-markdown>
3337
</example-viewer>
38+
3439
<example-viewer title="Pagination Color" file="PaginationColor" :location-url="locationUrl" :js-paths="jsPaths" :css-paths="cssPaths">
3540
<q-markdown class="q-ma-md">
3641
`QPagination` is used for the pagination. You can pass any of it's props to it via the `pagination-props` property which takes an object filled with properties.
3742

3843
Enter colors only from the Quasar color palette (ex: "orange-8")
3944
</q-markdown>
40-
4145
</example-viewer>
46+
4247
<example-viewer title="Using Icon Slot" file="UsingIconSlot" :location-url="locationUrl" :js-paths="jsPaths" :css-paths="cssPaths">
4348
<q-markdown class="q-ma-md">
4449
Besides using the scopedSlot `icon`, which gives the `name` of the current icon, you can skin everything the way you wish.
@@ -110,6 +115,7 @@ export default {
110115
this.addToToc('Tooltips', 2)
111116
this.addToToc('Color', 2)
112117
this.addToToc('Selected Color', 2)
118+
this.addToToc('Transition', 2)
113119
114120
this.addToToc('Advanced')
115121
this.addToToc('Filter', 2)

ui/src/components/QIconPicker.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,11 +323,26 @@ export default {
323323
},
324324

325325
__renderContainer (h) {
326-
return h('div', {
326+
const container = h('div', {
327+
key: this.computedPagination.page,
327328
staticClass: 'q-icon-picker__container row'
328329
}, [
329330
...this.__renderIcons(h)
330331
])
332+
333+
if (this.animated === true) {
334+
const transition = 'q-transition--' + (this.direction === 'prev' ? this.transitionPrev : this.transitionNext)
335+
return h('transition', {
336+
props: {
337+
name: transition,
338+
appear: true
339+
}
340+
}, [
341+
container
342+
])
343+
}
344+
345+
return container
331346
},
332347

333348
__renderTooltip (h, name) {

ui/src/components/QIconPicker.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,29 @@
136136
"examples": [
137137
":pagination.sync=\"myPagination\""
138138
]
139+
},
140+
"animated": {
141+
"type": "Boolean",
142+
"category": "behavior",
143+
"desc": "Turns on animation"
144+
},
145+
"transition-prev": {
146+
"type": "String",
147+
"category": "behavior",
148+
"desc": "When animated property is true, transition to use for previous paginated view",
149+
"default": "slide-right",
150+
"examples": [
151+
"transition-prev=\"flip-right\""
152+
]
153+
},
154+
"transition-next": {
155+
"type": "String",
156+
"category": "behavior",
157+
"desc": "When animated property is true, transition to use for next paginated view",
158+
"default": "slide-left",
159+
"examples": [
160+
"transition-next=\"flip-left\""
161+
]
139162
}
140163
},
141164
"events": {

ui/src/components/utils/props.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,15 @@ export default {
4343
input: true
4444
})
4545
},
46-
pagination: Object
46+
pagination: Object,
47+
animated: Boolean,
48+
transitionPrev: {
49+
type: String,
50+
default: 'slide-right'
51+
},
52+
transitionNext: {
53+
type: String,
54+
default: 'slide-left'
55+
}
4756
}
4857
}

0 commit comments

Comments
 (0)