@@ -38,7 +38,12 @@ export default {
3838 default : 'bottom' ,
3939 validator : v => [ 'top' , 'bottom' ] . includes ( v )
4040 } ,
41- quickNavIcon : String
41+ quickNavIcon : String ,
42+ thumbnails : {
43+ type : Array ,
44+ default : ( ) => ( [ ] )
45+ } ,
46+ thumbnailsIcon : String
4247 } ,
4348 provide ( ) {
4449 return {
@@ -51,7 +56,8 @@ export default {
5156 slide : 0 ,
5257 positionSlide : 0 ,
5358 slidesNumber : 0 ,
54- animUid : false
59+ animUid : false ,
60+ viewThumbnails : false
5561 }
5662 } ,
5763 watch : {
@@ -119,6 +125,9 @@ export default {
119125 canGoToNext : this . canGoToNext ,
120126 canGoToPrevious : this . canGoToPrevious
121127 }
128+ } ,
129+ computedThumbnailIcon ( ) {
130+ return this . thumbnailIcon || this . $q . icon . carousel . thumbnails
122131 }
123132 } ,
124133 methods : {
@@ -335,9 +344,7 @@ export default {
335344 color : this . color
336345 } ,
337346 on : {
338- click : ( ) => {
339- this . goToSlide ( i )
340- }
347+ click : ( ) => { this . goToSlide ( i ) }
341348 }
342349 } ) )
343350 }
@@ -347,6 +354,58 @@ export default {
347354 staticClass : 'q-carousel-quick-nav scroll text-center' ,
348355 'class' : [ `text-${ this . color } ` , `absolute-${ this . quickNavPosition } ` ]
349356 } , items )
357+ } ,
358+ __getThumbnails ( h ) {
359+ const slides = this . thumbnails . map ( ( img , index ) => {
360+ if ( ! img ) {
361+ return
362+ }
363+
364+ return h ( 'div' , {
365+ on : {
366+ click : ( ) => { this . goToSlide ( index ) }
367+ }
368+ } , [
369+ h ( 'img' , {
370+ attrs : { src : img } ,
371+ 'class' : { active : this . slide === index }
372+ } )
373+ ] )
374+ } )
375+
376+ const nodes = [
377+ h ( QBtn , {
378+ staticClass : 'q-carousel-thumbnail-btn absolute' ,
379+ props : {
380+ icon : this . computedThumbnailIcon ,
381+ fabMini : true ,
382+ flat : true ,
383+ color : this . color
384+ } ,
385+ on : {
386+ click : ( ) => {
387+ this . viewThumbnails = ! this . viewThumbnails
388+ }
389+ }
390+ } ) ,
391+ h ( 'div' , {
392+ staticClass : 'q-carousel-thumbnails scroll text-center absolute-bottom' ,
393+ 'class' : { active : this . viewThumbnails }
394+ } , slides )
395+ ]
396+
397+ if ( this . viewThumbnails ) {
398+ nodes . unshift (
399+ h ( 'div' , {
400+ staticClass : 'absolute-full' ,
401+ on : {
402+ click : ( ) => { this . viewThumbnails = false }
403+ }
404+ } )
405+ )
406+ }
407+
408+ return nodes
350409 }
351410 } ,
352411 render ( h ) {
@@ -397,6 +456,9 @@ export default {
397456 } ) : null ,
398457 this . __getQuickNav ( h ) ,
399458 this . __getScopedSlots ( h ) ,
459+ this . thumbnails . length
460+ ? this . __getThumbnails ( h )
461+ : null ,
400462 this . $slots . control
401463 ] )
402464 } ,
0 commit comments