UNPKG

bia-framework

Version:

Bia Framework to work with angular 2

77 lines 3.52 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; var core_1 = require("@angular/core"); var RippleEffect = (function () { function RippleEffect(element) { var _this = this; this.element = element; this.canAnimate = true; this.showEffect = function (event) { var newRipple = document.createElement("DIV"); var time = _this.rippleSize == "i" ? 500 : 290; if (_this.rippleMousePosition && event != null) { var pos = _this.getPosition(event); newRipple.setAttribute("style", "top:" + (pos.y - 12) + 'px;' + "left:" + (pos.x - 12) + 'px;'); } else newRipple.setAttribute("style", "top:" + (_this._el.clientTop) + 'px;' + "left:" + (_this._el.clientLeft) + 'px;'); newRipple.setAttribute("class", "ripple bg-color-" + _this.rippleColor + " size-" + _this.rippleSize); _this._el.appendChild(newRipple); setTimeout(function () { newRipple.remove(); }, time); }; this.getPosition = function (event) { return { x: event.layerX, y: event.layerY }; }; this.rippleColor = this.rippleColor || 'white'; this.rippleSize = this.rippleSize || 'i'; this.rippleMousePosition = this.rippleMousePosition || false; this._el = element.nativeElement; } RippleEffect.prototype.ngOnInit = function () { var _this = this; if (this.rippleReverseCommand != null) this.rippleReverseCommand.subscribe(function (str) { _this.showEffect(null); }); return undefined; }; __decorate([ core_1.Input(), __metadata('design:type', core_1.EventEmitter) ], RippleEffect.prototype, "rippleReverseCommand", void 0); __decorate([ core_1.Input(), __metadata('design:type', String) ], RippleEffect.prototype, "rippleColor", void 0); __decorate([ core_1.Input(), __metadata('design:type', String) ], RippleEffect.prototype, "rippleSize", void 0); __decorate([ core_1.Input(), __metadata('design:type', Boolean) ], RippleEffect.prototype, "rippleMousePosition", void 0); __decorate([ core_1.HostListener('click', ['$event']), __metadata('design:type', Object) ], RippleEffect.prototype, "showEffect", void 0); RippleEffect = __decorate([ core_1.Directive({ selector: '[ripple]', }), __metadata('design:paramtypes', [core_1.ElementRef]) ], RippleEffect); return RippleEffect; }()); exports.RippleEffect = RippleEffect; //# sourceMappingURL=RippleEffect.js.map