jquery - Javascript plugin only firing once -


I have created a very basic jQuery plugin, which inevitably holds a phantom image which is a set amount The animation effect to every x millisecond and this plugin is very basic at this level and there are only a few options, and it works very well.

In addition to that it has set fire only once! I have several examples of animation on one page and they are all fire, but once only once.

Now I am not an expert on JavaScript and only managed to combine it together, but here's the code by any means:

  // Animation plugin ( Default default option = {SluWidth: 100, frame: 10, speed: 40, minCycles: 1, stopFrame: 0}; // default in function ($) {$ .fn.anime = function (customOptions)} // default Set options for options by using the default option; // set option; Custom options with default Merge existing options with the option set (custom option); // custom option function set option (custom presentation) {options = $ .extend (options, customOptions);} return.Each (function () {/ / Animation object var $ elem = $ ('img', this); var framecount = 0; var start startSlideWidth = Options.slideWidth; var intervalID = null; var cycleCount = 1; var animate = function () (if ( Framecount & lt; (options.frames-1)) {$ elem.css ('left', '-' + currentSli devdom + 'px'); frameCount ++; CurrentSlideWidth + = options.slideWidth; } And {if (Chakkankan & lt; options.minCycles) {frameCount = 0; CurrentSlideWidth = options.slideWidth; $ Elem.css ('left', '-' + current sladwidth + 'px'); CycleCount ++; } And {window.clearInterval (interval ID); $ Elem.css ('left', '0px'); }} CycleCount = 1; }; $ (This) .bind ('mouseover', function () {var intervalID = window.setInterval (animate, options.speed);}); }); }; }) (JQuery);   

The code used to call the actual plugin on a DOM element is:

  $ ('# animeboolt'). Anime ({frames: 50, slidewidth: 62, min cycle: 1, speed: 30,});   

This is the HTML that is called:

  & lt; Div class = "anime" id = "animebolt" & gt; & Lt; Img src = "_ assets / img / anime-bolt.png" alt = "lightning bolt" width = "3100" height = "114" & gt; & Lt; / Div & gt;   

and finally CSS:

  .anime {position: absolute; Hidden flurry; } .nimig {status: absolute; Left: 0; Top: 0; } #animeboolt {top: 2669px; Left: 634px; Width: 62px; Height: 116 pixels; }   

How do I get the plugin to fire again and again?

I created and modified jsfiddle example using your code. It has been working

I have changed some things:

  • Added clear interval for multiple overlapping intervals on the mouseover over the mouseover
  • Out of the intervalID Left the variable each function, and var the keyword was removed from the mouseover handler so that the script will remember the interval ID set on the last mouseover
  • Frame counting , Animation end on cyclard and current slide width variation (which really is Annie Registration was a clue to just more than once)

    hope

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -