Change plugin-vars "onBeforeInit"
Hi,
developed my own Image-Carousel which automatic resizes, when the window is resized or in my case when the orientation of a mobile device is changed. Now I want to change to number of displayed slides in Landscape-View, but i dont know how to change my "Setting"-Vars in my Plugin-Call
Here is the basic Code of my Plugin:
- (function($){
- $.fn.didiCarousel = function(settings) {
- var defaults = {
- displaySlideQty : 2,
- moveSlideQty : 2,
- delayFadeTime : 500,
- delaySteps : 350,
- onBeforeInit : function() {},
- onAfterInit : function() {},
- onLoaded : function() {},
- onBeforeSlide : function(direction) {}
- };
-
- var $this = $(this);
- var settings;
- var maxVisibleItem = settings.displaySlideQty;
-
- var initCarousel = function() {
- settings.onBeforeInit();
- settings = $.extend({}, defaults, settings);
-
- // some JS Code
-
- settings.onAfterInit();
- }
-
- var refreshCarousel = function() {
- clearContent();
- initCarousel();
- }
-
- $(window).resize(function(){
- refreshCarousel();
- });
-
- $(window).load(function() {
- settings.onLoaded();
- });
-
- initCarousel();
- }
-
- })(jQuery);
Here is the Code of my Plugin-Call:
- var mySlider = $('#myCarousel').didiCarousel({
- displaySlideQty : 1,
- moveSlideQty : 1,
- speed : 500,
-
- onBeforeInit: function() {
- window.onorientationchange = function() {
- alert("ori change start");
- $.fn.didiCarousel.settings.displaySlideQty = 2;
- $.fn.didiCarousel.settings.moveSlideQty = 2;
- alert("ori change done");
- };
- },
- onAfterInit: function() {
- // irrelevant JS-Code after initialization
- },
- onBeforeSlide: function() {
- // irrelevant JS-Code before every slide
- },
- onLoaded: function() {
- // irrelevant JS-Code after everything is loaded
- }
- });
As you can see I trigger the orientationchange in my "onBeforeInit" function and try to change my Plugin-Settings-Vars. But no matter what I do I get an error and my second alert isnt called. Can somebody tell me how to change my Plugin-Settings-Vars in my "onBeforeInit" Function.