Enjoy an ad free experience by logging in. Not a member yet? Register.
|
|
Results 1 to 2 of 2
Thread: Recursive jquery functions
-
03-18-2016, 09:41 AM #1New to the CF scene
- Join Date
- Feb 2016
- Posts
- 3
- Thanks
- 0
- Thanked 0 Times in 0 Posts
Recursive jquery functions
Hi everybody!
I try to make a slider, but i can't understand how jquery recursive functions work. Here is the code so far:
I tried to add $(this).banner(); after the last moveRight() but if i do that after a long delay all the functions run at once. Can somebody show me the way?Code:(function ($) { var w = 160; $.fn.moveLeft = function (elm, delay, x, y, t) { var elm_s = $(elm); $.each(elm_s, function () { $(this).delay(delay).animate({left: '-=' + w}, t); }); }; $.fn.moveRight = function (elm, delay, x, y, t) { var elm_s = $(elm); $.each(elm_s, function () { $(this).delay(delay).animate({left: '+=' + w}, t); }); }; $.fn.banner = function(){ //first text blocks in $(this).moveLeft('#text_wrap h2', 800,0,0,1000); $(this).moveRight('#text_wrap h3', 800,0,0,1000); //first text blocks out $(this).moveLeft('#text_wrap h2', 3000,0,0,600); $(this).moveRight('#text_wrap h3', 3000,0,0,600); //second img in $(this).moveRight('#second-img', 5400,0,0,1000); }; }(jQuery)); $(document).ready(function () { $(this).banner(); });
-
03-18-2016, 06:51 PM #2New Coder
- Join Date
- Feb 2016
- Posts
- 80
- Thanks
- 0
- Thanked 16 Times in 16 Posts
What do you intend to slide? Text or images? Please post the HTML. Without having analyzed your code completely I assume that you have to place the recursive call as a callback function of your animate().
Last edited by Sempervivum; 03-18-2016 at 06:55 PM.



Reply With Quote
