iosscripts / iosslider

iosslider is a jQuery plugin which allows you to integrate a customizable, cross-browser content slider into your web presence. Designed for use as a content slider, website banner, or image gallery.
http://iosscripts.com/iosslider
432 stars 103 forks source link

settings.onSliderResize Doesn't Fire #280

Closed theloveofcode closed 11 years ago

theloveofcode commented 11 years ago

Settings:

{ onSliderReize: function () { alert('test'); }, onSlideChange: function () { alert('test'); } }

Then, inside the callback for $(window).bind(orientationEvent + '.iosSliderEvent-' + sliderNumber, function() { ...} you can add this: console.log(settings);

While onSlideChange will correctly be a function, onSliderReize is an empty string, and therefore isn't fired.

marcwhitbread commented 11 years ago

You have a spelling error in your code there. Just tested this code and it fires correctly.

$(element).iosSlider({
    onSliderResize: testFunction
});

function testFunction(args) {
    console.log('it works!');
}
theloveofcode commented 11 years ago

That was actually the custom written example. My actual code has the callback spelled correctly, and it doesn't fire.

    function WorkiosSliderResize(args) {
        $('#work .iosSlider').stop(true, false).animate({
            'height': args.currentSlideObject.height()
        }, 500);
    }

    $('#work .iosSlider').iosSlider({
        snapToChildren: true,
        infiniteSlider: true,
        scrollbar: false,
        desktopClickDrag: true,
        responsiveSlideContainer: true,
        responsiveSlides: true,
        navPrevSelector: '#work .iosSliderCustomNav .prev',
        navNextSelector: '#work .iosSliderCustomNav .next',
        onSliderResize: WorkiosSliderResize,
        onSliderUpdate: WorkiosSliderResize,
        onSlideChange: function (args) {
            $('#work .iosSliderCustomNav').find('.current').text(args.currentSlideNumber);

            var $imgs = args.currentSlideObject.find('img');
            if ($imgs.size() <= 0) console.error('Featured projects must have a header image.');

            $imgs.imagesLoaded(function () {
                WorkiosSliderResize(args);
            });
        },
        onSliderLoaded: function (args) {
            // Sometimes the slider loads before the header image does
            // Wait for both to load before setting the height and other attributes
            var $imgs = args.currentSlideObject.find('img');
            if ($imgs.size() <= 0) console.error('Featured projects must have a header image.');

            $imgs.imagesLoaded(function () {
                $('#work .iosSliderCustomNav').find('.current').text(args.currentSlideNumber);
                $('#work .iosSliderCustomNav').find('.total').text(args.data.numberOfSlides);
                $('#work .iosSlider').height( args.currentSlideObject.height() );
            });
        }
    });

Because onSliderResize isn't working, I had to do this:

    $(window).on('resize', function() {
        $('#work .iosSlider').iosSlider('update');
    });
marcwhitbread commented 11 years ago

I just copied and pasted your code into example 1 (default) and it definitely fires.

What device are you testing on? Latest iosslider version?

theloveofcode commented 11 years ago

Sorry for this. I must have had something else conflicting when I was testing this because now it works.

marcwhitbread commented 11 years ago

Glad to hear it :).