diff --git a/_examples/storyline-tracker/app/core/toast/toast.component.css b/_examples/storyline-tracker/app/core/toast/toast.component.css index c20721b9..8e2eed47 100644 --- a/_examples/storyline-tracker/app/core/toast/toast.component.css +++ b/_examples/storyline-tracker/app/core/toast/toast.component.css @@ -1,4 +1,4 @@ -.toast-container { +:host { /*-webkit-transition-property: opacity, bottom, left, right, width, margin, border-radius; transition-property: opacity, bottom, left, right, width, margin, border-radius; -webkit-transition-duration: 1.0s; @@ -9,7 +9,6 @@ right: 0; bottom: 0; left: 0; - overflow: scroll; background: rgba(0, 0, 0, 0.4); z-index: 9999; opacity: 0; @@ -19,12 +18,11 @@ transition: opacity 400ms ease-in; } -.toast-container > * { +:host > * { text-align: center; } .toast-card { - width: 100%; z-index: 1; padding: 2px; position: relative; diff --git a/_examples/storyline-tracker/app/core/toast/toast.component.html b/_examples/storyline-tracker/app/core/toast/toast.component.html index 3e9ea179..0058807d 100644 --- a/_examples/storyline-tracker/app/core/toast/toast.component.html +++ b/_examples/storyline-tracker/app/core/toast/toast.component.html @@ -1,6 +1,4 @@ -
-
-
{{title}}
-

{{message}}

-
+
+
{{title}}
+

{{message}}

diff --git a/_examples/storyline-tracker/app/core/toast/toast.component.ts b/_examples/storyline-tracker/app/core/toast/toast.component.ts index 514cd456..d1028af4 100644 --- a/_examples/storyline-tracker/app/core/toast/toast.component.ts +++ b/_examples/storyline-tracker/app/core/toast/toast.component.ts @@ -1,28 +1,28 @@ -import { Component, OnDestroy, OnInit } from '@angular/core'; +import { Component, OnDestroy, ElementRef, Renderer } from '@angular/core'; import { ToastService } from './toast.service'; - -import { Subscription } from 'rxjs/Subscription' +import { Subscription } from 'rxjs/Subscription'; @Component({ moduleId: module.id, selector: 'story-toast', - templateUrl: './toast.component.html', + templateUrl: './toast.component.html', styleUrls: ['./toast.component.css'] }) -export class ToastComponent implements OnDestroy, OnInit { +export class ToastComponent implements OnDestroy { private defaults = { title: '', message: 'May the Force be with You' }; - private toastElement: any; private toastSubscription: Subscription; title: string; message: string; - constructor(private toastService: ToastService) { + constructor(private toastService: ToastService, + private renderer: Renderer, + private elementRef: ElementRef) { this.toastSubscription = this.toastService.toastState.subscribe((toastMessage) => { - console.log(`activiting toast: ${toastMessage.message}`) + console.log(`activiting toast: ${toastMessage.message}`); this.activate(toastMessage.message); }); } @@ -33,24 +33,20 @@ export class ToastComponent implements OnDestroy, OnInit { this.show(); } - ngOnInit() { - this.toastElement = document.getElementById('toast'); - } - ngOnDestroy() { this.toastSubscription.unsubscribe(); } private show() { console.log(this.message); - this.toastElement.style.opacity = 1; - this.toastElement.style.zIndex = 9999; + this.renderer.setElementStyle(this.elementRef.nativeElement, 'opacity', '1'); + this.renderer.setElementStyle(this.elementRef.nativeElement, 'zIndex', '9999'); window.setTimeout(() => this.hide(), 2500); } private hide() { - this.toastElement.style.opacity = 0; - window.setTimeout(() => this.toastElement.style.zIndex = 0, 400); + this.renderer.setElementStyle(this.elementRef.nativeElement, 'opacity', '0'); + window.setTimeout(() => this.renderer.setElementStyle(this.elementRef.nativeElement, 'zIndex', '0'), 400); } } diff --git a/_examples/storyline-tracker/plnkr.no-link.html b/_examples/storyline-tracker/plnkr.no-link.html index 358596e3..0c2af51a 100644 --- a/_examples/storyline-tracker/plnkr.no-link.html +++ b/_examples/storyline-tracker/plnkr.no-link.html @@ -1167,31 +1167,31 @@ Copyright 2016 JohnPapa.net, LLC. All Rights Reserved. Use of this source code is governed by an MIT-style license that can be found in the LICENSE file at http://bit.ly/l1cense -*/">