Closed theloveofcode closed 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!');
}
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');
});
I just copied and pasted your code into example 1 (default) and it definitely fires.
What device are you testing on? Latest iosslider version?
Sorry for this. I must have had something else conflicting when I was testing this because now it works.
Glad to hear it :).
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.