2012-10-27 45 views
3

我有一個jQuery的內容切換器,顯示/隱藏divs時單擊適當的鏈接。每個Div內都是FlexSlider。第一個柔性滑塊工作得很好,但是當您單擊鏈接以顯示不同的Div時,柔性滑塊會混亂,它會一次顯示所有3個幻燈片。如果您離焦並重新調整瀏覽器窗口的焦點(單擊桌面以散焦窗口,然後單擊窗口中的焦點重新對焦),則柔性滑塊將正常工作。這是一個需要解釋的問題,最好是在行動中看到它。該網站是:http://www.benhenschel.comjQuery隱藏/顯示內容切換器中的多個FlexSliders。

「網絡」是第一個滑塊工作正常,但如果你點擊「移動」第二個Flex滑塊出現,你可以看到它一次顯示所有3張幻燈片。如果您離焦並重新調整瀏覽器窗口的焦點,則Flex滑塊將正確顯示。

下面是內容切換器和Flex滑塊

<!--Hide/Show--> 
    <script type="text/javascript" charset="utf-8"> 
     $(function(){ 

function contentSwitcher(settings){ 
    var settings = { 
     contentClass : '.workContent', 
     navigationId : '#navigation' 
    }; 

    //Hide all of the content except the first one on the nav 
    $(settings.contentClass).not(':first').hide(); 
    $(settings.navigationId).find('li:first').addClass('active'); 

    //onClick set the active state, 
    //hide the content panels and show the correct one 
    $(settings.navigationId).find('a').click(function(e){ 
     var contentToShow = $(this).attr('href'); 
     contentToShow = $(contentToShow); 

     //dissable normal link behaviour 
     e.preventDefault(); 

     //set the proper active class for active state css 
     $(settings.navigationId).find('li').removeClass('active'); 
     $(this).parent('li').addClass('active'); 

     //hide the old content and show the new 
     $(settings.contentClass).hide(); 
     contentToShow.show(); 

    }); 
} 
contentSwitcher(); 
}); 

    </script> 

    <!--Flex Slider--> 
    <script type="text/javascript" charset="utf-8"> 
    $(window).load(function() { 
    $('.flexslider').flexslider(); 
    }); 
    </script> 

這裏的代碼的HTML

   <!-- Web --> 
       <div id="webContainer" class="workContent flexslider"> 
        <h3>Web</h3> 
        <ul class="slides"> 
         <!-- Slide 1 --> 
         <li> 
          <div class="workImage"> 
           <img src="/images/work/urbanSurvivorWeb.jpg" alt="" /> 
          </div> 

          <div class="workDescription"> 
           <h4>Urban Survivor</h4> 
           <p> 
            The goal of this project, was to create a teaser page for a iPhone app called Urban Survivor. This simple one page site was designed to introduce the app, and generate interest. By providing a email sign up that interest can be measured. 
            <br /><br /> 
            <a href="http://www.urbansurvivorapp.com">Visit Site</a> 
           </p> 
          </div> 
         </li> 

         <!-- Slide 2 --> 
         <li> 
          <div class="workImage"> 
           <img src="/images/work/taykey.jpg" alt="" /> 
          </div> 

          <div class="workDescription"> 
           <h4>Taykey</h4> 
           <p> 
            I was tasked with redesigning Taykey's website, the goal was to better communicate what Taykey had to offer, and how Taykey works. Additionally, provide general information about the company, jobs available as well as contact information for the various offices. The redesign also aimed at brining a more concise visual brand across other Taykey marketing material.        
            <br /><br /> 
            <a href="http://www.taykey.com">Visit Site</a> 
           </p> 
          </div> 
         </li> 

         <!-- Slide 3 --> 
         <li> 
          <div class="workImage"> 
           <img src="/images/work/ireland.jpg" alt="" /> 
          </div> 

          <div class="workDescription"> 
           <h4>I'm Off To Ireland</h4> 
           <p> 
            This was a personal website I created so I could share my experiences while studying abroad in Waterford, Ireland.        
            <br /><br /> 
            <a href="http://www.imofftoireland.com">Visit Site</a> 
           </p> 
          </div> 

         </li> 

        </ul> 
       </div> 
       <!-- END Web --> 

       <!-- Mobile --> 
       <div id="mobileContainer" class="workContent flexslider"> 

        <h3>Mobile</h3> 
        <ul class="slides"> 

         <!-- Slide 1 --> 
         <li> 
          <div class="workImage"> 
           <img src="/images/work/urbanSurvivor/app.png" alt="" /> 
          </div> 

          <div class="workDescription"> 
           <h4>Urban Survivor iPhone App</h4> 
           <p> 
            Urban Survivor alerts the user when they have physically entered an area with a high crime rating. Additionally, the user will be able to check the threat level of their current physical location and see a broader view of their surroundings through the use of a heat map. Both the threat meter and the heat map use a simple, color-coded visual cue (green = low, yellow = neutral, red = high). Finally, there is a panic button dials 911 when pressed.         
           </p> 
          </div> 
         </li> 

         <!-- Slide 2 --> 
         <li> 
          <div class="workImage"> 
           <img src="/images/work/urbanSurvivor/wireframe.jpg" alt="" /> 
          </div> 

          <div class="workDescription"> 
           <h4>Urban Survivor App: Wireframe</h4> 
           <p> 
            A major requirement for this app was a super simple navigation. After several iterations we landed on having two buttons in the top left and right hand corner of the screen that, when taped, would swipe left/right reveling the content of the new screen. As an alternate to this navigation, the user would swipe left or right with their fingers to also revel the content.         
           </p> 
          </div> 
         </li> 

         <!-- Slide 3 --> 
         <li> 
          <div class="workImage"> 
           <img src="/images/work/urbanSurvivor/workflow.jpg" alt="" /> 
          </div> 

          <div class="workDescription"> 
           <h4>Urban Survivor App: User Workflow</h4> 
           <p> 
            This flowchart shows the entire user workflow, and how the user could interact with the app.         
           </p> 
          </div> 
         </li> 
        </ul> 

       </div> 
       <!-- END Mobile --> 

我真的不知道很多關於jQuery的,所以任何幫助會不勝感激。

回答

2

那麼,在嘗試了不同的標籤系統和自制的jQuery解決方案之後,我用另一種非常簡單的方式解決了同樣的問題!

你只需要創建第一個幻燈片,5幻燈片,並在每張幻燈片放另一個flexslider。將controlNav設置爲true,並使用導航html結構設置manualControls。

這裏是我的設置:

//first slideshow 
    $('.flexslider_cont').flexslider({ 
    animation: "slide", 
    slideshow: 0, 
    useCSS: true, 
    controlNav: true, 
    selector: ".slides_l1 > .slide_l1", 
    manualControls: "#navorizzontale li", //navigation structure 
    directionNav: false, 

    });  

     $('.flexslider2a').flexslider({ 
      animation: "slide", 
      slideshow: 0, 
      useCSS: true, 
      controlNav: false, 
      directionNav: true, 
     }); 

     $('.flexslider2b').flexslider({ 
      animation: "slide", 
      slideshow: 0, 
      useCSS: true, 
      controlNav: false, 
      directionNav: true 
     }); 

     $('.flexslider2c').flexslider({ 
      animation: "slide", 
      slideshow: 0, 
      useCSS: true, 
      controlNav: false, 
      directionNav: true 
     }); 

     $('.flexslider2d').flexslider({ 
      animation: "slide", 
      slideshow: 0, 
      useCSS: true, 
      controlNav: false, 
      directionNav: true 
     });