MediaWiki:Common.js
Nota: Após publicar, você pode ter que limpar o "cache" do seu navegador para ver as alterações.
- Firefox / Safari: Pressione Shift enquanto clica Recarregar, ou pressione Ctrl-F5 ou Ctrl-R (⌘-R no Mac)
- Google Chrome: Pressione Ctrl-Shift-R (⌘-Shift-R no Mac)
- Edge: Pressione Ctrl enquanto clica Recarregar, ou pressione Ctrl-F5.
- Opera: Pressione Ctrl-F5.
mw.loader.using('jquery', function () {
const $carousel = $('.carousel-wrapper');
const $items = $('.carousel-item');
let index = 0;
function update() {
const itemWidth = $items.outerWidth(true);
$carousel.scrollLeft(index * itemWidth);
$items.removeClass('active');
$items.eq(index).addClass('active');
}
$('.right-btn').on('click', function () {
index = (index + 1) % $items.length;
update();
});
$('.left-btn').on('click', function () {
index = (index - 1 + $items.length) % $items.length;
update();
});
setInterval(function () {
index = (index + 1) % $items.length;
update();
}, 4000);
update();
});