Hi there,
I observe a strange behaviour in the paper-tabs ontap
listener: When I register listeners on a "paper-tabs" menu, changing the
tabs selection bar color, the color does not change on the first, but
only on the second click on a tab. This means that the color change on
the selection bar always lags exactly one click behind - so e.g. when I
click on Tab-1 first, and then on Tab-2, the color change of Tab-1 is
applied first and only after a second click on Tab-2, the correct Tab-2
specific color is applied.
For the menu itself I made a component like this which uses the {{selected}} variable to specify the currently selected tab:
<dom-module id="my-menu">
<template>
<paper-tabs id="my_menu" noink selected={{selected}}>
<paper-tab id="tab1">Tab-1</paper-tab>
<paper-tab id="tab2">Tab-2</paper-tab>
<paper-tab id="tab3">Tab-3</paper-tab>
</paper-tabs>
</template>
<script>
My_Menu = Polymer({
is: 'my-menu',
properties: {
selected: Number,
value: 0
},
listeners:{
'my_menu.tap': 'handleMenuTap'
},
handleMenuTap: function(e) {
console.info("HandleMenuTap happened");
console.info(this.selected);
if(this.selected == 0){
this.customStyle['--paper-tabs-selection-bar-color'] = 'red';
}
if(this.selected == 1){
this.customStyle['--paper-tabs-selection-bar-color'] = 'blue';
}
if(this.selected == 2){
this.customStyle['--paper-tabs-selection-bar-color'] = 'green';
}
this.updateStyles();
}
});
var my_menu = new My_Menu();
</script>
</dom-module>
In my index.html body, I call the menu like this:
<my-menu selected=0></my-menu>
I'm relatively new to Webcomponents and JavaScript in general. If you think that this is not the right approach at all, please also tell me. ;)
Thanks in advance!
Constantin