Skip to content

Commit 7b3aead

Browse files
author
Buck Ryan
committed
provide functions for calculating an element's width and height
1 parent 7aa79f8 commit 7b3aead

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/angular-gridster.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -752,14 +752,22 @@
752752
}
753753
};
754754

755+
this.calculateElementHeight = function() {
756+
return (this.sizeY * this.gridster.curRowHeight - this.gridster.margins[0]);
757+
}
758+
759+
this.calculateElementWidth = function() {
760+
return (this.sizeX * this.gridster.curColWidth - this.gridster.margins[1]);
761+
}
762+
755763
/**
756764
* Sets an elements height
757765
*/
758766
this.setElementSizeY = function() {
759767
if (this.gridster.isMobile && !this.gridster.saveGridItemCalculatedHeightInMobile) {
760768
this.$element.css('height', '');
761769
} else {
762-
this.$element.css('height', (this.sizeY * this.gridster.curRowHeight - this.gridster.margins[0]) + 'px');
770+
this.$element.css('height', this.calculateElementHeight() + 'px');
763771
}
764772
};
765773

@@ -770,7 +778,7 @@
770778
if (this.gridster.isMobile) {
771779
this.$element.css('width', '');
772780
} else {
773-
this.$element.css('width', (this.sizeX * this.gridster.curColWidth - this.gridster.margins[1]) + 'px');
781+
this.$element.css('width', this.calculateElementWidth() + 'px');
774782
}
775783
};
776784
})

0 commit comments

Comments
 (0)