Skip to content

Commit

Permalink
Fixed carousel vertical alignment
Browse files Browse the repository at this point in the history
  • Loading branch information
acburst committed Dec 20, 2016
1 parent bd2abb5 commit bb5dd21
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion bin/materialize.css
Original file line number Diff line number Diff line change
Expand Up @@ -7776,7 +7776,7 @@ input[type=range]:focus::-ms-fill-upper {
.carousel .carousel-item {
display: none;
width: 200px;
height: 400px;
height: 200px;
position: absolute;
top: 0;
left: 0;
Expand Down
2 changes: 1 addition & 1 deletion bin/materialize.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion css/ghpages-materialize.css

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions js/carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

return this.each(function() {

var images, item_width, offset, center, pressed, dim, count,
var images, item_width, item_height, offset, center, pressed, dim, count,
reference, referenceY, amplitude, target, velocity,
xform, frame, timestamp, ticker, dragged, vertical_dragged;
var $indicators = $('<ul class="indicators"></ul>');
Expand Down Expand Up @@ -59,6 +59,7 @@
offset = target = 0;
images = [];
item_width = view.find('.carousel-item').first().innerWidth();
item_height = view.find('.carousel-item').first().innerHeight();
dim = item_width * 2 + options.padding;

view.find('.carousel-item').each(function (i) {
Expand Down Expand Up @@ -137,7 +138,7 @@

if (!options.fullWidth) {
alignment = 'translateX(' + (view[0].clientWidth - item_width) / 2 + 'px) ';
alignment += 'translateY(' + (view[0].clientHeight - item_width) / 2 + 'px)';
alignment += 'translateY(' + (view[0].clientHeight - item_height) / 2 + 'px)';
} else {
alignment = 'translateX(0)';
}
Expand Down Expand Up @@ -392,6 +393,7 @@
$(window).on('resize.carousel', function() {
if (options.fullWidth) {
item_width = view.find('.carousel-item').first().innerWidth();
item_height = view.find('.carousel-item').first().innerHeight();
dim = item_width * 2 + options.padding;
offset = center * 2 * item_width;
target = offset;
Expand Down
2 changes: 1 addition & 1 deletion sass/components/_carousel.scss
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
.carousel-item {
display: none;
width: 200px;
height: 400px;
height: 200px;
position: absolute;
top: 0;
left: 0;
Expand Down

0 comments on commit bb5dd21

Please sign in to comment.