From 3921cf166a52cf2126f6261bf24fa9de672cb4c5 Mon Sep 17 00:00:00 2001 From: Sergey Akopkokhyants Date: Wed, 6 Apr 2016 11:08:55 +0200 Subject: [PATCH] fix($browser): Fixed issue: The loading bar still invisible after set the progress value --- bundles/ng2-slim-loading-bar.js | 3 +++ bundles/ng2-slim-loading-bar.min.js | 2 +- src/service.ts | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/bundles/ng2-slim-loading-bar.js b/bundles/ng2-slim-loading-bar.js index 7a65ccb..8f9102a 100644 --- a/bundles/ng2-slim-loading-bar.js +++ b/bundles/ng2-slim-loading-bar.js @@ -130,6 +130,9 @@ System.registerDynamic("src/service", ["angular2/core", "angular2/src/facade/lan }, set: function(value) { if (lang_1.isPresent(value)) { + if (value > 0) { + this.visible = true; + } this._progress = value; this.emitEvent(new SlimLoadingBarEvent(SlimLoadingBarEventType.PROGRESS, this._progress)); } diff --git a/bundles/ng2-slim-loading-bar.min.js b/bundles/ng2-slim-loading-bar.min.js index 10c5838..df95624 100644 --- a/bundles/ng2-slim-loading-bar.min.js +++ b/bundles/ng2-slim-loading-bar.min.js @@ -1,2 +1,2 @@ -System.registerDynamic("src/component",["angular2/core","angular2/src/facade/lang","angular2/common","./service"],!0,function(e,t,r){var i=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,s=3>o?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(3>o?n(s):o>3?n(t,r,s):n(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},n=this&&this.__metadata||function(e,t){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(e,t):void 0},o=e("angular2/core"),s=e("angular2/src/facade/lang"),a=e("angular2/common"),c=e("./service"),l=function(){function e(e){this.service=e,this._progress="0%",this.color="firebrick",this.height="2px",this.show=!0}return Object.defineProperty(e.prototype,"progress",{get:function(){return this._progress},set:function(e){s.isPresent(e)&&(this._progress=e+"%")},enumerable:!0,configurable:!0}),e.prototype.ngOnInit=function(){var e=this;this.service.observable.subscribe(function(t){t.type===c.SlimLoadingBarEventType.PROGRESS?e.progress=t.value:t.type===c.SlimLoadingBarEventType.COLOR?e.color=t.value:t.type===c.SlimLoadingBarEventType.HEIGHT?e.height=t.value:t.type===c.SlimLoadingBarEventType.VISIBLE&&(e.show=t.value)})},i([o.Input(),n("design:type",String),n("design:paramtypes",[String])],e.prototype,"progress",null),i([o.Input(),n("design:type",String)],e.prototype,"color",void 0),i([o.Input(),n("design:type",String)],e.prototype,"height",void 0),i([o.Input(),n("design:type",Boolean)],e.prototype,"show",void 0),e=i([o.Component({selector:"ng2-slim-loading-bar",directives:[a.CORE_DIRECTIVES],template:'\n
\n
\n
'}),n("design:paramtypes",[c.SlimLoadingBarService])],e)}();return t.SlimLoadingBar=l,r.exports}),System.registerDynamic("src/service",["angular2/core","angular2/src/facade/lang","rxjs/Observable"],!0,function(e,t,r){var i=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,s=3>o?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(3>o?n(s):o>3?n(t,r,s):n(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},n=this&&this.__metadata||function(e,t){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(e,t):void 0},o=e("angular2/core"),s=e("angular2/src/facade/lang"),a=e("rxjs/Observable");!function(e){e[e.PROGRESS=0]="PROGRESS",e[e.HEIGHT=1]="HEIGHT",e[e.COLOR=2]="COLOR",e[e.VISIBLE=3]="VISIBLE"}(t.SlimLoadingBarEventType||(t.SlimLoadingBarEventType={}));var c=t.SlimLoadingBarEventType,l=function(){function e(e,t){this.type=e,this.value=t}return e}();t.SlimLoadingBarEvent=l;var p=function(){function e(){var e=this;this._progress=0,this._height="2px",this._color="firebrick",this._visible=!0,this._intervalCounterId=0,this.interval=500,this.observable=new a.Observable(function(t){e.subscriber=t})}return Object.defineProperty(e.prototype,"progress",{get:function(){return this._progress},set:function(e){s.isPresent(e)&&(this._progress=e,this.emitEvent(new l(c.PROGRESS,this._progress)))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"height",{get:function(){return this._height},set:function(e){s.isPresent(e)&&(this._height=e,this.emitEvent(new l(c.HEIGHT,this._height)))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"color",{get:function(){return this._color},set:function(e){s.isPresent(e)&&(this._color=e,this.emitEvent(new l(c.COLOR,this._color)))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"visible",{get:function(){return this._visible},set:function(e){s.isPresent(e)&&(this._visible=e,this.emitEvent(new l(c.VISIBLE,this._visible)))},enumerable:!0,configurable:!0}),e.prototype.emitEvent=function(e){try{this.subscriber.next(e)}catch(t){console.log(t),console.log("!!! Suggestion: Seems you forget add into your html?")}},e.prototype.start=function(e){var t=this;void 0===e&&(e=null),this.stop(),this.visible=!0,this._intervalCounterId=setInterval(function(){t.progress++,100===t.progress&&t.complete()},this.interval)},e.prototype.stop=function(){this._intervalCounterId&&(clearInterval(this._intervalCounterId),this._intervalCounterId=null)},e.prototype.reset=function(){this.stop(),this.progress=0},e.prototype.complete=function(){var e=this;this.progress=100,this.stop(),setTimeout(function(){e.visible=!1,setTimeout(function(){e.progress=0},250)},250)},e=i([o.Injectable(),n("design:paramtypes",[])],e)}();return t.SlimLoadingBarService=p,r.exports}),System.registerDynamic("ng2-slim-loading-bar",["./src/component","./src/service"],!0,function(e,t,r){"use strict";function i(e){for(var r in e)t.hasOwnProperty(r)||(t[r]=e[r])}var n=e("./src/component"),o=e("./src/service");return i(e("./src/component")),i(e("./src/service")),Object.defineProperty(t,"__esModule",{value:!0}),t["default"]={providers:[o.SlimLoadingBarService],directives:[n.SlimLoadingBar]},r.exports}); +System.registerDynamic("src/component",["angular2/core","angular2/src/facade/lang","angular2/common","./service"],!0,function(e,t,r){var i=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,s=3>o?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(3>o?n(s):o>3?n(t,r,s):n(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},n=this&&this.__metadata||function(e,t){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(e,t):void 0},o=e("angular2/core"),s=e("angular2/src/facade/lang"),a=e("angular2/common"),c=e("./service"),l=function(){function e(e){this.service=e,this._progress="0%",this.color="firebrick",this.height="2px",this.show=!0}return Object.defineProperty(e.prototype,"progress",{get:function(){return this._progress},set:function(e){s.isPresent(e)&&(this._progress=e+"%")},enumerable:!0,configurable:!0}),e.prototype.ngOnInit=function(){var e=this;this.service.observable.subscribe(function(t){t.type===c.SlimLoadingBarEventType.PROGRESS?e.progress=t.value:t.type===c.SlimLoadingBarEventType.COLOR?e.color=t.value:t.type===c.SlimLoadingBarEventType.HEIGHT?e.height=t.value:t.type===c.SlimLoadingBarEventType.VISIBLE&&(e.show=t.value)})},i([o.Input(),n("design:type",String),n("design:paramtypes",[String])],e.prototype,"progress",null),i([o.Input(),n("design:type",String)],e.prototype,"color",void 0),i([o.Input(),n("design:type",String)],e.prototype,"height",void 0),i([o.Input(),n("design:type",Boolean)],e.prototype,"show",void 0),e=i([o.Component({selector:"ng2-slim-loading-bar",directives:[a.CORE_DIRECTIVES],template:'\n
\n
\n
'}),n("design:paramtypes",[c.SlimLoadingBarService])],e)}();return t.SlimLoadingBar=l,r.exports}),System.registerDynamic("src/service",["angular2/core","angular2/src/facade/lang","rxjs/Observable"],!0,function(e,t,r){var i=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,s=3>o?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(3>o?n(s):o>3?n(t,r,s):n(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},n=this&&this.__metadata||function(e,t){return"object"==typeof Reflect&&"function"==typeof Reflect.metadata?Reflect.metadata(e,t):void 0},o=e("angular2/core"),s=e("angular2/src/facade/lang"),a=e("rxjs/Observable");!function(e){e[e.PROGRESS=0]="PROGRESS",e[e.HEIGHT=1]="HEIGHT",e[e.COLOR=2]="COLOR",e[e.VISIBLE=3]="VISIBLE"}(t.SlimLoadingBarEventType||(t.SlimLoadingBarEventType={}));var c=t.SlimLoadingBarEventType,l=function(){function e(e,t){this.type=e,this.value=t}return e}();t.SlimLoadingBarEvent=l;var p=function(){function e(){var e=this;this._progress=0,this._height="2px",this._color="firebrick",this._visible=!0,this._intervalCounterId=0,this.interval=500,this.observable=new a.Observable(function(t){e.subscriber=t})}return Object.defineProperty(e.prototype,"progress",{get:function(){return this._progress},set:function(e){s.isPresent(e)&&(e>0&&(this.visible=!0),this._progress=e,this.emitEvent(new l(c.PROGRESS,this._progress)))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"height",{get:function(){return this._height},set:function(e){s.isPresent(e)&&(this._height=e,this.emitEvent(new l(c.HEIGHT,this._height)))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"color",{get:function(){return this._color},set:function(e){s.isPresent(e)&&(this._color=e,this.emitEvent(new l(c.COLOR,this._color)))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"visible",{get:function(){return this._visible},set:function(e){s.isPresent(e)&&(this._visible=e,this.emitEvent(new l(c.VISIBLE,this._visible)))},enumerable:!0,configurable:!0}),e.prototype.emitEvent=function(e){try{this.subscriber.next(e)}catch(t){console.log(t),console.log("!!! Suggestion: Seems you forget add into your html?")}},e.prototype.start=function(e){var t=this;void 0===e&&(e=null),this.stop(),this.visible=!0,this._intervalCounterId=setInterval(function(){t.progress++,100===t.progress&&t.complete()},this.interval)},e.prototype.stop=function(){this._intervalCounterId&&(clearInterval(this._intervalCounterId),this._intervalCounterId=null)},e.prototype.reset=function(){this.stop(),this.progress=0},e.prototype.complete=function(){var e=this;this.progress=100,this.stop(),setTimeout(function(){e.visible=!1,setTimeout(function(){e.progress=0},250)},250)},e=i([o.Injectable(),n("design:paramtypes",[])],e)}();return t.SlimLoadingBarService=p,r.exports}),System.registerDynamic("ng2-slim-loading-bar",["./src/component","./src/service"],!0,function(e,t,r){"use strict";function i(e){for(var r in e)t.hasOwnProperty(r)||(t[r]=e[r])}var n=e("./src/component"),o=e("./src/service");return i(e("./src/component")),i(e("./src/service")),Object.defineProperty(t,"__esModule",{value:!0}),t["default"]={providers:[o.SlimLoadingBarService],directives:[n.SlimLoadingBar]},r.exports}); //# sourceMappingURL=bundles/ng2-slim-loading-bar.min.js.map \ No newline at end of file diff --git a/src/service.ts b/src/service.ts index 7a92281..afd2028 100644 --- a/src/service.ts +++ b/src/service.ts @@ -45,6 +45,9 @@ export class SlimLoadingBarService { set progress(value:number) { if (isPresent(value)) { + if (value > 0) { + this.visible = true; + } this._progress = value; this.emitEvent(new SlimLoadingBarEvent(SlimLoadingBarEventType.PROGRESS, this._progress)); }