Po pierwsze to mi się nie podoba:
document.addEventListener("DOMContentLoaded", function(event) {
PapaSlide.setLibrary({
/*
* string: elementClass for the container element; default: 'papa-container'
*/
'container': 'papa-container',
/*
* string: elementClass for the items element; default: 'papa-item'
*/
'items': 'papa-item',
/*
* string: transition-duration css property in miliseconds; default: '300'
*/
'transitionDuration': '300',
/*
* string: transition-timing-function css property; default: 'ease-in'
*/
'transitionFunction': 'ease-in',
/*
* string: interval between each element, in milliseconds; default: 3000
*/
'timeInterval': '3000',
/*
* string: animation type ( more in table ); default: 'fade'
*/
'animationType': 'fade',
/*
* string: switching slides ( more in table ); default: 'auto'
*/
'type': 'auto',
/*
* number: first index element; default: 0
*/
'startAt': 0,
});
})
Niesądzisz, że trochę za dużo argumentów?
Po drugie, co jeżeli chce więcej elementów animowanych? Do każdej mam pisać to?
Lepiej ustawić set do obiektu, najwyżej tam sprawdzać instanceof. Po drugie, czy nie sądzisz, że niektóre z nich mogą być domyślne.
.your-container-className {
position: relative;
}
.your-items-className {
position: absolute;
top: 0;
right: 0;
top: 0;
bottom: 0;
opacity: 0;
}
Pamiętaj, że akrusz CSS też możesz przypiąć do klienta po przez JS. Tylko trzeba założyć jakiś boilerplate. Ale to tak zostawiam jako ciekawostkę.
Za to w kodzie masz o wiele przyjemniejszą implementację:
fadeAuto.setPapaSlider({container: 'fade-auto', timeInterval: '1000'});
Brak obsługi wyjątków.
Nie wiem kto ci kazał tak pisać.-> _nazwaMetody ale nieprzyjemnie się to czyta.