|
本帖最后由 永恒淘榜 于 2018-6-26 15:49 编辑
没事写了个分类顶部导航,点击到奶瓶后,不能自动滚动,可以左右拖动。
- function changeClass(index) {
- var tabs = $api.domAll('#tab .tabItem');
- for (var i = 0; i < tabs.length; i++) {
- if (i === index) {
- $api.addCls(tabs[i], 'active')
- } else {
- $api.removeCls(tabs[i], 'active')
- }
- }
- }
- function moveNav(index) {
- var noDiy = [];
- for (var i = 0; i < topNavMenu.length; i++) {
- if (topNavMenu[i].isdiy == 0) {
- noDiy.push(topNavMenu[i]);
- }
- }
- if (index >= 6 && index < noDiy.length - 2) {
- $api.dom('#moveBox').style.marginLeft = (-(index - 2) * 100) + 'px'
- }
- if (index < 6) {
- $api.dom('#moveBox').style.marginLeft = 0;
- }
- }
- function tab(index) {
- changeClass(index);
- moveNav(index);
- api.setFrameGroupIndex({
- name: 'group',
- index: index,
- reload: false,
- scroll: true
- });
- }
复制代码
|
|