0

我正在使用flexslider 创建自定义滑块。当一个人单击项目符号导航部分时,我只想获取滑动编号。

我在 controlNavigation 部分尝试了各种方式

 controlNav: {
    setup: function() {
      if (!slider.manualControls) {
        methods.controlNav.setupPaging();
      } else { // MANUALCONTROLS:
        methods.controlNav.setupManual();
      }
    },
    setupPaging: function() {
      var type = (vars.controlNav === "thumbnails") ? 'control-thumbs' : 'control-paging',
          j = 1,
          item;

      slider.controlNavScaffold = $('<ol class="'+ namespace + 'control-nav ' + namespace + type + '"></ol>');

      if (slider.pagingCount > 1) {
        for (var i = 0; i < slider.pagingCount; i++) {
          item = (vars.controlNav === "thumbnails") ? '<img src="' + slider.slides.eq(i).attr("data-thumb") + '"/>' : '<a>' + j + '</a>';
          slider.controlNavScaffold.append('<li>' + item + '</li>');
          j++;
        }
      }

      // CONTROLSCONTAINER:
      (slider.controlsContainer) ? $(slider.controlsContainer).append(slider.controlNavScaffold) : slider.append(slider.controlNavScaffold);
      methods.controlNav.set();

      methods.controlNav.active();

      slider.controlNavScaffold.delegate('a, img', eventType, function(event) {
        event.preventDefault();
        var $this = $(this),
            target = slider.controlNav.index($this);

        if (!$this.hasClass(namespace + 'active')) {
          slider.direction = (target > slider.currentSlide) ? "next" : "prev";
          slider.flexAnimate(target, vars.pauseOnAction);
        }
      });
      // Prevent iOS click event bug
      if (touch) {
        slider.controlNavScaffold.delegate('a', "click touchstart", function(event) {
          event.preventDefault();
        });
      }
    },
    setupManual: function() {
      slider.controlNav = slider.manualControls;
      methods.controlNav.active();

      slider.controlNav.live(eventType, function(event) {
        event.preventDefault();
        var $this = $(this),
            target = slider.controlNav.index($this);

        if (!$this.hasClass(namespace + 'active')) {
          (target > slider.currentSlide) ? slider.direction = "next" : slider.direction = "prev";
          slider.flexAnimate(target, vars.pauseOnAction);
        }
      });
      // Prevent iOS click event bug
      if (touch) {
        slider.controlNav.live("click touchstart", function(event) {
          event.preventDefault();
        });
      }
    },
    set: function() {
      var selector = (vars.controlNav === "thumbnails") ? 'img' : 'a';
      slider.controlNav = $('.' + namespace + 'control-nav li ' + selector, (slider.controlsContainer) ? slider.controlsContainer : slider);
    },
    active: function() {
      slider.controlNav.removeClass(namespace + "active").eq(slider.animatingTo).addClass(namespace + "active");
    },
    update: function(action, pos) {

      if (slider.pagingCount > 1 && action === "add") {
        slider.controlNavScaffold.append($('<li><a>' + slider.count + '</a></li>'));
      } else if (slider.pagingCount === 1) {
        slider.controlNavScaffold.find('li').remove();
      } else {
        slider.controlNav.eq(pos).closest('li').remove();
      }
      methods.controlNav.set();
      (slider.pagingCount > 1 && slider.pagingCount !== slider.controlNav.length) ? slider.update(pos, action) : methods.controlNav.active();
    }
  },

但没有找到运气。如果有人知道如何实现这一点,请帮助我。提前致谢。

4

1 回答 1

1

我找到了解决方案。这对我来说真的很耗时......在活动功能中,我们可以获得下一个动画幻灯片编号,如下所示。(希望有一天这会对像我这样的人有所帮助)

active: function() { slider.controlNav.removeClass(namespace + "active").eq(slider.animatingTo).addClass(namespace + "active"); alert(slider.animatingTo) },

于 2013-03-18T10:41:49.640 回答