I try to convert from html buttons to screen&element UI
the index is changing but the cars are not switching
initialize() {
let index = 0;
const self = this;
const onBtnLeft = function(){
--index;
console.log('left', index);
self.toggleCar(index);
};
const onBtnRight = function(){
++index;
console.log('right', index);
self.toggleCar(index);
};
this.btnLeft.element.on('click', onBtnLeft);
this.btnRight.element.on('click', onBtnRight);
}
toggleCar(index){
const showroom = this.entity.script.showroom;
showroom.hideAll();
const lastIndex = showroom.cars.length - 1;
const indexExceedsArray = index < 0 || index > lastIndex;
if(indexExceedsArray){
return;
}
showroom.showOne(index);
}