Skip to content

Commit

Permalink
Fixes #43
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertPeek committed Aug 12, 2022
1 parent 8dca84b commit 378e68f
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 53 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ The attributes listed below are used in *components.json* to configure **Flip ca
No known limitations.

----------------------------
**Version number:** 4.2.0
**Version number:** 4.2.1
**Framework versions:** 5.8+
**Author / maintainer:** Deltanet with [contributors](https://github.com/deltanet/adapt-flipcard-audio/graphs/contributors)
**Accessibility support:** yes
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "adapt-flipcard-audio",
"version": "4.2.0",
"version": "4.2.1",
"framework": ">=5.8",
"homepage": "https://github.com/deltanet/adapt-flipcard-audio",
"issues": "https://github.com/deltanet/adapt-flipcard-audio/issues",
Expand Down
51 changes: 1 addition & 50 deletions js/flipcardView.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,61 +78,12 @@ class FlipcardView extends ComponentView {
if (Adapt.device.screenSize === 'large') {
const inRow = this.model.get('_inRow');
const itemWidth = 100 / inRow;

this.$('.flipcard-audio__item').css({
width: (itemWidth - 1) + '%'
});

this.setItemlayout();
this.$('.flipcard-audio__item').css({ width: (itemWidth - 1) + '%' });
} else {
this.$('.flipcard-audio__item').css({ 'width': '100%' });
}
}

setItemlayout() {
const columns = this.model.get('_inRow');
const itemLength = this.model.get('_items').length;
const $items = this.$('.flipcard-audio__item');
const itemRemainder = itemLength % columns;
let $item;
let itemToAlignIndex;

if (itemRemainder !== 0) {
if (itemRemainder === 1) {
$item = $items.eq(itemLength - 1);
this.centerItem($item);
} else {
itemToAlignIndex = itemLength - itemRemainder;
$item = $items.eq(itemToAlignIndex);
this.alignItem($item, itemRemainder);
}
}
}

centerItem(item) {
item.css({
float: 'none',
margin: 'auto'
});
}

alignItem(item, itemsToAlign) {
const columns = this.model.get('_inRow');
const itemWidth = 100 / columns;

if (Adapt.config.get('_defaultDirection') === 'rtl') {
let marginRight = itemWidth / 2;
item.css({
marginRight: marginRight + '%'
});
} else {
let marginLeft = itemWidth / 2;
item.css({
marginLeft: marginLeft + '%'
});
}
}

resizeHeights() {
const $items = this.$('.flipcard-audio__item');
const itemLength = this.model.get('_items').length;
Expand Down
2 changes: 1 addition & 1 deletion less/flipcard-audio.less
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
&__item {
position: relative;
display: inline-block;
margin-top: @item-margin * 4;
margin-top: 1%;
vertical-align: top;
margin-left: 0.5%;
margin-right: 0.5%;
Expand Down

0 comments on commit 378e68f

Please sign in to comment.