Skip to content

Commit 490a06d

Browse files
manucorporatadamdbradley
authored andcommitted
feat(fab): update floating action buttons
1 parent 83d973b commit 490a06d

22 files changed

+703
-223
lines changed

src/components/button/button-fab.scss

Lines changed: 0 additions & 58 deletions
This file was deleted.

src/components/button/button.ios.scss

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -311,14 +311,6 @@ $button-ios-fab-border-radius: 50% !default;
311311
}
312312

313313

314-
// iOS FAB Button
315-
// --------------------------------------------------
316-
317-
.button-fab-ios {
318-
border-radius: $button-ios-fab-border-radius;
319-
}
320-
321-
322314
// Generate iOS Button Colors
323315
// --------------------------------------------------
324316

src/components/button/button.md.scss

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -394,23 +394,6 @@ $button-md-fab-box-shadow-activated: 0 5px 15px 0 rgba(0, 0, 0, .4),
394394
border-radius: $button-md-round-border-radius;
395395
}
396396

397-
398-
// Material Design FAB Button
399-
// --------------------------------------------------
400-
401-
.button-fab-md {
402-
border-radius: $button-md-fab-border-radius;
403-
box-shadow: $button-md-fab-box-shadow;
404-
405-
transition: box-shadow $button-md-transition-duration $button-md-transition-timing-function,
406-
background-color $button-md-transition-duration $button-md-transition-timing-function,
407-
color $button-md-transition-duration $button-md-transition-timing-function;
408-
}
409-
410-
.button-fab-md.activated {
411-
box-shadow: $button-md-fab-box-shadow-activated;
412-
}
413-
414397
.button-md [icon-only] {
415398
padding: 0;
416399
}

src/components/button/button.wp.scss

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -309,14 +309,6 @@ $button-wp-fab-border-radius: 50% !default;
309309
border-radius: $button-wp-round-border-radius;
310310
}
311311

312-
313-
// Windows FAB Button
314-
// --------------------------------------------------
315-
316-
.button-fab-wp {
317-
border-radius: $button-wp-fab-border-radius;
318-
}
319-
320312
.button-wp [icon-only] {
321313
padding: 0;
322314
}

src/components/button/test/fab/app-module.ts

Lines changed: 0 additions & 30 deletions
This file was deleted.

src/components/button/test/fab/e2e.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/components/button/test/fab/main.html

Lines changed: 0 additions & 25 deletions
This file was deleted.

src/components/content/content.scss

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,27 @@ ion-content.js-scroll > .scroll-content {
5757
}
5858

5959

60+
// Fixed Content (ion-fixed and ion-fab)
61+
// --------------------------------------------------
62+
63+
.fixed-content {
64+
position: absolute;
65+
top: 0;
66+
right: 0;
67+
bottom: 0;
68+
left: 0;
69+
display: block;
70+
}
71+
72+
[ion-fixed] {
73+
position: absolute;
74+
75+
z-index: $z-index-fixed-content;
76+
77+
transform: translateZ(0);
78+
}
79+
80+
6081
// Content Padding
6182
// --------------------------------------------------
6283

@@ -151,15 +172,3 @@ ion-content.js-scroll > .scroll-content {
151172
margin-left: $content-margin;
152173
}
153174
}
154-
155-
156-
// Content Fixed
157-
// --------------------------------------------------
158-
159-
ion-fixed {
160-
position: absolute;
161-
162-
z-index: $z-index-fixed-content;
163-
164-
transform: translateZ(0);
165-
}

src/components/content/content.ts

Lines changed: 60 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,12 @@ import { isTrueProperty } from '../../util/util';
103103
@Component({
104104
selector: 'ion-content',
105105
template:
106+
'<div class="fixed-content">' +
107+
'<ng-content select="[ion-fixed],ion-fab"></ng-content>' +
108+
'</div>' +
106109
'<div class="scroll-content">' +
107110
'<ng-content></ng-content>' +
108111
'</div>' +
109-
'<ng-content select="ion-fixed"></ng-content>' +
110112
'<ng-content select="ion-refresher"></ng-content>',
111113
host: {
112114
'[class.statusbar-padding]': '_sbPadding'
@@ -136,6 +138,11 @@ export class Content extends Ion {
136138
*/
137139
_scrollEle: HTMLElement;
138140

141+
/*
142+
* @private
143+
*/
144+
_fixedEle: HTMLElement;
145+
139146
/**
140147
* A number representing how many pixels the top of the content has been
141148
* adjusted, which could be by either padding or margin.
@@ -175,7 +182,8 @@ export class Content extends Ion {
175182
* @private
176183
*/
177184
ngOnInit() {
178-
this._scrollEle = this._elementRef.nativeElement.children[0];
185+
this._fixedEle = this._elementRef.nativeElement.children[0];
186+
this._scrollEle = this._elementRef.nativeElement.children[1];
179187

180188
this._zone.runOutsideAngular(() => {
181189
this._scroll = new ScrollView(this._scrollEle);
@@ -530,63 +538,61 @@ export class Content extends Ion {
530538
* DOM WRITE
531539
*/
532540
writeDimensions() {
533-
let newVal: number;
534-
let scrollEle = this._scrollEle;
541+
let scrollEle = this._scrollEle as any;
542+
if (!scrollEle) {
543+
return;
544+
}
535545

536-
if (!scrollEle) return;
546+
let fixedEle = this._fixedEle;
547+
if (!fixedEle) {
548+
return;
549+
}
537550

538-
// only write when it has changed
539-
if (this._fullscreen) {
540-
// adjust the content with padding, allowing content to scroll under headers/footers
541-
// however, on iOS you cannot control the margins of the scrollbar (last tested iOS9.2)
542-
// only add inline padding styles if the computed padding value, which would
543-
// have come from the app's css, is different than the new padding value
551+
// Toolbar height
552+
let contentTop = this._headerHeight;
553+
let contentBottom = this._footerHeight;
544554

545-
newVal = this._headerHeight + this._paddingTop;
546-
if (this._tabsPlacement === 'top') {
547-
newVal += this._tabbarHeight;
548-
}
549-
if (newVal !== this.contentTop) {
550-
scrollEle.style.paddingTop = (newVal > 0 ? newVal + 'px' : '');
551-
this.contentTop = newVal;
552-
}
555+
// Tabs height
556+
if (this._tabsPlacement === 'top') {
557+
contentTop += this._tabbarHeight;
553558

554-
newVal = this._footerHeight + this._paddingBottom;
555-
if (this._tabsPlacement === 'bottom') {
556-
newVal += this._tabbarHeight;
559+
} else if (this._tabsPlacement === 'bottom') {
560+
contentBottom += this._tabbarHeight;
557561

558-
if (newVal > 0 && this._footerEle) {
559-
this._footerEle.style.bottom = (newVal - this._footerHeight - this._paddingBottom) + 'px';
560-
}
561-
}
562-
if (newVal !== this.contentBottom) {
563-
scrollEle.style.paddingBottom = (newVal > 0 ? newVal + 'px' : '');
564-
this.contentBottom = newVal;
562+
// Update footer position
563+
if (contentBottom > 0 && this._footerEle) {
564+
this._footerEle.style.bottom = cssFormat(contentBottom - this._footerHeight);
565565
}
566+
}
566567

567-
} else {
568-
// adjust the content with margins
569-
newVal = this._headerHeight;
570-
if (this._tabsPlacement === 'top') {
571-
newVal += this._tabbarHeight;
572-
}
573-
if (newVal !== this.contentTop) {
574-
scrollEle.style.marginTop = (newVal > 0 ? newVal + 'px' : '');
575-
this.contentTop = newVal;
576-
}
568+
// Handle fullscreen viewport (padding vs margin)
569+
let topProperty = 'marginTop';
570+
let bottomProperty = 'marginBottom';
571+
let fixedTop: number = contentTop;
572+
let fixedBottom: number = contentBottom;
573+
if (this._fullscreen) {
574+
// adjust the content with padding, allowing content to scroll under headers/footers
575+
// however, on iOS you cannot control the margins of the scrollbar (last tested iOS9.2)
576+
// only add inline padding styles if the computed padding value, which would
577+
// have come from the app's css, is different than the new padding value
578+
contentTop += this._paddingTop;
579+
contentBottom += this._paddingBottom;
580+
topProperty = 'paddingTop';
581+
bottomProperty = 'paddingBottom';
582+
}
577583

578-
newVal = this._footerHeight;
579-
if (this._tabsPlacement === 'bottom') {
580-
newVal += this._tabbarHeight;
581-
}
582-
if (newVal !== this.contentBottom) {
583-
scrollEle.style.marginBottom = (newVal > 0 ? newVal + 'px' : '');
584-
this.contentBottom = newVal;
584+
// Only update top margin if value changed
585+
if (contentTop !== this.contentTop) {
586+
scrollEle.style[topProperty] = cssFormat(contentTop);
587+
fixedEle.style.marginTop = cssFormat(fixedTop);
588+
this.contentTop = contentTop;
589+
}
585590

586-
if (newVal > 0 && this._footerEle) {
587-
this._footerEle.style.bottom = (newVal - this._footerHeight) + 'px';
588-
}
589-
}
591+
// Only update bottom margin if value changed
592+
if (contentBottom !== this.contentBottom) {
593+
scrollEle.style[bottomProperty] = cssFormat(contentBottom);
594+
fixedEle.style.marginBottom = cssFormat(fixedBottom);
595+
this.contentBottom = contentBottom;
590596
}
591597

592598

@@ -606,3 +612,7 @@ export class Content extends Ion {
606612
function parsePxUnit(val: string): number {
607613
return (val.indexOf('px') > 0) ? parseInt(val, 10) : 0;
608614
}
615+
616+
function cssFormat(val: number): string {
617+
return (val > 0 ? val + 'px' : '');
618+
}

0 commit comments

Comments
 (0)