anythingSlider starts on the last slide in IE

ukwebguy
ukwebguy used Ask the Experts™
on
I've added the CSS-Tricks anythingSlider to a page - it works correctly in Firefox and Chrome but in IE8, it starts on the last element instead of the first. This is a known bug apparently - Googling got me this...
---
When AnythingSlider is initialized on a hidden element, the last slide will show instead of the first. This is because a scrollLeft value cannot be applied to a hidden element. So either initialize it with visibility hidden, or if that isn't possible, then set the scrollLeft when it becomes visible:

    var s = $('#slider1').data('AnythingSlider');
    s.$window.scrollLeft( s.$window.width() + s.easingMargin ); // may not work if resizeContents is false (width will vary)

Can anyone explain how I implement this in my page, please? (not being a JavaScript/JQuery guru). I have a sample page here... http://www.cobwebbery.co.uk/anything/page.html which demonstrates the problem. I've obviously not done it correctly because I get an error '$window is null or not an object'

I've selected 250 points not because it looks like a huge problem but simply because I've got a client who needs this on Monday morning. BTW as you'll see from the site, the order of the slide is very important, so they must display in the correct order.

Many thanks



Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
It works fine on my IE8, but you have some problems with IE7.

Author

Commented:
OK -my IE8 may be compatibility mode - there is still a problem with IE7 - yes?

Commented:
Yes
 view IE7
Success in ‘20 With a Profitable Pricing Strategy

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Commented:
To resolve issue with IE7
Please add the following changes:
 
.art-blockheader .r
{
  width: 20px; //smaller value HERE
  right: 0;
  clip: rect(auto, auto, auto, 980px);
  background-position: right; //shifts background to right side
}

Open in new window

Author

Commented:
I'm sorry for the delay in replying as I had to go out. I've made the changes and the block headers are now displaying correctly in IE7 - however - the slider is still starting on the last element rather than the first.
Commented:
Have you updated your slider? -If, Yes. Have you updated markup? -If, yes.
Why do you need this:
<li style="width: 516px; height: 280px;" class="cloned panel">
                                                        <div style="width: 100%; height: 100%;">
                                                            This is the content for the sixth slider panel - I'm using HTML in this case but we could just use an image<br>
                                                            Click here if you like this!
                                                        </div>
                                                        </li>

Open in new window

So called last slide is the first one in unordered list.

Try to updated your markup as well and remove any unneeded tags.

Author

Commented:
I have updated the slider - the markup (class="cloned panel") is not present in my markup - it appears to be added by the JavaScript in anythingSlider.js

How do I make the last last slide LOOK LIKE the last slide to IE - it keeps displaying it as the first one.

If you read my question carefully, this appears to be a known issue - I think this might be a JS question ie how to incorporate the JS snippet I've quoted in my question OR how to ensure that the first element is visible.

Author

Commented:
Thank you for your very quick assistance.
Top Expert 2015
Commented:
Have you tried the simpler solution (option 2) from this site https://github.com/ProLoser/AnythingSlider/wiki/FAQ which suggests adding a line to set the first slide specifically by index to overcome the IE bug?          
        <script>
            // DOM Ready
            $(function(){
                      $('#slider').anythingSlider(1);
                      $('#slider').anythingSlider({
                      ....
                      ....

                     

Author

Commented:
Sorry for the delayin answering, but I eventually had to go to bed for a couple of hours.

I hadn't tried it, but I have now and that doesn't work either. I think I need to look at other sliders - they can't all be beaten by IE...

Author

Commented:
I didn't really get a solution, but the discussion helped to clarify my thought process - always useful in the 'wee small hours'.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial