scripts
JavaScript and CSS tips, tutorials
and resources for the mobile web

iosSlider – jQuery Horizontal Slider for iPhone/iPad Safari (Beta)

iPad
iPhone
JavaScript
jQuery
Mobile Safari
Plugin
Version: 0.9.4 (beta)   05/16/12

iosSlider is a jQuery plugin which turns any wide element into a touch enabled horizontal slider.

Awesome photography provided by Aaron Forster

Touch Me.
Hardware accelerated using
CSS3 for supported iOS,
Android and WebKit
Responsive.
Respond to change in browser
width and adjust automatically
Flexible.
Run multiple sliders on
the same web page
Customize.
Set momentum, elasticity,
scrollbars and more...
Touch Me | Hardware accelerated using CSS3 for supported iOS, Android and WebKit
Responsive | Respond to change in browser width and adjust automatically
Flexible | Run multiple sliders on the same web page
Customize | Set momentum, elasticity, scrollbars and more...
Touch Me.
Hardware accelerated using CSS3 for supported iOS, Android and WebKit
Read More ›
Respond.
Responsive to change in browser width and adjust automatically
Read More ›
Flexible.
Run multiple sliders on the same web page
Read More ›
Custom.
Set momentum, elasticity, scrollbars and more...
Read More ›
Rotating Banner
Photo Gallery
Embedded HTML
Default

Features

Hardware accelerated
using CSS3 for supported iOS, Android and WebKit browsers.
Responsive support
to work with the most dynamic desktop and mobile sites.
Tons of API callbacks
to get the perfect slider feel for your web application.
FF/Safari/Chrome/IE7+
Full modern browser support for desktop.
Infinitely looping
Loop through your slides endlessly in both directions.
Auto-sliding
Set your slider to automatically transition and pause on hover.

Browser Support Details

Full Support
Partial Support
Firefox Safari Chrome Internet Explorer iOS Safari Android
5.0+ 5.0+ 19.0+ 7+ 4.0+ 2.3+

iosSlider may work in earlier versions of browsers listed above, but are not included in testing at this time.

Tutorial

Getting Ready

To get started, you will need to download the iosSlider script. Click here to download the latest version. This download contains the iosSlider script, the jQuery library, and source files for the examples shown above.

Include the Necessary JavaScript Files

The jQuery library and iosSlider Plugin scripts must be included in the HTML header of the web page. The jQuery library must be included first for the iosSlider plugin to function.

<!-- jQuery library -->
<script type = 'text/javascript' src = '/iosSlider/jquery-1.7.min.js'></script>

<!-- iosSlider plugin -->
<script type = 'text/javascript' src = '/iosSlider/jquery.iosslider.js'></script>

Add the HTML

Add the iosSlider HTML code within the body of the web page. The HTML can contain as little as one slide element, but if you want to leverage the snapToChildren setting, you will need to use multiple slides.

<!-- slider container -->
<div class = 'iosSlider'>

	<!-- slider -->
	<div class = 'slider'>
	
		<!-- slides -->
		<div class = 'slide'>...</div>
		<div class = 'slide'>...</div>
		<div class = 'slide'>...</div>
		
	</div>
	
</div>

Add the CSS

Place the CSS in your stylesheet. The required CSS attributes are included to guarantee optimal performance. Feel free to apply as many other CSS attributes as you want. To see some real-world examples of this, check the demos folder of the iosSlider download.

/* slider container */
.iosSlider {
	/* required */
	position: relative;
	top: 0;
	left: 0;
	overflow: hidden;

	/* optional */
	width: 630px;
	height: 214px;
}

/* slider */
.iosSlider .slider {
	/* required */
	width: 100%;
	height: 100%;
}

/* slide */
.iosSlider .slider .slide {
	/* required */
	float: left;

	/* optional */
	width: 630px;
	height: 214px;
}

Add the JavaScript

Add the code below to your JavaScript file. The following code uses the jQuery selector to fire the iosSlider jQuery plugin. If you are unfamiliar with jQuery, here is a tutorial to get you started.

$(document).ready(function() {

	/* basic - default settings */
	$('.iosSlider').iosSlider();

	/* some custom settings */
	$('.iosSlider').iosSlider({
		snapToChildren: true,
		scrollbar: true,
		scrollbarHide: false,
		desktopClickDrag: true,
		scrollbarLocation: 'bottom',
		scrollbarHeight: '6px',
		scrollbarBackground: 'url(_img/some-img.png) repeat 0 0',
		scrollbarBorder: '1px solid #000',
		scrollbarMargin: '0 30px 16px 30px',
		scrollbarOpacity: '0.75',
		onSlideChange: changeSlideIdentifier
	});

});

Settings & Options

You can pass along any of the following key/value pairs listed below to the iosSlider() function or modify them at the bottom of the the iosSlider() JavaScript file directly.

Key Value Description
elasticPullResistance 0.6 (decimal, 0.0 - 1.0) The elastic resistance when pulling on the slider edge.
frictionCoefficient 0.92 (decimal, 0.0 - 1.0) The friction coefficient applied to the momentum on touch release affecting the rate of deceleration.
elasticFrictionCoefficient 0.8 (decimal, 0.0 - 1.0) Additonal friction coefficient applied when momentum slides outside the bounds of the slider.
snapFrictionCoefficient 0.92 (decimal, 0.0 - 1.0) Friction applied to the slider when snapping to an element.
snapToChildren false (boolean) Slider will slide to the closest child element on touch release.
startAtSlide 1 (integer) Current slide when slider is initially loaded.
scrollbar false (boolean) Show or hide the scrollbar.
scrollbarHide true (boolean) Show or hide the scrollbar when it is idle.
scrollbarLocation 'top' (string, 'bottom' or 'top') Location that the scrollbar will appear.
scrollbarOpacity 0.4 (decimal) The css opacity of the scrollbar when visible.
scrollbarHeight '4px' (string) The css height in 'px' of the scrollbar.
scrollbarBorder 'none' (string) The css border of the scrollbar.
scrollbarMargin '5px' (string) The css margin of the scrollbar.
scrollbarBackground 'none' (string) The css background of the scrollbar.
scrollbarBorderRadius '100px' (string) The css border-radius of the scrollbar.
scrollbarShadow 'none' (string) The css box-shadow of the scrollbar.
desktopClickDrag false (boolean) Desktop click and drag fallback for the desktop slider.
responsiveSlideWidth true (boolean) Width of slides becomes responsive to the width of its parent element. Slides dynamically collapse to the width/height of the parent element when wider/taller.
navSlideSelector null (string) A jQuery selection (ex. $('.navButtons .button') ), each element returned by the selector will activate navigation to each slide respectively. ie. element 0 when clicked (or touched) will animate to the first slide and so on.
navPrevSelector null (string) A jQuery selection (ex. $('#previousSlide') ), the element returned by the selector will navigate to the previous slide when clicked.
navNextSelector null (string) A jQuery selection (ex. $('#nextSlide') ), the element returned by the selector will navigate to the next slide when clicked.
autoSlide false (boolean) Enables automatic cycling through slides.
autoSlideTimer 5000 (integer) the time (in milliseconds) that a slide will wait before automatically navigating to the next slide.
autoSlideTransTimer 750 (integer) the time (in milliseconds) required for all automatic animations to move between slides. See navSlideSelector, navPrevSelector, navNextSelector for details on activating elements for automatic sliding.
autoSlideToggleSelector null (string) A jQuery selection (ex. $('#autoScrollToggle') ), the element returned by the selector will disable/enable automatic scrolling when clicked. Note: Only works when autoSlide is set to 'true'.
infiniteSlider false (boolean) Makes the slider loop in both directions infinitely with no end. When set to true, the option scrollbar is automatically disabled.
onSliderLoaded null (function) Executed when slider has finished loading initially.
Returned parameter: 'args' (array) { settings, sliderObject, currentSlideObject, currentSlideNumber }
onSlideChange null (function) Executed when the slider has entered the range of a new slide.
Returned parameter: 'args' (array) { settings, sliderObject, currentSlideObject, currentSlideNumber }
onSlideComplete null (function) Executed when the slider has come to a stop on a new slide.
Returned parameter: 'args' (array) { settings, sliderObject, currentSlideObject, currentSlideNumber }

Public Methods

Method Description
$('div').iosSlider('destroy'); Destroys the selected slider.
Optional parameter: 'clearStyle' (boolean, default: true) when iosSlider is destroyed, all inline style applied to the slider will be removed.
$('div').iosSlider('goToSlide', slideNum); Moves to the selected slide.
Required parameter: 'slideNumber' (integer, default: null)

License

You may use iosSlider (beta) freely, without restriction in any material intended for sale or distribution. Attribution is not required but always appreciated. You are not permitted to make the resources found on iosscripts.com available for distribution elsewhere "as is" without prior consent.

If you would like to feature iosSlider (beta) on your site, please do not link directly to the resource zip files. Please link to the appropriate page on iosscripts.com where users can find the download.

Support

Need help with your implementation? Feel free to drop me a line below and I will get back to you as quickly as I can.

If you run into problems implementing iosSlider and need to report a bug or request a new feature, please create an issue on GitHub issues and I will investigate.

Additional demos, readme, and changelog can be found in the iosSlider repository on GitHub

265 Comments
  • Mr V says:
    Your comment is awaiting moderation.

    Hi Marcus,

    Well done and thank you for sharing your amazing script. Just wondering whether it is possible to achieve this with iosSlider to have a vertical scroll.

    Let’s say I have 5 images in total. My container is set to 900 x 300 pixels.

    1st image = 900 x 300 pixels.
    2nd image = 900 x 600 pixels.
    3rd image = 900 x 600 pixels.
    4th image = 900 x 300 pixels.
    5th image = 900 x 300 pixels.

    Is there a way for me to scroll up on the 2nd and 3rd slides to see the rest of the images?

    Your help will be greatly appreciated.

    Many thanks in advance.

    Kind regards,
    Mr V

  • jenn says:
    Your comment is awaiting moderation.

    Hello! Thank you for this amazing script. I am wondering if it’s possible to integrate a draggable scroll bar to move the images? This would serve desktop users who aren’t savvy enough to know the images can be be dragged to navigate. Thanks much!

  • Mahesh says:

    Hi Marcus,

    Thanks for this valuable plugin. I would like to know the direction in which I have swiped ie; to detect whether I have swiped backward or forward.

    Looking forward to get your reply soon.

    • marcus says:

      It’s not built in at the moment. You could use the onSlideComplete callback to store the slide number when fired and then compare that to the new slide number when fired again, thus giving you the direction.

  • Zai says:

    Just downloaded the brilliant plugin and it works perfectly fine on both PC and Android devices. The only problem I’m facing now is that I wasn’t able to zoom into the page or image using Safari browser on the new iPad (iPad 3). The webpage and image look freeze. Could you please advise if anything I can fix up?

    Thanks!

  • Flo says:

    Dear Marcus,

    I’m using your slider (v0.9.3.1) and the content of my slide are responsive.
    When I change my iPad orientation or resize my browser (mediaqueires are “triggered”),I jump to the next slide.

    Also I’m using fullscreen slides and I was wondering how I could change iosslider’s height to adapt to the current slide’s height each time the onSlideChange function is triggered.

    Thank you so much for the great plugin !

    Flo

    • marcus says:

      When I change my iPad orientation or resize my browser (mediaqueires are “triggered”),I jump to the next slide. Are you using media queries to change the size of the slider/slides? Please let me know what you are manipulating with the media query.

      Also I’m using fullscreen slides and I was wondering how I could change iosslider’s height to adapt to the current slide’s height each time the onSlideChange function is triggered. You could use $(args.currentSlideObject).height() to get the height and apply it to $(args.sliderObject).parent(). I’m not sure how weird this would look though, you might want to animate the transition.

      • Flo says:

        Dear Marcus,

        It seems that v 0.9.4 fixed the issue :) Thank you very much !!!!

      • Flo says:

        Hi Marcus,

        I’m using mediaqueries on the content within the slides. My structure looks like this :

        Content



        iosslider, slider and slides have a width of 100%
        I use mediaqueries on section, changing them from a width of 960px to auto; when the browser width is inferior to 960px.

        Thanks for the suggestion on adding transition, I’ll try it and let you know.

        • Flo says:

          oups the comment system got rid of the html code I sent, my strucutre is like this :

          div .main
          div .ioslider
          div .slider
          div .slides
          section .content <- thos are using mediaqueries
          /div
          /div
          /div
          /div

          • Flo says:

            In the meantime, I tried your suggestion on resizing the height onslideChange, it works very well on desktop when I change slide triggered by $(‘div’).iosSlider(‘goToSlide’, slideNum); . However on iPad, it seems that the onSlideChange and onSlideComplete aren’t triggered when swiping.

  • Mahesh says:

    I have come across a situation in which the sliding items have an input form and it fails. The input form cant be filled in Chrome, swiping still works. In FF and IE it doesn’t make any problem. Any idea?

  • Daniel says:

    Hi Marcus,
    Thanks a lot for develop it. It is just what I was looking for.
    I want to ask you something. You think I can use ios slider putting all the divs of the slide with 100% with and height for realize the effect that this guy uses on his website? http://caseybritt.com/

    Thank you.

    • marcus says:

      You should be able to get the responsive full page width effect by setting the iosSlider container div to be 100% width and slides to be 100% width. As for the keyboard integration that isn’t possible with this script, but I will add it as a possible new feature to be added later.

  • Edmund Tee says:

    Hi,

    great slider. Thanks for the fantastic script.

    I had integrated into my web project, but when I viewed the slider in IE7+, the content of the is shrink, when I view in PC –> Chrome, Safari, Firefox, Opera, Phone –> Android, Iphone, Ipad is working great, The content is fit but why IE cannot fit, it shrink. may I know how to fix this in IE?

    link : http://itech-gd.info/en/simon

    I put it at [WALLPAPER STYLE] + [FURNITURE]

    Thanks,

    • marcus says:

      IE8/9 look like they are working. I see your issue in IE7.

      I have seen issues arise when iosSlider is initialized while hidden. The first thing I would try is specifying a width to the parent of the slider class: “leftPanelList_msTitle_3_msContent_3″ or try initializing iosSlider after the content is opened.

      • Edmund Tee says:

        Thanks a lot…I had specific the width for the parent of the slider class, It’s work like a charm… actually IE8+ caused this problem not IE7+, sorry about giving wrong info…anyway thanks for your help and keep-up the good work

  • nadav says:

    hey , great slider .

    i have one issue with resize slider on orientation with android .

    what i am doing wrong ?

    http://www.2scan.info/nadav/new-mobile-desgin/index-new.html

    thanks

  • Jørgen Hvamb Sveli says:

    Hey! The library looks and feels great. I’m wondering If you could fix this in line 749:

    //from this:
    $(this).css({
    float: ‘left’
    });

    //to this:
    $(this).css({
    ‘float’: ‘left’
    });

    It seems to break yui compressor, since float is a reserved, though unused, keyword in js.

    cheers

  • thangaraj says:

    hi,
    marcus good work , is there any possibility to prevent horizontal slide while scrolling content vertical.because while i scroll inside content vertically it automatically moving to next or previous slide vise versa.

    • marcus says:

      I’m not sure I understand what the issue is. The slider shouldn’t be automatically moving to the next/previous slide on its own unless you have it set to autoslide.

      • thangaraj says:

        thank you for reply, i’m not set autoslide true , it will happen only i scrolling faster up and down.

  • Bram says:

    Hi currently i’m working width 0.9.2.1 all seems to work width the image gallery and thumbs however using $(‘.iosSlider’).iosSlider(‘goToSlide’, 2); activates thumb button 2 but not slide 2 it remains on slide 1 .
    running on windows Chrome.

    Thx for any suggestion

    • Bram says:

      Ps this is only in fancybox popup in THE main window thuis is working properly

      • marcus says:

        How are you using fancyBox? iFrame or page embed?

        • Bram says:

          Hi Marcus i am using fancybox inline however in iframe the same problem exists, even in twitter Bootstrap modal.

          • marcus says:

            When are you calling $(‘div’).iosSlider()? There are known issues when initializing the slider while it is contained within an element with { display: none }. Make sure you are initializing after the fancyBox is loaded.

            • Bram says:

              well Marcus you’re right for you to be complete maybe a faq
              // set click funtion on your images
              $(“a.swipeImages”).click(function(){
              // populate the hidden div for fancybox with object this
              $(“#imagesPopup”).data(‘context’,$(this));
              // get the slidenumber from the images
              var slideNumber=($(‘#imagesPopup’).data(‘context’).attr(‘data-slider-id’));

              // use href attribute for fancybox and the slidenumber to execute the goToSlide function
              $.fancybox({
              href : “#imagesPopup”,
              beforeShow : function () {
              $(‘.iosSlider’).iosSlider(‘goToSlide’,slideNumber);
              }
              });
              });

  • fawzi says:

    hi Marcus, i think i found a minor issue with the returned values from onSlideComplete.
    If it is triggered by me physically sliding the images using my track pad, the id of slider object is in sliderObject[id]. However, if i do it dynamically using $(‘mydiv’) iosSlider(“goToSlide”, sNum); then the id is sliderObject[0].id…. i have a work around now, but thought you may want to know about it… thanks again

  • fawzi says:

    Hi Marcus,
    it seems that the onSlideComplete event is triggered when iosSlider is first created. is this the intended behavior? if so, can’t be disabled so as it only fires when the slide have actually stopped moving?
    in my implementation i destroy and recreate the slide multiple times and i do use the onSlideComplete for something else as well, so currently i cannot tell when the slides have stopped moving from i just recreated an iosSlider.

    any suggestions, or is there a chance to modify your code to reflect what is actually happening…

    • marcus says:

      In the mean time you could remove line 990 from the script. That will disable the onSlideComplete being triggered from the initialization process. The only effect removing this will have is onSlideComplete will not be triggered onorientationchange and onresize. I’m not sure if this affects your implementation but that’s a short term solution until I decide what I would like to do with the onSlideComplete function.

      • fawzi says:

        - that should work for my implementation… i’ll give t a shot… thanks…
        - my 2 cents, is to have 2 events, one for iosSlider “ready” and another for onSlideComplete.

        • fawzi says:

          your suggestion did the job… many thanks….

          • fawzi says:

            hi Marcus,
            do i still need to comment out line 990 (or its new line number) in revision 0.9.4, or has it been fixed?

            Also, for the iosSlideComplete issue that i reported earlier… is that also taken care of in 0.9.4? it seems that it is, but wanted to make sure.

  • Billy says:

    Hi, loving the script!

    Having some issues though setting up multiple slider on a single page. Is there a simple solution for this? I’m trying to set multiple classes for the slider but it doesnt seem to work(noob issues here)

    Thanks!

    • marcus says:

      Hey can you give me some more information? What does your $(‘div’).iosSlider(); call(s) look like?

      • Billy says:

        $(‘.iosSlider’).iosSlider({
        scrollbar: true,
        snapToChildren: true,
        desktopClickDrag: true,
        scrollbarLocation: ‘top’,
        scrollbarMargin: ’10px 10px 0 10px’,
        scrollbarBorderRadius: ’0′,
        responsiveSlideWidth: true,
        navSlideSelector: $(‘.iosSliderButtons .button’),
        infiniteSlider: true,
        startAtSlide: ’2′,
        onSlideChange: slideContentChange,
        onSlideComplete: slideContentComplete,
        onSliderLoaded: slideContentLoaded
        });

        When i add more classes to $(‘.iosSlider’) ($(‘.iosSlider’ ‘.iosSlider2′ etc) the slider breaks and no images are shown. I don’t think its in the css since i added the new classes to the same previous css markup( all sliders are consistent through out the site)

        Any clue what i might be doing wrong?

        • marcus says:

          Did your jQuery selector look like $(‘.iosSlider1, .iosSlider2′).iosSlider()? If not, you’re using jQuery selectors wrong. Alternatively, you can just do:
          $(‘.iosSlider1′).iosSlider();
          $(‘.iosSlider2′).iosSlider();

  • Math says:

    Hey,
    I have another question I cannot seems to find on google…
    How can I lock the vertical slide/scroll when I scroll/slide the iosslider horizontaly on mobile?
    I figured I have to add an “ontouch even” on my iosSlider class which will disable the vertical scrolling by returning false.
    How could I do that?

    • marcus says:

      Which touch device are you using? Once you start scrolling on the slider horizontally, it should disable vertically.

      Do some research on e.preventDefault(); for more info on disabling default scrolling/behavior.

      • Math says:

        It’s weird. I tested with an android and it already works but not on an iphone/ipod.
        Any idea?

        • marcus says:

          Once you start scrolling horizontally, the slider is supposed to lock vertical page scrolling. It seems to be working on my iPad… Are you able to reproduce the issue with the demos on this page?

      • Math says:

        Im using iphone/Ipad for the moment. I haven’t test for android yet.
        Is it normal?
        Anyway thanks, I’ll try to find something with e.preventDefault();

  • Pete Holberton says:

    Hi Marcus,

    Thanks for the plugin – it looks very interesting. A minor thing, but the 4-Embedded-HTML example seems broken. I think it’s to do with the “float:left;” on “.iosSlider” – one of the height calculations returns 0 and the element gets hidden. It worked for me when I removed the float.

    Cheers,

    Pete

  • Math says:

    Hey Marcus! Thanks for this very nice jquery! Unfortunately, I have a little problem I have been working on too much.
    My slider has infiniteDrag, no snaptochildren, no desktopclickdrag because it is only for a mobile version.
    Everything works well but I cannot slide my first element.
    The slider is for my navigation menu and all buttons are inside “li” -> “a” -> “div” -> img and a “p” under the image. ( looks like this : )
    For the first element (only on mobile), I cannot slide my button normally. I have to slide it through the “p”. Normally I slide the navigation buttons with the “img” except for the first 1 and the last 1.
    What could be the problem?

    • marcus says:

      In the current version, there are issues with anchor links breaking the slider. And I believe I have seen exactly what you are experiencing…

      The good news is I will be releasing 0.9.2 shortly (hopefully tonight!). I hope that my fix will address the anchor/onclick issues you are experiencing. Hopefully my approach fixes your issue! :D

  • David Nguyen says:

    Hey Marcus thanks for the great script, I think I found a bug on your script. When I use goToSlide the timer isn’t reset, so if you time it just right it switches to the intended slide but then changes again because of the autoslide timer :(

  • Flo says:

    Hi Marcus,

    I’m starting a project using this great slider and I have the following issue.
    I’m initializing the plugin using :
    $(‘.iosSlider’).iosSlider({
    snapToChildren: true,
    responsiveSlideWidth: true
    });
    When I resize the window or change orientation, I keep on going back to the first slide. How can I prevent such behavior ?

    Thanks !

  • Rithesh says:

    I had used the above slider for sliding the html pages for IPAD .One of the html pages having some 360 image rotation function.When we drag on the image it will rotate,but problem in IPAD ,touch event conflicts for particular page .The problem is the touch event function overides the 360 degrees rotation function

  • Nishanth says:

    Hi,
    its a great plugin,im using ios slider to load html pages by using jquery load function,normal html files works fine,but for html pages with jquery animation conflict occurs,another question
    can i use with jquery mobile so that in all devices works fine

  • fawzi says:

    Nice work, i am looking forward to use your “onSlideComplete” feature.
    In the meantime, for some reason, after embedding your “Photo-Gallery” example in my my page, Safari displays it with vertical scrolling/sliding. i am not sure from looking at the plugins’ parameter how to control this action to make it horizontal.

    Can you please direct me to instructions on how to switch from one mode to another?

    thanks,

    • marcus says:

      Vertical? I didn’t program it to be able to do that! Do you have an example I can look at? Feel free to send details to contact@iosscripts.com

      • Mike says:

        Vertical would be nice! Any idea if you plan to include this? Been scouring the internet for ONE plugin that does both at this caliber. Great work BTW… Also, I have a question. I am using this to provide a sliding toolbar. each slide is an .

        There are 17 large buttons in the toolbar. 7 are visible, the remaining 10 are hidden until scrolled into view. I’d like the “nextSlide” and “prevSlide” buttons to be able to scroll the next set of 7 buttons into view. Then when clicking “nextSlide” again, only the remaining 3 would slide into view. I believe I can achieve this by wrapping sets of 7 items in one slide. However, I would have to break up my UL lists into multiples and this isnt preferred for accessibility reasons. In addition, I also believe doing this would slide the last three all the way to the left edge, leaving large whitespace which is also not preferred as this is wasted real-estate when existing buttons could be visible.

        Any way one can add a config value to specify the number of slides in a “slide group” and the plugin automagically calculate the number of slides? Like paging really…

      • fawzi says:

        that’s weird… I am not able to reproduce it at the moment, but will send example if i can…. i already changed my code few times over since i first posted, and now it is working fine… i was just still curious on how i achieved that vertical scrolling… anyways… thanks…

  • KhiemND says:

    This doesn’t work correct on ios 4.3. I have tested it with simulator.

  • Mike says:

    Hi Marcus,

    I’m trying to figure out how to modify the speed at which the slider scrolls when clicking on a slide selector button. Ideally, my client would like to see an immediate transition with no animated scrolling.

    I suspect editing this will involve modifying the xCurrentScrollRate array, but I’ve been playing around with the code for a few hours now and can’t figure it out.

    • Mike says:

      Oh, and thanks for this plug-in, it’s awesome.

      • marcus says:

        Have you tried lowering autoSlideSpeed? This will actually affect all slide transition speeds (navPrevSelector/navNextSelector/navSlideSelector/autoSlide/goToSlide).

        Let me know if this accomplishes what you need.

        • Mike says:

          Thanks for the fast reply!

          I did end up finding that adjusting the scrollIntervalTime variable is what affects that, however it’s not behaving in the way I want. Even if I set it to 0, it changes immediately on my desktop browser, but on iPhone and iPad I can still see it scrolling past the other slides to get to where it wants to be.

          The thing is – as per my client’s request – I want to keep the scrollIntervalTime at 10 for everything except for when using the slide navigator. When using the slide navigator, I want the specified image to display immediately, without scrolling through all the slides between the current and clicked slide.

          I could write a function that adjusts the scrollIntervalTime variable for when the slide navigator is in use, however, as stated above, even when set to 0, i still see the scrolling on iPhone and iPad.

  • Chris says:

    Hey Marcus, caught a minor bug: When you use ‘goToSlide’, it doesn’t update the internal “currSlide” index, so that if you ‘goToSlide’ number 1 from, say, the end, hitting the next button doesn’t go to slide 2 because it still thinks it’s at the end.

  • Christopher says:

    Marcus,

    Thanks for creating such a great script. It is just what I am looking for. I was wondering if you’ll be updating the CSS (and the link to the newer JS file) on this page to make it easier to apply your examples on our own webpages?

    I ran into a problem with the embedded html because the width of my image was not the entire width of the slider. Thus, when grabbing the image to drag the slider to the next frame, I ended up just dragging only the image. I got around that problem by adding the following class:

    .iosSlider .slider .item .cover {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    }
    that I then am applying to an empty div element between the image and div with class=”text”
    to put a barrier between the image and the cursor (at least in FF 11.0).

    I understand this could cause potential navigation problems and perhaps problems with forms in a slider div (but the use of the extra div is optional. I mention it here in case you might find it useful.

    Also, I have an issue with the parent element that is arbitrarily used to determine the responsiveWidth and height. In my case, my slider’s parent element happens to have a height of 300px, so even at 1020×768 my 608x600px slider is being resized unconditionally. Perhaps it would be possible to specify an array of responsive width breakpoints that could used by default and if that array is empty, *then* use the parent width & height? Just my two cents. If I can work something out, I’ll send you the code.

    Otherwise, this is just an awesome plugin! Keep up the great work

    Sincerely,
    Christopher.

  • Kristin says:

    Hi! This plug-in is awesome, great job. With the last two versions, links don’t work in embedded html slides on the first slide if DesktopClickDrag is true. The links work on mobile, though, and if DesktopClickDrag is set to false. Is there a JS tweak that could be made to address this or will it just be tackled in the next version? Awesome work, again.

    • marcus says:

      Next version I am looking to fix anchor linking/onclick events within slides. I admit it is currently bugged… infinite slider and some jQuery cloning caused some onclicks to be lost.

      At any rate, I am working out a way of handling links/onclicks properly going forward. Sometimes when a user is grabbing the slider and then releases, a slide with a link in it is inadvertently clicked. Some drag sensitivity monitoring should be used to address that. But progress is being made and I will have a fix :).

      Anyway, that’s where I’m at. I would expect to have something in place on the weekend. Thanks again for trying out iosSlider!

  • Chris says:

    Best jQuery plugin I’ve used yet, especially because I can use it everywhere :)

    Functionality Request:
    Something that I can’t quite figure out myself bug-free: Slide Addition. Is it possible to add a new slide to the end of the current set? The app i’m developing has a max-load of only 5 data-items at a time for performance reasons, and I would like to set it up so that onSlideComplete, it triggers an additional call to load an item and then append it, as a slide, to the end of the current slider-container. Ideally this would work in reverse, too –the ability to destroy individual slides.

    Another functionality request, (though this is something that I have already hacked together but it would be a good addition to the core): The ability to cancel out drag / click if over / on a particular target. In my modified version of the plugin, i set up two additional parameters (“cancelOnClass” and “cancelOnId” that check if a given target has been clicked or touched and cancels out the drag-call if true. Very useful for sites with multiple touch-slide areas (nav docks, text, etc.)

    Again, great, great work.

    • marcus says:

      I think that you could call incorporate the destroy method, jquery’s appendTo() method to add a new slide and then initiate the slider again starting at a specified offset.

      Another way would be to have all the slides in the slider at the beginning but leaving them as empty divs. When sliding close to them, you would load the contents of the slide onSlideComplete.

      Just 2 ideas off the top :).

      I like your second idea, I will look into it!

      • Chris says:

        Hey Marcus,

        Yes, I actually ended up going with the second suggestion; it ended up working well and solving most performance issue, though it still feels a little hacky compared to a public method “add slide” / “remove slide” — but yes, thanks again for getting back to me. This thing flys on the iPad with everything from embedded videos to multiple views to … who knows. Awesome work.

        • fawzi says:

          marcus, i am in a similar situation, except that i do not have a Fixed number of slides, they could be anywhere from 1 to 40 slides. so i tried the destroy-create method. It seems to be doing everything correctly except that all images have “display:none” on them. So nothing is visible in the slider, even though the code shows that the correct divs are there. I can even slide them around and i can see that the scrollBar adjusted accordingly to the new number of slides and my onSlideComplete handler displays the correct values in the console.

          so any ideas why the slides have disply = none, and how to remedy this?
          Or am i calling the destroy function wrongly?

          here is how i am calling it:
          //Load some images in div in html…
          ….
          // Create a slider
          $(“.iosSlider).iosSlider({…….});
          // Load a new set of images and put in div in individual divs in html
          …..
          // Destroy Previous iosSlider….. it has a class= iosSlider, and id = g_slidecont.
          $(‘#g_slidecont’).iosSlider(“destroy”);
          // Recreate the Slider
          $(“#g_slidecont”).iosSlider( {…..});

  • Romain says:

    This is the most beautiful Plugin for iPad and Touch device Thank you so much

  • Robert says:

    First of all, what a wonderful little plugin! Perfectly suits my needs.

    I’ve downloaded the 0.9.1 (beta) version, yet I have trouble getting anchor elements to work. They seem to work perfectly on all slide except for the very first one.

    Is this a bug ?

  • Stefan says:

    Very good piece of work. But it does not run under Safari, 5.02 – 5.1.5 – therefore the name does not quite fit. Any update?

    • marcus says:

      Under 5.02? Your wording is kind of throwing me a bit. Do you mean Safari 4?

      • stefan says:

        Hi Marcus, thanks for the quick reaction. I did not want to offend you or your work in any way – to be clear: this is probably the best slider to date! Moreover, the mentioned “Safari-Bug” (so called) occured under SF 5.15 Win Vista – which surely disqualifies me from now on :-) Surely it runs in the Apple world where it is supposed to be, I guess.

        • marcus says:

          No offense taken :). I will take a look at it in Saf 5.15 on Vista and get it working for a future release. Thanks again for finding that bug!

  • Adrian says:

    Hello.

    How works the calculation of the “SnapToChildren”? I need to Update this – The Function use the half size of an item. I need not the half size, i need the double ratio.

    How i can recalculate the SnapToChildren function?

    Thanks for help

  • kjs3 says:

    Edit to my previous comment:

    The first image seems to always be unresponsive to touch when you enable infiniteSlider. When I set that to false all is well.

  • kjs3 says:

    I’m trying to get this to work with a figure and caption in the slide but it’s not responding to touch on iOS. Do images have to be applied in the background css? I also tried putting an overlay div on top on the figure tag but it still wouldn’t work with touches.

  • [...] iosSlider is a jQuery plugin which turns any wide element into a touch enabled horizontal slider. Touch Me. Hardware accelerated using CSS3 for supported iOS, Android and WebKit iosSlider – jQuery Horizontal Slider for iPhone/iPad Safari (Beta) [...]

  • Gerard says:

    Hi Marcus,

    The new version is great! The gotoslide function works well too. :) The only thing now is that code like this cannot be used anymore in the new version:

    function UpdateNav(settings, node, activeSlideNode, newChildOffset) {
    $(‘#slide_sorter a’).removeClass(‘selected’);
    $(‘#s’ + activeChildOffset).addClass(‘selected’);
    }

    Is there any alternative to this in version 0.9?

    Much obliged,

    G.

    • marcus says:

      Yes! I have improved the way the optional functions handle parameters. The easiest way to explain it would be to get you to take a look at the demo’s in the iosSlider.zip.

  • Ali Dib says:

    Hi Mark,
    Finally i used your plugin on one of the projects i am working on, I totally love it.

    I am trying to add Google Map in one of the slides. Any idea, how to?
    My plan is to have 2 pictures, one Google Map and one Interactive image (with lightbox popup)

  • Emerson Climber says:

    Hi there!
    I was wondering the same think about the mouse wheel …. Is it possible? And if the answer is Yeap, how can I do this? :-P
    Thks

    • marcus says:

      This functionality is not currently built in. What are you looking to do with the mouse wheel? Scroll up and slide left, scroll down slide right?

      • Emerson Climber says:

        Hi Marcus!

        Thanks 4 your answer!
        Well, I’m using the magic mouse, and I would like to scroll left and slide left, scroll right and slide right… should it be possibile to do it?

        Emerson

        • Emerson Climber says:

          By the way, it’s possible to random images with your amazing script and show the slide number?
          Thks for all!

          Emerson

  • Paul says:

    Hi,
    Is there any way i can add mouse wheel effect to the Embedded html version?
    Please contact me on the e-mail. I really need help!

    Thanks,
    Paul

  • Greg says:

    Hi Marc,

    I have a strange behaviour with “infiniteSlider” on iPad with version 0.8.9 : I can slide infinitely towards the left, but not towards the right. The right direction has only one copy of the slides and then I’m stuck.

    It works okay on an iPhone, though.

    Have you seen this problem before?

    Greg

    • Greg says:

      Hi,

      I tried to append more clones of the children to the scrollerNode object, i.e. replacing :

      $(scrollerNode).children().clone().prependTo(scrollerNode).clone().appendTo(scrollerNode);

      with
      $(scrollerNode).children().clone().prependTo(scrollerNode).clone().appendTo(scrollerNode).clone().appendTo(scrollerNode).clone().appendTo(scrollerNode).clone().appendTo(scrollerNode);

      This seems okay now, even though I don’t understand why I don’t find a limit just a little further to the right : I guess I don’t understand how you coded the infinite slider at all! :-)

      Greg

  • Mark says:

    When I set the width of the classes .slide and .iosSlider to 1024px in my CSS file, my slides and my slider always get a width of 876px by element style.
    When I set the width lower than 875px my CSS works and there is no element style, however when I set it any value higher than 876px I get the element style of 876px again.

    how can I fix that?

    great slider though! thanks a lot!

    • marcus says:

      Is responsiveSlideWidth: true? i think you need it to be set to false, or left out of the options so it defaults to false. Could be a bug though, let me know if it works!

      Additional info about responsiveSlideWidth: When responsiveSlideWidth is set to true, it compares the window width to the outer width of the slides (width + margins + borders + padding) and makes the outerwidth equal to the window width if it is greater.

      • Mark says:

        responsiveSlideWidth was not set, so it should have been false.

        It works now as I have an element with class content inside the slide with width set to 1024px.

        .content{
        width: 1024px;
        }

        I don’t know if this fixed the problem or if it was something else, but I’m happy it works now!=)

        Thanks for your very fast answer!

  • Gerard says:

    Hi Marcus,

    I just thought about a few things concerning iosslider. Currently it is possible to embed a slider within a slider. This is especially useful when creating a flipbook (or magazine) with iosslider. That way you can embed small slideshows in pages. However, when swiping an embedded slider, the parent slider also slides along with it. Would there be any way to prevent this?

    Also, it would be cool to offer a vertical scrolling version of iosslider.

    G.

  • gustavo says:

    Thank you for that slider!

    I have a question: how can I redirect the user to a page when it reaches the last item of the slider?

    This is possible?

    Anyway thank you very much!

    • marcus says:

      Something like this might work.

      var lastSlide = 5;
      
      $('div').iosSlider({
      	onSlideComplete: checkSlide
      });
      
      function checkSlide(settings, node, activeSlideNode, activeChildOffset) {
      	if(activeChildOffset == lastSlide) {
      		window.location.href = 'page.html';
      	}
      }
      
  • Gerard says:

    Thanks for sharing this great plugin with us! :) I’m using it now to develop a magazine on iPad. The only thing I can’t get my head around with my limited knowledge of jquery is how to make the slider jump to a specific slidenumber. I’d like to be able to do something like to be able to link from one slide to another.

    Any thoughts would be much appreciated. Cheers! :)

    • marcus says:

      The only way you can navigate the slider right now is with the options: navSlideSelector, navPrevSelector and navNextSelector. I don’t think these will be useful in this case… :(

      On a positive note, I think this functionality is something I would like to include! So I will add it to the next beta release. Probably a end of week.

      • Gerard says:

        That’s great! :) It would be awesome if you could just jump to a slide-number from a link. (for example onClick=”$(‘div’).iosSlider.gotoslide(5);” )

        Can’t wait to see it in the next beta – best of luck! :)

  • Mike says:

    Hello,

    I really like this plug-in, it’s the best slider I’ve found and it works really well with my jQuery Mobile / responsive design site that I’m working on.

    My question is about how to tell the plugin to refresh the width calculation of the “.slider” div. I am using the plugin for a features comparison and there is an option to remove and item from the list (I’m removing “.sliderFrame” div when the user clicks the remove link). I’ve tried adjusting the width of the “.slider” div based off the number of remaining “.sliderFrame” divs but that doesn’t seem to resolve the issue. I’m still able to scroll/swipe to the phantom (removed) slide.

    Is there a way to refresh the slider without re-initializing it?

    Thanks again for creating this VERY useful plugin!
    Mike

    • marcus says:

      Thanks for trying out iosSlider. :)

      Re-initialization would be possible by calling $(‘div’).iosSlider(); again. But then it may be attached twice… havn’t had a chance to try it yet. I would recommend trying that (but it may cause some undesirable effects :S).

      I am currently working on a destroy method which would allow you to kill the plugin globally. You could then bundle that with executing $(‘div’).iosSlider(); again to simply recalibrate. I would expect that functionality to be working by the end of the weekend.

      • Mike says:

        Yeah, that would work. So instead of a refresh I would just destroy the slider and reinitialize. Works for me. Looking forward to it!

        • marcus says:

          The destroy method has been added in v0.8.9 (beta). See Public Methods above for usage. Let me know if it allows you to do what you need.

          • Mike says:

            Can the destroy method be called on an individual slider? Something like this?

            $(“#myFirstSlider”).destroy(true);

            And if I had a second slider on my page $(“#mySecondSlider”).iosSlider({…}) it would still be active? Or are all sliders destroyed no matter?

  • Stefan says:

    Great stuff, thank you!

    May I ask what license you are using? Haven’t found anything on the site, nor in the code.

    Thanks.

    • marcus says:

      No redistribution of original or derivative works. No attribution required for use. This only applies to beta versions. The full release will be different.

  • Martijn says:

    Hi Marcus,
    English is not my native language and this is a bit difficult to explain.
    When I set infinitiveScroll on true in the demo called “4-Embedded-HTML” and click on the previous button, nothing happens. Click on the next button the slider slides to the second slide in the duplicated slides prepended. Click next again and it goes back to the first slide and now everything works normal. Drag and autoplay works just fine.
    Thought I’ll let you know.

  • Martijn says:

    Hi Marcus,
    Great job. I’m building a small site right now. Before I downloaded your script I tried this site on IE8 and everything worked. I downloaded and used the script but when testing it on IE8 it doesn’t slide. So I tried one of the examples that came with the download and they don’t work on IE8 as well. I’ve been comparing the examples with the demo on this site but can’t find it.
    Any ideas? Tnx.

    • Martijn says:

      Somewhere along the script the width of the Slider is being calculated. In IE8 I don’t see the calculated width back in the Slider style element. If put in in manually then I can drag the slider (kinda) but the prev next buttons still don’t work. I’ll keep on digging.

      • marcus says:

        It should be working… I will update the demo package tonight with the fixes. Sorry about that.

        Update: Fixed. Download 0.8.7 and try it out. There was an issue with IE7/8 failing when no border CSS was set.

  • Alex says:

    This is a realy nice script. But I have a special problem. I want to use it for sliding about 50 images on mobile devices and specially for low bandwidth. So I have tried to implement a preloader for my images, so that the image only load, if the actual slide is active. But I can’t get this to work. I have tried it with background image, with normal image tag and so on. All images that I load after the slider initialisation will not be displayed. But in source code, image url’s are correct. It would be very nice if there would be an option to load images individually and not on initialize of the slider.

    • Flo says:

      I was interested having preloading and i did it like this :
      $(‘.iosSlider’).iosSlider(
      // your ioslider Setups
      onSlideComplete:loadImg
      );
      function loadImg(settings, node, activeSlideNode, activeChildOffset) {
      $(‘.selector’+activeChildOffset).html();
      };

      all my images are embedded in :
      selector0 : first image
      selector1 : second image

      • Flo says:

        Oups sorry :

        of course I add the image call on the .html() function something like .html(”);

        • marcus says:

          I like your approach to the preloading. Somehow I never thought of integrating it this way.

          In addition to this, it might be a good idea to check the next/previous slides of the current (activeChildOffset +/- 1) and buffer those without having to go to the slide and then wait.

          • Flo says:

            Good point on preloading the next/previous slide. One nice integration would be to get access to the previous / current / next selector on the onSlideComplete function :)

            • marcus says:

              Yeah you’re right. I would like to pass a lot more variables back to those functions. I am trying to think of a better way to do it. Perhaps passing an array of variables back would work better. So it would be just:

              function slideCompleteFunc(args) {}

              Much cleaner and more data that way.

              • Flo says:

                Yep sounds good !
                Actually having the current selector would be enough as getting the pre and next one would be fairly using jquery’s magic .

    • marcus says:

      Hi Alex,

      Thanks for trying out iosSlider! At the moment, there is no way of buffering the images within the slider, but I do plan on adding that functionality :).

  • Greg says:

    Hi Marcus,

    I experienced a bug with iosSlider and @font-face. The problem is that iosSlider computes the size of the slider before the @font-face font is loaded and applied. If a font changes the width of the slides, then the added pixels make the slider too small : you end up with the last right slide being “cut off” and sent to the “next line”. If this doesn’t make much sense, a demo is here:

    http://artefarita.com/iosSlider/iosSlider-bug-overflow.html

    The last item should be “Décoration & Travaux” and it is not visible because of the @font-face declaration.

    Maybe computing the width on “window.load” instead of “document.ready” could help?

    Grégoire

    • Greg says:

      Well, it seems to work with $(window).load() instead of $(document).ready(), so maybe you could just add this “@font-face” corner-case in the documentation.

      • Greg says:

        It works with window.load on the given link, but not on my real world slider : the computed width is 0px!

        • marcus says:

          From what I’m seeing, it looks like this might do the trick. I cant say for sure without more testing but I would try the following:

          document.onreadystatechange = function() {
          	if (document.readyState == "complete") {
          		//load slider
          	}
          }
          
      • marcus says:

        That makes sense. window.load means that the slider waits until the page has completely loaded all media before firing. That might end up being too ‘late’ in some cases though… If I can’t find a way of resolving this via the script, I’ll be sure to add this situation to the documentation.

        Thanks.

  • Flo says:

    Hi,

    Would it be easy to retrieve the current and targeted slide selector when in the onSlideChange() function ?

    Thanks !

    • Flo says:

      Ok I should have looked at the examples first, for the targeted slide offset that’s how I did :
      $(‘.iosSlider’).iosSlider(
      onSlideComplete:SlideChange
      );
      function SlideChange(settings, node, activeSlideNode, activeChildOffset) {
      // do whatever you need with the var : activeChildOffset
      };

      Love the plugin ! :)

  • David Eglin says:

    Marcus,

    Great script you’re developing here! I have a quick question for you – I notice that you have some variables set up for different IE versions which currently don’t seem to do anything, and that the script currently bombs on IE. Do you have any plans to make this work cross-browser? I would love to use this, but unfortunately the project that I have in mind would need a solution whereby we could use the same script to power both desktop and mobile versions, and IE is a large part of the market.

    Wonderful work… I look forward to seeing how you take it forward!

    David

  • krispouille says:

    Great script indeed.
    You may have already noticed it; but when there are lots of items (130 in my case), it crashed my chrome browser … (But I totally agree, that having 100 items in a slider is certainly too much …)

    • marcus says:

      If your slides are 800px wide (for example) x 130 slides. The slider is 100K pixels wide LOL. I can see a lot of bad things happening. I’ll look into it though.

  • BP says:

    Hi!

    First off, great script! Thank you so much for sharing.

    Is there an easy way to have the thumbails (buttons) scroll along the bottom instead of going to a second line below? If I’m over 6 slides, the thumbnails below the main picture go to a second line.

    Thanks again for all your hard work!

    Cheers,
    B.

    • marcus says:

      Thanks!

      Reply with a link to your example and I will take a look :)

      • BP says:

        Thanks Marcus!

        You can see it here: http://www.bp1.ca/escios/gallery2.html
        It’s being designed to work with an iPad in landscape.

        Cheers,
        B.

        • marcus says:

          I think if you put the thumbnails within a different slider, you would probably be able to achieve this. I’ll look into building out a demo with this concept in mind tonight. Expect to see it up on the site tomorrow.

          • BP says:

            Hey Marcus,

            I tried to add the thumbnails to a slider and it’s *almost* working. It shows the first slide, but not the second.

            The latest version is up.

            If you get a chance, can you take a look at it? I’m missing something easy I imagine.

            Cheers,
            B.

            • marcus says:

              You’re getting there. I uploaded a new 0.8.4 zip with a fifth example. Try that and let me know if it’s what you are looking for.

              • BP says:

                Thanks Marcus!

                Works great. I’ll see if I can add a function that scrolls the bottom slider when someone swipes past the 6th one.

                Thank you again!

                Cheers,
                B.

          • BP says:

            That’s great news! Thank you.

            BTW: I did try and wrap the thumbnails in a new slider, but could not get it to work.
            That’s why I decided to ask. :)

            Cheers,
            B.

  • jk says:

    hey man, im back again.

    The new option responsiveWidth was great.

    There were a few tweeks and bug fixes though.
    At first i changed the orientation and it didnt resize so i thought it didnt handle that, i was about to add it then notice you had it there but just a slight bug that didnt allow it to work on android.

    so i change from $(‘body’) to $(window) now thats fixed.

    then i noticed that when u change u completely reinitialize the slides which is kind of good except that if im on slide 4 , when i change orientation i go to the slide that was set to start.

    so i changed childrenOffsets[settings.startAtSlide-1] to childrenOffsets[activeChildOffset] in the init code.

    i also added made some changes in init to the stage width so i wouldnt have to use css unless i had too. for my purposes only , others might prefer the default way

    i will shoot you the plugin with the old lines commented out an my new lines of code. for all the above

    i will also start to take a loop at the loop and you are correct about the most desired way.

    Thanks again

    • Greg says:

      Hi,

      I’m experiencing the same problem than “jk” with landscape mode : the slider doesn’t resize itself. I’m using version 0.8.4 and I have set the “responsiveSlideWidth” to false (it really should be set to false by default in my opinion, as the longer slide names are cut off when it’s on, making the slider looking seriously bugged).

      While I’m here, I tried to use the “startAtSlide” option and it doesn’t seem to work, even with “snapToChildren” set to true (by the way, the “description” for the “startAtSlide” starts with “(boolean)” instead of “(integer)”).

      I also noticed that version 0.7.7 is more fluid than 0.8.4 is (sorry to be so negative about the latest version but I think it’s important for you to know).

      Cheers,
      Greg

      • marcus says:

        I appreciate any feedback. The more critical people are, the better this can be ultimately. So thanks!

        Responsive slide width will not resize anything within the slider, only the slide itself. This means that if you want your titles to resize or wrap when they are too long, you will need to have width set to auto or a percentage on those items.

        I will look at the bug in startAtSlide not working.

        Sorry for the typo in the options, I can fix that at least! :D

        As I continue to build up the features, performance will be impacted in the short term. I expect it to be an ongoing struggle.

        • Greg says:

          Hi Marcus,

          I cannot find out if I can have slides with non-constant width (i.e. dependant of the length of the text in each slide) and “responsiveSlideWidth” set to true (so that landscape mode extends the slider to the width of the screen). It seems that whenever I set “responsiveSlideWidth” to true, all slides get the same width. Do you confirm this behaviour? If so, could it be possible to have a slider width that ajusts to landscape mode, without forcing a constant width on the slides themselves?

          Thanks,
          Greg

          • Greg says:

            Hi again,

            I solved the problem by commenting out the following lines in init() :
            /*
            if(settings.responsiveSlideWidth) {
            stageWidth = ($(stageNode).width() > windowWidth) ? windowWidth : $(stageNode).width();
            }

            $(stageNode).css({
            position: ‘relative’,
            top: ’0′,
            left: ’0′,
            overflow: ‘hidden’,
            zIndex: 1,
            width: stageWidth
            });

            if(settings.responsiveSlideWidth) {
            slideWidth = $(slideNodes).outerWidth(true);
            if(slideWidth > windowWidth) {
            slideWidth = windowWidth + ($(slideNodes).outerWidth(true) – $(slideNodes).width()) * -1;
            } else {
            slideWidth = $(slideNodes).width();
            }
            $(slideNodes).css({
            width: slideWidth
            });
            }
            */

            I guess you could add another option for people who only need the “landscape” resize of the slider, but who don’t want fixed-width slides.

            Greg

            • marcus says:

              That works. But that’s definitely a bug. responsiveSlideWidth should only alter slides that are above the threshold when set to true, not change them all :S. Expect that fix in the next release. :)

  • Roger says:

    hello, marcus
    ur plugin is great!! thanks!

    i have one problem.
    when i zoom the webpage, no matter in or out, the slider will flash(looks like reload), and sometimes the word will be blur.
    Is it the bug about mobile device?

    • marcus says:

      The slider needs to recalibrate whenever there is a change in window resolution, updating the scrollbar, slide widths, etc. This essentially resets the slider to its starting state. Would you prefer to see something different happen when zooming in?

      Also, which device are you using?

      Thanks.

      • Roger says:

        Oh, i see
        That means the recalibrate process can’t be avoid.
        I am using ipad.
        are there differences among different devices?

        Thanks!!

        • marcus says:

          Sometimes there are bugs across different devices, that’s the only reason I ask.

          The recalibration process has been streamlined in version 0.8.3. By default, when you are on a slide and the window is resized, you will stay on the same slide. Another option you have is to set responsiveSlideWidth = false. This will disable all resizing and recalibration. Let me know if that helps.

          • Roger says:

            Oh, Thanks so much!
            I will try it.

            I have another question.
            I want to know if iosslider is possible to be used on the items with different width?

  • Flo says:

    Hi, just wanted to say: Beautiful / easy to use script !

  • jk says:

    marcus you have been excellent in updating and add functionality to your plugin.

    The feature i am waiting on is the added feature of the infinite loop.

    There are two types
    - infinite loop where you see the transition back to the first slide/last slide
    - infinite loop where there is always just the next and previous slide with no extra transition

    If you are interested i just took a look at you code and i see it is easily implement the first one with two lines of code.

    i would have to really examine your code a little more for the second type. (maybe ill get a little time tommorrow when i test out the responsiveSlideWidth to figure it out as well.

    only if you are interested.

    Thanks again

  • jk says:

    sorry to be overwhelming your blog post area!

    Quick question i am trying to implement this into a mobile enviroment, i have problem getting a 100% width set for the slide the allows it to automatically adjust based on screen size.

    example. i have a slide div that has a image that i have to defined width and height and a div under the image that has text and so forth. but i cant get it to allow the text to automatically be the width of the screen and adjust according

    do you understand? and do you know the method of handlng this similar to how yahoo.com slider sits.

    thanks

    • marcus says:

      I get what you are saying…. That would be a situation I overlooked.

      SO, let me ask you this. Is there ever a situation where you might want to have slides wider than the width of the screen? no, right? I will add some code that evaluates the following:

      if(slideWidth > windowWidth) slideWidth = windowWidth.

      If the slide width is less than the window width, then it will function as normal. Deal?

      • jk says:

        just to also clarify i was originally posting for a css solution that i thought you may already know about.

        but this should work just as nice.

        • marcus says:

          A CSS solution would be impossible I think… for a slide to have it’s width dynamic based on the window, it would need to be a direct child element of it, and that wouldn’t be possible because they need to sit within the slider :S.

          At any rate, 0.8.2 is up and should do what you need! The ‘responsiveSlideWidth’ option will allow you to toggle this functionality on and off. Cheers! :D

          • jk says:

            yeah you are correct about the css

            and i will get a chance to update you tommorrow.

            Super Awesome thanks to you and your plugin again.

      • jk says:

        yes that sounds like a plan, sounds like the solution. i can test out once its updated.

        As far as the if block.
        i dont think i ever would need any slides wider than the screen. but for others you never know.

        so i would say a api option to turn it off or on. ex. slideWidthAuto: true/false and maybe even slideHeightAuto: true/false (not sure) then only use the if block above when this option is true

        just idea.

  • jk says:

    looks good appreciate the update. now just whenever you get time to get to the infinite loop through slides(i think it will be as full featured as any other plugin)

    thanks again

  • jk says:

    Nice work!

    Am I missing something or is there no way to continue to the first slide when u get to the last siide and go to the last slide if you slide past the first slide.

    i guess i mean is there no way to have it where its continuous(no end)

    • marcus says:

      You’re not missing anything, it doesn’t exist… yet. The ‘infinite’ scrolling style has been asked requested a lot. It’s a priority enhancement right now :). Hoping to have it up with a few other new additions in the next little bit. :)

      • jk says:

        ok sounds good, nice work even without it but i would definitely use it over something else with it.

        is there any current function / or variable that i can access that will allow me to dynamically change the current slide.

        I need a way to have previous/next buttons for those that dont realize they can slide, just asking before i try to hack in my own version

        • marcus says:

          Wow what a coincidence! I am about to release that! If you can wait a few hours, I can have 0.8.1 up tonight with that functionality included.

          • jk says:

            man yeah that is coincidental but even better than that… You are awesome on the support, quick reply and just pure dedication to your project.

            just awesome.

  • Charlie says:

    Thanks for some awesome Javascript!

    I’ve come across a curious bug using an input form element & iosSlider on the same page – example @ http://cucaera.co.uk/lincsbeetles.m/e3.html

    Works fine on an iPod, but on my Android device (using the stock browser) typing in the input is delayed – it takes ~4 seconds for the character to show.

  • David says:

    One more thing: onSlideStart and onSlideComplete arguments/parameters doesn’t match. Why?

    onSlideStart(this, HTMLElement)
    onSlideComplete(this, DOMWindow, i)

    The second parameter need to be the slider’s element.

    Br,
    David

  • David says:

    Hi Marcus!

    I have an issue with Chrome on the second example.

    First swipe the slide nr. 2 was perfect. Then, when I want to swipte to the third slide it’s jumped to the first slide. Actually, forgot the original statement when I starts drag (onmousemove event). In IE and FF works great. I checked your code and I think I found the problem: If you force “isWebkit” var to false, the bug is disappearing. I think you are using isWebKit to detect iPhone/iPad/iThings but it isn’t good, you need to check Chrome as well.

    Or I have a simple fix. At line number 195, change this:

    if(isTouch || isWebkit) {

    to this:

    if(isTouch && isWebkit) {

    I didn’t tested on my iPad, but I think it’s will be good.
    Fix it, then publish your next release :)

    ps.: sorry for my bad English knowledge.

    Keep up the good work!
    Br,
    David

    • marcus says:

      I’m sorry… I somehow missed that bug when I was tinkering with some desktop compatibility. The fix you mentioned work but not exactly what I had to do to fix it. Touch devices and WebKit browsers are not exclusive to one another in all cases.

      Just in case you are curious, to fix the issue I changed a condition within the init() and getSliderOffset() functions to:

      if(isTouch || isWebkit) {

      from this:

      if(isTouch) {

      At any rate it is fixed in version 0.7.9. Sorry for the inconvenience :(.

    • patrick says:

      I’m having the same issue with examples 2 and 3. Using Safari 5.1.3, OS 10.7.3.

      • marcus says:

        Fixed in 0.7.9. Sorry about that…

      • David says:

        Yeah, Safari is using same engine (WebKit).

        Marcus, publish your code to github / bitbucket(free) and I will fork your code. I found some annoying “features” like onSlideStart / onSlideComplete can’t reach the slider or the scroller element. Some inline style is unnecessary too (f.e. margin-bottom). I would like to share with you and with the community.

        David

  • Greg says:

    Hi Marcus,

    I’d like to know if this is possible to initialize the slider so that a given slide is visible.

    The use case is that I have added a “selected” class on the selected “li” element (so I have a somewhere), and if this element is far to the right of the slider, then it may not be visible on the new page.

    The idea could be to “snap” from slide to slide, until we find the one which carries the given class (“selected” in my example, but the name of the class should ultimately be left to the user).

    What do you think of this idea?

    Thanks,
    Greg

    • marcus says:

      What I will do is add an option called ‘startAtSlide’ (or something similar) which will accept an integer value of the slide to start at. The javascript would look like:

      $('.iosSlider').iosSlider({
              startAtSlide: 2
      });
      

      This will initiate the slider at slide 2. Will that achieve what you are thinking of?

      This will be included in the soon to be released version 0.8 :D!

    • Greg says:

      The html tag was eaten by the form. Insert “li class=’slide selected’” between “so I have a” and “somewhere”. :-)

  • tais says:

    Somebody told me that is it not working on a Windows mobile.
    Can anybody confirm this?
    Maybe internet explorer issue?

    • marcus says:

      Without testing it and knowing how bad IE usually takes to these sorts of things I would say probably not.

      • Conrad says:

        It works almost on IE mobile. but only the browse-buttons work, not the touch-dragging.

        • Mike says:

          I can confirm this as well. Prev/Next button functionality works well but the swipe/touch-drag functionality does not work.

          Are there any plans to adopt this? I’d be more than willing to assist with testing on a Windows Mobile 7.5 device.

  • Gino says:

    Hi, great,
    if you want to mimic iPhone or mobile phone, when the image pass 51% of the screen, it should slide and not return back,
    If you do it slowly, and slide image until 51% of the image is showing, on mouse out it should continu to slide. :)

    • marcus says:

      I am having trouble understanding what you’re saying. I’m benchmarking it against the iPhone/iPad home screen slide functionality (when the ‘snapToChildren’ option is set to true). In 0.7.7 I am not seeing any major difference in functionality, unless there is a bug I’m not seeing :S.

      What is supposed to happen is: While ‘snapToChildren’ = true, if the user swipes quickly, it will always snap to the next slide. When the user slides at a speed below the velocity threshold, it will snap in the direction of the most visible slide.

  • Taï-nui says:

    hello Marcus,
    first of all : thanks and congratulations for your work, your slider rocks !

    i totally agree with Florian : adapting behaviour when rotating would be greatly appreciated ; before you achieve this, may there’s a way to desactivate the sliding effect and then reactivate it ?
    Best regards

  • tom h says:

    i have downloaded the new slider and am now using it. it is a big improvement on the previous version i was using. i have found a small issue that may want fixing. on line 427 you have left in alert(‘a’); i assume this was for testing purposes as it serves no purpose and probably just wants removing

  • Greg says:

    Hi Marcus!

    I downloaded version 0.7.3 and I have a problem to reach the last item to the right. Very often, the slider bounces back, making this item unreachable. Is there a way to configurate the slider so that it doesn’t bounce back “too much”?

    Thanks!
    Greg

  • Oliver says:

    Hi there !
    First off, thanks a lot for this great script. I’m using it in a project to generate an image rotator…this means that I only have one slide. I tweaked the script a bit to fit my needs, but I can’t get the following to work: I would like that the end of the slide (part to the far right) acts the same as the beginning of the slide. Would you mind pointing me out how I could achieve this ? Thanks in advance.

    Kind regards, Oliver

  • tais says:

    hi!
    i like this a lot too.
    I have several slider on my page (ijinprod.com/iphone/)
    so i can’t scroll vertically…
    Do you have a workaround for me?
    thank you

  • Christian says:

    Hi Marcus,
    Nice script, very easy to use!! Thank you for writing it!
    I’m wondering if it’s possible to make the slider infinite? Means it goes in circle and when you hit the last slide, it will automatically return to the first slide?

  • Greg says:

    Hi Marcus!

    I’m trying to make an horizontal menu for iPad/iPhone. Your “iosSlider” class is what I find to be the best so far, in terms of fluidity.

    However I have a problem : when I add links in the “slide” elements of your example, the “clicking area” is shifted to the bottom and to the right (as displayed by the area when the links are activated). I have put a screenshot here, showing that the active area is not centered :

    http://artefarita.com/iosSlider/shift.jpg

    As can be seen, to activate the Google link, the user has to tap on the bottom of the “g” and not on the second “o” as expected.

    You can test the problem here :

    http://artefarita.com/iosSlider/iosSlider.html
    or more shortly :
    http://bit.ly/wKLrBS

    I don’t own an iPhone or an iPad, and I test on Android’s browser (WebKit based).

    I believe this is a bug from iosSlider, because when I remove the call to iosSlider() from my JS, the links “active” areas are normal (centered around the text).

    Can you confirm that you have the same behaviour on your iPhone/iPad, and have you any idea of where the bug comes from? I tried to isolate the problem but without success.

    Thanks!
    Greg

    • marcus says:

      Hi Greg,

      Thanks for trying out iosSlider! That issue is interesting… I will take a look at it and update the plugin with the fix (probably today or tomorrow). I use an iPhone/iPad to test so hopefully it isn’t an android specific issue. It’s webkit as well so it should be fine… I will update the plugin and email you the fix as well :).

      Update: Sadly I can’t seem to regenerate this issue on the iPad/iPhone. Although, there was a different bug in 0.4 which had some links not activating when clicked within the slider. I have released a newer version (0.5) which resolves that particular issue. Download 0.5 and try it out and let me know if it fixes your issue as well: iosSlider 0.5 (beta).

      Once I have the iPhone/iPad working to my satisfaction, I will move to Android dev. But for now it will have to stay unsupported :(.

      • Greg says:

        Hi Marcus,

        Thanks for the reply! The problem was that the click was not being propagated and so it was ok with version 0.5.

        The slider would be perfect if it could compute the horizontal length of the items and stop moving them when there’s no need too. For example, if I have only 3 items in my menu, and each one is 70px width (total 210px), and my slider is 300px, then I would like the slide effect to be removed completely when I touch the items (the slide effect only makes sense if there are hidden entries in the menu).

        The menu entries are fetched from a database and I don’t know how many there are statically.

        Thanks!
        Greg

  • Patrik says:

    Hi,
    Great plugin, thanks! However, I would like to have the slides to snap only to the next one and never bounce back to current, if not slid far enough. I have tried with different settings, but nothing seems to affect it. I’m going through the code now to find the place where it checks the slide’s position and decided to bounce back to the current one, but I would appreciate if you can point me to the right direction.
    Also having it as an option in the future would be great.
    –patrik

    • marcus says:

      Hi Patrik,

      iosSlider 0.7 (beta) contains this functionality. When the option ‘snapToChildren’ is set to true, slides will always move to the next/previous item on slide unless the momentum is extremely low. Thanks again trying out iosSlider!

  • sebastiaan says:

    Hi,

    great work.

    How far are the controls for normal web browsing. Like for blackberry.

  • tom h says:

    hi, im currently using your slider in a mobile website and have found a bug. if you are at the very right of the scroller and try to scroll left again but do it too fast and drag your finger off the edge of the screen the scroller bounces off the right edge and back to where is was. this is slightly difficult to replicate on an iphone but can be done. however it is very noticable on android, which is why i would like a fix. any ideas?
    also the scroller performs very poorly on android browsers. i dont understand why seen as it is the same web browser so this must be a bug aswel. i no its not billed as a cross platform component but it would be a good feature.
    my current settings are;

    snapToChildren: false,
    scrollbar: true,
    scrollbarHide: false,
    scrollbarLocation: 'bottom',
    scrollbarHeight: '6px',
    scrollbarBackground: '#d5d8d8',
    scrollbarBorder: '1px solid #c1c2c2',
    scrollbarMargin: '0 10px 5px 10px',
    scrollbarOpacity: '0.75',
    frictionCoefficient: '0.1',
    elasticPullResistance: '0.1',
    elasticFrictionCoefficient: '0.1'
    
    • marcus says:

      Hi Tom,

      The bug you found has been resolved in iosSlider 0.7 beta. Also, I have noted the issues with android browsers and can only offer you a frowny face [:(… but I can say that I will be fully optimizing the Android version once I release the 100% working iOS version. Thanks again for using iosSlider!

      • tom h says:

        i’m glad to see you have now fixed the issue. i will download and try the new version asap. as far as i can tell the slider works quite well on android apart from the one issue i reported. so maybe not too much optimization will be required.

  • Robin says:

    Hi Marcus,

    I am currently trying to put a link in the slider, but it doesn’t work. The iOS slider only shows up when you’re using an iPad, iPod or iPhone, so I hope you own one of these.

    Do you have any idea why it wont work? I really need this since I’m loading the contents via jQuery (via the <a> relation).

    The URL is: http://bit.ly/s98TP9

    Hope you can help me out!

    Kind regards, Robin.

    • marcus says:

      Good news, I have a fix for your issue! :D

      Here is a copy of iosSlider 0.5 (beta) with a the fix applied to resolve the issue you are experiencing.

      Thanks again for using iosSlider! It’s still in beta so let me know if you come across any other issues.

      • Robin says:

        Hi Marcus,

        Thanks for this!! I really needed this. Hope it doesn’t cause any other bugs since it’s a beta version.

        Thanks for your work, appreciate this!

        Greetings from holland :) Robin

        • marcus says:

          No problem! Thanks for finding the bug for me. :)

          Send over a link to the page once it’s all styled and polished, I would love to see the finished product!

  • Ryan says:

    This is the coolest JS on the web right now!
    We just spent 1 hour searching around and testing different systems, and this one is by far the best. We definitely want all the features above, and the ability to double-tap to open a new page.

    Thank you for building this fantastic Mobile JS.

    • Ryan says:

      Now for special request:

      Can you create an elasticity to the dragging, so as to separate the strip of objects to independent object motion. For example, please think of a Newton’s Cradle, but with elastic and time variables.

      What do you think?

      • marcus says:

        Coolest JS on the web?! Well, thanks! I think the iPad/iPhone web stuff is so heavily overlooked right now it’s ridiculous.

        I love the double tap idea for links within the slider… I’ll add that to the list of features coming to future releases! :D. As for the second idea, I COULD create that with some decent sized modifications to this script. It would be an interesting implementation, but sort of outside the scope of this project I think :S.

        I am a gun for hire though, so if you need that specific thing done real bad, send an email to contact@marcwhitbread.com.

  • Florian says:

    hi,

    i really like your Script (there are not many sliders around which do not need jqtouch or jqm).

    But I am having a problem with dynamic width. I am trying to use it so that the images use the complete width of the device (no matter what resolution the device has) but I did not have much success with it.
    Can you give me some help.

    Thanks in advance

    • marcus says:

      Hi Florian,

      This is a good example. I will definitely include the dynamic width slider as a coded example in an upcoming release. Here is what you need to do… Within the document.ready function – above the iosSlider trigger – you need to add the following code:

      $(document).ready(function() {
          /* set the width of the iosSlider container to be the window width */
          $('.iosSlider').css({
              width: $(window).width() + 'px'
          });
      
          /* set the width of the iosSlider slides to be the window width */
          $('.iosSlider .slide').css({
              width: $(window).width() + 'px'
          });
      
          /* launch iosSlider */
          $('.iosSlider').iosSlider();
      });
      

      Please let me know if you have any additional questions, and I’ll do my best to help you out. Thanks again for using iosSlider! :D

  • marcus says:

    I am taking feature requests! Feel free to pass along any functionality that you would like to see in upcoming releases! :D

    • master floda says:

      another nice to have would be setting the index of the starting image so you don’t have to start with the first.
      here’s a workaround:

      	$('.slider').css({
      		webkitTransform: 'translateX(-' + (newIndex*$(window).width()) + 'px)'
      	});
      

      (where newIndex is the index of the image you want to scroll to)

      • marcus says:

        You’re definitely on the right track with that code. You aren’t accounting for variable sized slides though, but this would be easy to implement none the less. I’ll add it to my long list of to-do’s! Thanks :D

    • Florian says:

      Nice features to have:
      - As already discussed: 100% width, including changing from landscape to portrait and back.
      - Some control buttons (next image, prev image). I know swipe should replace that, but it would be nice to have that as a fallback or to trigger a swipe with a link..
      - Loop: I do not know how it should work but a loop so that after the last image the first image is displayed.

      • marcus says:

        Oddly enough, the looping and the controls are already on their way. The portrait/landscape switching and the 100% width functionality are great ideas! I will add them to the list of new functionality.

  • Leave a Reply

    Your email address will not be published. Required fields are marked *

    *

    You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>