Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the requirement for the number of frames to be an exact multiple of the frames visible #7

Open
janthonyeconomist opened this issue Jun 25, 2014 · 1 comment

Comments

@janthonyeconomist
Copy link

Problem:
If there is 4 frames visible, and 9 frames, then the system will only allow you to scroll once and the last frame is alway hidden.

Solution:
Always allow the person to scroll to the very end, but only scroll to the offset that doesn't display empty space.

Diff:

=== modified file 'jcarousellite_1.0.1.js'                            
--- jcarousellite_1.0.1.js 2013-02-21 23:02:00 +0000                  
+++ jcarousellite_1.0.1.js  2014-06-25 13:13:31 +0000
@@ -318,8 +318,10 @@
                         curr = to==itemLength-v+1 ? v+1 : v+o.scroll;
                     } else curr = to;
                 } else {                    // If non-circular and to points to first or last, we just return.
-                    if(to<0 || to>itemLength-v) return;
-                    else curr = to;
+                    if(to<0) to = 0
+                    else if(to>itemLength-v) to = itemLength-v
+                    if(curr == to) return;
+                    curr = to;
                 }                           // If neither overrides it, the curr will still be "to" and we can proceed.

                 running = true;
@janthonyeconomist
Copy link
Author

Looks like you also need this:

=== modified file 'jcarousellite_1.0.1.js'
--- jcarousellite_1.0.1.js  2014-06-18 22:18:27 +0000
+++ jcarousellite_1.0.1.js  2014-06-26 15:57:21 +0000
@@ -337,9 +337,9 @@
                 // Disable buttons when the carousel reaches the last/first, and enable when not
                 if(!o.circular) {
                     $(o.btnPrev + "," + o.btnNext).removeClass("disabled");
-                    $( (curr-o.scroll<0 && o.btnPrev)
+                    $( (curr == 0 && o.btnPrev)
                         ||
-                       (curr+o.scroll > itemLength-v && o.btnNext)
+                       (curr >= itemLength-v && o.btnNext)
                         ||
                        []
                      ).addClass("disabled");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant