@@ -236,6 +236,13 @@ export default class SampleControl {
236236 label . textContent = "Variants: " ;
237237 this . _sampleControls . appendChild ( label ) ;
238238
239+ this . _previousVariantButton = document . createElement ( 'button' ) ;
240+ this . _previousVariantButton . className = 'openmapsamples-variant-increment' ;
241+ this . _previousVariantButton . id = 'openmapsamples-variant-previous' ;
242+ this . _previousVariantButton . textContent = '◀︎' ;
243+ this . _previousVariantButton . onclick = this . decrementVariant . bind ( this , sample ) ;
244+ this . _sampleControls . appendChild ( this . _previousVariantButton ) ;
245+
239246 this . _variantSelect = document . createElement ( 'select' ) ;
240247 this . _variantSelect . className = 'openmapsamples-variant-select' ;
241248 this . _variantSelect . id = 'openmapsamples-variant-select' ;
@@ -253,6 +260,12 @@ export default class SampleControl {
253260 this . _variantSelect . value = this . variant ;
254261 this . _variantSelect . onchange = this . changeVariant . bind ( this , sample ) ;
255262
263+ this . _nextVariantButton = document . createElement ( 'button' ) ;
264+ this . _nextVariantButton . className = 'openmapsamples-variant-increment' ;
265+ this . _nextVariantButton . id = 'openmapsamples-variant-next' ;
266+ this . _nextVariantButton . textContent = '►' ;
267+ this . _nextVariantButton . onclick = this . incrementVariant . bind ( this , sample ) ;
268+ this . _sampleControls . appendChild ( this . _nextVariantButton ) ;
256269
257270 // Save default source data and replace with sample data.
258271 this . restoreOriginalStyle ( ) ;
@@ -365,4 +378,18 @@ export default class SampleControl {
365378 }
366379 }
367380
381+ decrementVariant ( sample ) {
382+ if ( this . _variantSelect . selectedIndex > 0 ) {
383+ this . _variantSelect . selectedIndex = this . _variantSelect . selectedIndex - 1 ;
384+ this . changeVariant ( sample ) ;
385+ }
386+ }
387+
388+ incrementVariant ( sample ) {
389+ if ( this . _variantSelect . selectedIndex < this . _variantSelect . options . length ) {
390+ this . _variantSelect . selectedIndex = this . _variantSelect . selectedIndex + 1 ;
391+ this . changeVariant ( sample ) ;
392+ }
393+ }
394+
368395}
0 commit comments