Skip to content

Commit ba2a40c

Browse files
committed
feat(modal): On larger displays modals will be inset and centered, not full width/height, closes #783
1 parent c912832 commit ba2a40c

File tree

3 files changed

+66
-21
lines changed

3 files changed

+66
-21
lines changed

Diff for: js/ext/angular/src/service/ionicModal.js

+12-6
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ angular.module('ionic.service.modal', ['ionic.service.templateLoad', 'ionic.serv
8282
var self = this;
8383
var modalEl = angular.element(self.modalEl);
8484

85+
self.el.classList.remove('hide');
86+
8587
$document[0].body.classList.add('modal-open');
8688

8789
self._isShown = true;
@@ -97,13 +99,14 @@ angular.module('ionic.service.modal', ['ionic.service.templateLoad', 'ionic.serv
9799
$timeout(function(){
98100
modalEl.addClass('ng-enter-active');
99101
self.scope.$parent && self.scope.$parent.$broadcast('modal.shown');
102+
self.el.classList.add('active');
100103
}, 20);
101104

102105
self._deregisterBackButton = $ionicPlatform.registerBackButtonAction(function(){
103106
self.hide();
104107
}, 200);
105108

106-
ionic.views.Modal.prototype.show.call(this);
109+
ionic.views.Modal.prototype.show.call(self);
107110

108111
},
109112

@@ -113,9 +116,11 @@ angular.module('ionic.service.modal', ['ionic.service.templateLoad', 'ionic.serv
113116
* @description Hide this modal instance.
114117
*/
115118
hide: function() {
116-
this._isShown = false;
117-
var modalEl = angular.element(this.modalEl);
119+
var self = this;
120+
self._isShown = false;
121+
var modalEl = angular.element(self.modalEl);
118122

123+
self.el.classList.remove('active');
119124
modalEl.addClass('ng-leave');
120125

121126
$timeout(function(){
@@ -125,13 +130,14 @@ angular.module('ionic.service.modal', ['ionic.service.templateLoad', 'ionic.serv
125130

126131
$timeout(function(){
127132
$document[0].body.classList.remove('modal-open');
133+
self.el.classList.add('hide');
128134
}, 350);
129135

130-
ionic.views.Modal.prototype.hide.call(this);
136+
ionic.views.Modal.prototype.hide.call(self);
131137

132-
this.scope.$parent && this.scope.$parent.$broadcast('modal.hidden');
138+
self.scope.$parent && self.scope.$parent.$broadcast('modal.hidden');
133139

134-
this._deregisterBackButton && this._deregisterBackButton();
140+
self._deregisterBackButton && self._deregisterBackButton();
135141
},
136142

137143
/**

Diff for: scss/_modal.scss

+33-4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,21 @@
55
* Modals are independent windows that slide in from off-screen.
66
*/
77

8+
.modal-backdrop {
9+
@include transition(background-color 300ms ease-in-out);
10+
position: fixed;
11+
top: 0;
12+
left: 0;
13+
z-index: $z-index-modal;
14+
width: 100%;
15+
height: 100%;
16+
background-color: $modal-backdrop-bg-inactive;
17+
18+
&.active {
19+
background-color: $modal-backdrop-bg-active;
20+
}
21+
}
22+
823
.modal {
924
position: absolute;
1025
top: 0;
@@ -15,10 +30,24 @@
1530
width: 100%;
1631

1732
background-color: $modal-bg-color;
33+
}
1834

19-
// Active modal
20-
&.active {
21-
height: 100%;
35+
@media (min-width: $modal-inset-mode-break-point) {
36+
// inset mode is when the modal doesn't fill the entire
37+
// display but instead is centered within a large display
38+
.modal {
39+
top: $modal-inset-mode-top;
40+
right: $modal-inset-mode-right;
41+
bottom: $modal-inset-mode-bottom;
42+
left: $modal-inset-mode-left;
43+
overflow: visible;
44+
min-height: $modal-inset-mode-min-height;
45+
max-width: $modal-inset-mode-max-width;
46+
width: (100% - $modal-inset-mode-left - $modal-inset-mode-right);
47+
}
48+
49+
.modal.ng-leave-active {
50+
bottom: 0;
2251
}
2352
}
2453

@@ -28,4 +57,4 @@
2857
.modal {
2958
pointer-events: auto;
3059
}
31-
}
60+
}

Diff for: scss/_variables.scss

+21-11
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,16 @@ $split-pane-menu-border-color: #eee !default;
526526
// -------------------------------
527527

528528
$modal-bg-color: #fff !default;
529+
$modal-backdrop-bg-active: rgba(0,0,0,0.5) !default;
530+
$modal-backdrop-bg-inactive: rgba(0,0,0,0) !default;
531+
532+
$modal-inset-mode-break-point: 680px !default; // @media min-width
533+
$modal-inset-mode-top: 20% !default;
534+
$modal-inset-mode-right: 20% !default;
535+
$modal-inset-mode-bottom: 20% !default;
536+
$modal-inset-mode-left: 20% !default;
537+
$modal-inset-mode-min-height: 240px !default;
538+
$modal-inset-mode-max-width: 768px !default;
529539

530540

531541
// Grids
@@ -543,26 +553,26 @@ $grid-responsive-lg-break: 1023px !default; // smaller than landscape tab
543553
$sheet-bg-color: rgba(255, 255, 255, 0.6) !default;
544554
$sheet-opacity: 0.95 !default;
545555

546-
// Border radii for the action sheet button groups
547556
$sheet-border-radius: 3px 3px 3px 3px !default;
548557
$sheet-border-radius-top: 3px 3px 0px 0px !default;
549558
$sheet-border-radius-bottom: 0px 0px 3px 3px !default;
550559

560+
551561
// Popups
552562
// -------------------------------
553563

554-
$popup-backdrop-fadein-duration: 0.1s;
555-
$popup-width: 250px;
556-
$popup-enter-animation: superScaleIn;
557-
$popup-enter-animation-duration: 0.2s;
558-
$popup-leave-animation-duration: 0.1s;
564+
$popup-backdrop-fadein-duration: 0.1s !default;
565+
$popup-width: 250px !default;
566+
$popup-enter-animation: superScaleIn !default;
567+
$popup-enter-animation-duration: 0.2s !default;
568+
$popup-leave-animation-duration: 0.1s !default;
559569

560-
$popup-border-radius: 0px;
561-
$popup-background-color: rgba(255,255,255,0.9);
570+
$popup-border-radius: 0px !default;
571+
$popup-background-color: rgba(255,255,255,0.9) !default;
562572

563-
$popup-button-border-radius: 2px;
564-
$popup-button-line-height: 20px;
565-
$popup-button-min-height: 45px;
573+
$popup-button-border-radius: 2px !default;
574+
$popup-button-line-height: 20px !default;
575+
$popup-button-min-height: 45px !default;
566576

567577

568578
// Badges

0 commit comments

Comments
 (0)