plustar-list.page.js 1.07 KB
var $ = require('yoho-jquery'),
    lazyLoad = require('yoho-jquery-lazyload'),
    Swiper = require('yoho-swiper');

var $navs = $('#nav-tab > li'),
    $contents = $('#ps-content > .content');

var mySwiper;

require('../common');

lazyLoad($('img.lazy'));

$('.star-content li').each(function(key, item) {
    $(item).find('.swiper-container').addClass('swiper-' + key);

    mySwiper = new Swiper('.swiper-' + key, {
        lazyLoading: true,
        pagination: '.swiper-' + key + ' .pagination-inner'
    });
});

$('#nav-tab').bind('contextmenu', function(e) {
    return false;
});
$('#nav-tab').on('touchend touchcancel', function(e) {
    var $this = $(e.target).closest('li');

    if ($this.hasClass('focus')) {
        return;
    }

    $navs.toggleClass('focus');
    $contents.toggleClass('hide');

    $(document).trigger('scroll'); //Trigger lazyLoad
});
$('#nav-tab').on('touchstart', function(e) {
    var target = e.target || e.srcElement;

    target.className = 'bytouch ' + target.className;
}).on('touchend touchcancel', function() {
    $navs.removeClass('bytouch');
});