feat(icon): lazy loading can be disabled

This commit is contained in:
Manu Mtz.-Almeida
2018-07-24 01:13:44 +02:00
parent a15a2f0f89
commit c635b65d75
3 changed files with 38 additions and 4 deletions
+20
View File
@@ -34,6 +34,9 @@ declare global {
* Specifies the label to use for accessibility. Defaults to the icon name.
*/
'ariaLabel': string;
/**
* The color to use for the background of the item.
*/
'color': string;
/**
* A combination of both `name` and `src`. If a `src` url is detected it will set the `src` property. Otherwise it assumes it's a built-in named SVG and set the `name` property.
@@ -43,10 +46,17 @@ declare global {
* Specifies which icon to use on `ios` mode.
*/
'ios': string;
/**
* If enabled, ion-icon will be loaded lazily when it's visible in the viewport. Default, `true`.
*/
'lazy': boolean;
/**
* Specifies which icon to use on `md` mode.
*/
'md': string;
/**
* The mode determines which platform styles to use. Possible values are: `"ios"` or `"md"`.
*/
'mode': 'ios' | 'md';
/**
* Specifies which icon to use from the built-in set of icons.
@@ -86,6 +96,9 @@ declare global {
* Specifies the label to use for accessibility. Defaults to the icon name.
*/
'ariaLabel'?: string;
/**
* The color to use for the background of the item.
*/
'color'?: string;
/**
* A combination of both `name` and `src`. If a `src` url is detected it will set the `src` property. Otherwise it assumes it's a built-in named SVG and set the `name` property.
@@ -95,10 +108,17 @@ declare global {
* Specifies which icon to use on `ios` mode.
*/
'ios'?: string;
/**
* If enabled, ion-icon will be loaded lazily when it's visible in the viewport. Default, `true`.
*/
'lazy'?: boolean;
/**
* Specifies which icon to use on `md` mode.
*/
'md'?: string;
/**
* The mode determines which platform styles to use. Possible values are: `"ios"` or `"md"`.
*/
'mode'?: 'ios' | 'md';
/**
* Specifies which icon to use from the built-in set of icons.
+16 -2
View File
@@ -20,9 +20,17 @@ export class Icon {
@Prop({ context: 'document' }) doc!: Document;
@Prop({ context: 'window' }) win: any;
@Prop() mode?: 'ios' | 'md';
/**
* The color to use for the background of the item.
*/
@Prop() color?: string;
/**
* The mode determines which platform styles to use.
* Possible values are: `"ios"` or `"md"`.
*/
@Prop() mode?: 'ios' | 'md';
/**
* Specifies the label to use for accessibility. Defaults to the icon name.
*/
@@ -62,6 +70,12 @@ export class Icon {
@Prop() size?: string;
/**
* If enabled, ion-icon will be loaded lazily when it's visible in the viewport.
* Default, `true`.
*/
@Prop() lazy = true;
componentWillLoad() {
// purposely do not return the promise here because loading
// the svg file should not hold up loading the app
@@ -81,7 +95,7 @@ export class Icon {
waitUntilVisible(el: HTMLElement, rootMargin: string, cb: Function) {
if (this.win && this.win.IntersectionObserver) {
if (this.lazy && this.win && this.win.IntersectionObserver) {
const io = this.io = new this.win.IntersectionObserver((data: IntersectionObserverEntry[]) => {
if (data[0].isIntersecting) {
io.disconnect();
@@ -9,12 +9,12 @@ import content from './content';
styleUrl: 'usage-page.scss'
})
export class UsagePage {
@Prop({ context: 'queue'}) queue: QueueApi;
@Prop({ context: 'queue'}) queue!: QueueApi;
@State() exampleType: string = 'md';
@State() exampleIcon: string = 'heart';
@Prop() match: MatchResults;
@Prop() match?: MatchResults;
@Prop() data: any;
componentWillLoad() {