8000 fix margin for infinite vertical · Dream-git/unslider@094dc42 · GitHub
[go: up one dir, main page]

Skip to content

Commit 094dc42

Browse files
author
Visual Idiot
committed
fix margin for infinite vertical
1 parent 428fcb3 commit 094dc42

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

dist/js/unslider-min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/js/unslider.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -348,9 +348,6 @@
348348
)
349349
);
350350
});
351-
352-
// So then we need to hide the first slide
353-
self.$container.css({marginLeft: '-100%'});
354351
};
355352

356353
// Remove any trace of arrows
@@ -463,6 +460,11 @@
463460
prop = 'right';
464461
}
465462

463+
if(self.options.infinite) {
464+
// So then we need to hide the first slide
465+
self.$container.css('margin-' + prop, '-100%');
466+
}
467+
466468
return self.slide(prop, to);
467469
};
468470

@@ -471,6 +473,14 @@
471473
// can just call as is
472474
self.animateVertical = function(to) {
473475
self.options.animateHeight = true;
476+
477+
// Normal infinite CSS fix doesn't work for
478+
// vertical animation so we need to manually set it
479+
// with pixels. Ah well.
480+
if(self.options.infinite) {
481+
self.$container.css('margin-top', -self.$slides.outerHeight());
482+
}
483+
474484
return self.slide('top', to);
475485
}
476486

0 commit comments

Comments
 (0)
0