Skip to content

Commit b05fb5d

Browse files
author
Andrew Sullivan
committed
Merge branch 'feature/OwnCssUnits' of https://github.com/winfinit/angular-mapbox into winfinit-feature/OwnCssUnits
2 parents b841848 + 8c52f7a commit b05fb5d

3 files changed

Lines changed: 25 additions & 7 deletions

File tree

dist/angular-mapbox.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,18 @@
313313

314314
var mapWidth = attrs.width || 500;
315315
var mapHeight = attrs.height || 500;
316-
element.css('width', mapWidth + (/^[0-9]+$/.test(mapWidth)?'px':''));
317-
element.css('height', mapHeight + (/^[0-9]+$/.test(mapHeight)?'px':''));
316+
317+
if ( isNaN(mapWidth) ) {
318+
element.css('width', mapWidth);
319+
} else {
320+
element.css('width', mapWidth + 'px');
321+
}
322+
323+
if ( isNaN(mapHeight) ) {
324+
element.css('height', mapHeight);
325+
} else {
326+
element.css('height', mapHeight + 'px');
327+
}
318328

319329
scope.zoom = attrs.zoom || 12;
320330
if(attrs.lat && attrs.lng) {
@@ -381,7 +391,6 @@
381391
});
382392
})();
383393

384-
385394
(function() {
386395
'use strict';
387396

dist/angular-mapbox.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/directives/mapbox.directive.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,18 @@
3434

3535
var mapWidth = attrs.width || 500;
3636
var mapHeight = attrs.height || 500;
37-
element.css('width', mapWidth + (/^[0-9]+$/.test(mapWidth)?'px':''));
38-
element.css('height', mapHeight + (/^[0-9]+$/.test(mapHeight)?'px':''));
37+
38+
if ( isNaN(mapWidth) ) {
39+
element.css('width', mapWidth);
40+
} else {
41+
element.css('width', mapWidth + 'px');
42+
}
43+
44+
if ( isNaN(mapHeight) ) {
45+
element.css('height', mapHeight);
46+
} else {
47+
element.css('height', mapHeight + 'px');
48+
}
3949

4050
scope.zoom = attrs.zoom || 12;
4151
if(attrs.lat && attrs.lng) {
@@ -101,4 +111,3 @@
101111
};
102112
});
103113
})();
104-

0 commit comments

Comments
 (0)