I'm looking to change a single jQuery plugin option when the window hits certain breakpoints.
The code below works, however I'm conscious of repeating code and feel there is a more elegant way writing code for examples like this.
My initial thoughts would be to store the first call in a variable.
$(window).smartresize(function () {
if ( config.wWidth >= 768 && config.wWidth <= 1024 ) {
$('#va-accordion').vaccordion({
accordionW : config.wWidth,
accordionH : config.wHeight,
visibleSlices : 2,
expandedHeight : 600,
expandedWidth : 1000,
contentAnimSpeed : 200
});
} else if ( config.wWidth < 768 ) {
$('#va-accordion').vaccordion({
accordionW : config.wWidth,
accordionH : config.wHeight,
visibleSlices : 1,
expandedHeight : 600,
expandedWidth : 1000,
contentAnimSpeed : 200
});
} else {
$('#va-accordion').vaccordion({
accordionW : config.wWidth,
accordionH : config.wHeight,
visibleSlices : 3,
expandedHeight : 600,
expandedWidth : 1000,
contentAnimSpeed : 200
});
}
});
$(window).trigger("smartresize");