mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
fix(collectionRepeat): parse collection-item-height/width to int
Closes #2633.
This commit is contained in:
8
js/angular/directive/collectionRepeat.js
vendored
8
js/angular/directive/collectionRepeat.js
vendored
@@ -170,16 +170,16 @@ function($collectionRepeatManager, $collectionDataSource, $parse) {
|
||||
var heightGetter = function(scope, locals) {
|
||||
var result = heightParsed(scope, locals);
|
||||
if (isString(result) && result.indexOf('%') > -1) {
|
||||
return Math.floor(parseInt(result, 10) / 100 * scrollView.__clientHeight);
|
||||
return Math.floor(parseInt(result) / 100 * scrollView.__clientHeight);
|
||||
}
|
||||
return result;
|
||||
return parseInt(result);
|
||||
};
|
||||
var widthGetter = function(scope, locals) {
|
||||
var result = widthParsed(scope, locals);
|
||||
if (isString(result) && result.indexOf('%') > -1) {
|
||||
return Math.floor(parseInt(result, 10) / 100 * scrollView.__clientWidth);
|
||||
return Math.floor(parseInt(result) / 100 * scrollView.__clientWidth);
|
||||
}
|
||||
return result;
|
||||
return parseInt(result);
|
||||
};
|
||||
|
||||
var match = $attr.collectionRepeat.match(/^\s*([\s\S]+?)\s+in\s+([\s\S]+?)(?:\s+track\s+by\s+([\s\S]+?))?\s*$/);
|
||||
|
||||
@@ -71,8 +71,8 @@ describe('collectionRepeat directive', function() {
|
||||
});
|
||||
|
||||
describe('widthGetter & heightGetter', function() {
|
||||
it('should work with given amounts', function() {
|
||||
var el = setup('collection-repeat="a in b" collection-item-height="5" collection-item-width="10"');
|
||||
it('should work with given amounts parsed to int', function() {
|
||||
var el = setup('collection-repeat="a in b" collection-item-height="\'5\'" collection-item-width="\'10\'"');
|
||||
expect(dataSource.options.heightGetter()).toBe(5);
|
||||
expect(dataSource.options.widthGetter()).toBe(10);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user