list.js 1.06 KB
/**
 * PLUS+STAR列表页
 * @author: xuqi<qi.xu@yoho.cn>
 * @date: 2015/10/10
 */

var $ = require('jquery'),
    Hammer = require('yoho.hammer'),
    lazyLoad = require('yoho.lazyload'),
    Swiper = require('yoho.iswiper');

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

var mySwiper, navHammer;

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

mySwiper = new Swiper('.swiper-container', {
    lazyLoading: true,
    pagination: '.swiper-pagination'
});
$('#nav-tab').bind('contextmenu', function(e) {
    return false;
});
navHammer = new Hammer(document.getElementById('nav-tab'));
navHammer.on('tap pressup', 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');
});