Fixed #360 - dynamic slidebox sizing

This commit is contained in:
Max Lynch
2014-01-10 12:50:56 -06:00
parent 621d42e03b
commit c9bc2e2eea
7 changed files with 172 additions and 7 deletions

View File

@@ -29,6 +29,7 @@ angular.module('ionic.service', [
// UI specific services and delegates
angular.module('ionic.ui.service', [
'ionic.ui.service.scrollDelegate',
'ionic.ui.service.slideBoxDelegate',
]);
angular.module('ionic.ui', [
@@ -121,6 +122,36 @@ angular.module('ionic.ui.service.scrollDelegate', [])
};
}]);
})(ionic);
;
(function() {
'use strict';
angular.module('ionic.ui.service.slideBoxDelegate', [])
.factory('SlideBoxDelegate', ['$rootScope', '$timeout', function($rootScope, $timeout) {
return {
/**
* Trigger a slidebox to update and resize itself
*/
update: function(animate) {
$rootScope.$broadcast('slideBox.update');
},
register: function($scope, $element) {
$scope.$parent.$on('slideBox.update', function(e) {
if(e.defaultPrevented) {
return;
}
$timeout(function() {
$scope.$parent.slideBox.setup();
});
e.preventDefault();
});
}
};
}]);
})(ionic);
;
angular.module('ionic.service.actionSheet', ['ionic.service.templateLoad', 'ionic.ui.actionSheet', 'ngAnimate'])
@@ -2317,7 +2348,7 @@ angular.module('ionic.ui.slideBox', [])
* The internal controller for the slide box controller.
*/
.directive('slideBox', ['$timeout', '$compile', function($timeout, $compile) {
.directive('slideBox', ['$timeout', '$compile', 'SlideBoxDelegate', function($timeout, $compile, SlideBoxDelegate) {
return {
restrict: 'E',
replace: true,
@@ -2377,6 +2408,8 @@ angular.module('ionic.ui.slideBox', [])
$scope.$parent.slideBox = slider;
SlideBoxDelegate.register($scope, $element);
this.getNumSlides = function() {
return slider.getNumSlides();
};