lixin-web
Version:
vue and bootstrap
33 lines (29 loc) • 805 B
JavaScript
var Question = function() {
var els = function() {
return $('.question');
}
var init = function() {
var links = els().find('.nav > .category > .list > a');
var items = els().find('.panel > .list > .item');
links.click(function() {
var thisItem = $($(this).attr('data-href'));
if(!thisItem.hasClass('active')) {
items.removeClass('active');
thisItem.addClass('active');
var top = thisItem.offset().top;
$('html,body').animate({scrollTop: top - 120}, 500);
}
});
items.click(function() {
if(!$(this).hasClass('active')) {
items.removeClass('active');
$(this).addClass('active');
var top = $(this).offset().top;
$('html,body').animate({scrollTop: top - 120}, 500);
}
});
}
return {
init: init
}
}();