UNPKG

@angular-mdc/web

Version:
22 lines (20 loc) 6.57 kB
/** * @license * Copyright (c) Dominic Carretto * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://github.com/trimox/angular-mdc-web/blob/master/LICENSE */ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("@angular/cdk/platform"),require("rxjs"),require("rxjs/operators"),require("@angular-mdc/web/base"),require("@angular-mdc/web/dom"),require("@material/tab-scroller")):"function"==typeof define&&define.amd?define("@angular-mdc/web/tab-scroller",["exports","@angular/core","@angular/cdk/platform","rxjs","rxjs/operators","@angular-mdc/web/base","@angular-mdc/web/dom","@material/tab-scroller"],e):e(((t=t||self).ng=t.ng||{},t.ng.web=t.ng.web||{},t.ng.web.tabScroller={}),t.ng.core,t.ng.cdk.platform,t.rxjs,t.rxjs.operators,t.ng.web.base,t.ng.web.dom,t.mdc.tabScroller)}(this,(function(t,e,n,r,o,l,i,a){"use strict"; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */var c=function(t,e){return(c=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};var s=["keydown","mousedown","pointerdown","touchstart","wheel"],u=function(t){function l(e,n,o){var l=t.call(this,o)||this;return l._ngZone=e,l._platform=n,l.elementRef=o,l._destroy=new r.Subject,l._align=null,l._scrollAreaEventsSubscription=null,l}return function(t,e){function n(){this.constructor=t}c(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}(l,t),Object.defineProperty(l.prototype,"align",{get:function(){return this._align},set:function(t){this.setAlign(t)},enumerable:!0,configurable:!0}),Object.defineProperty(l.prototype,"scrollAreaEvents",{get:function(){var t=this;return r.merge.apply(void 0,s.map((function(e){return r.fromEvent(t._getScrollArea(),e,{passive:n.supportsPassiveEventListeners()})})))},enumerable:!0,configurable:!0}),l.prototype.getDefaultFoundation=function(){var t=this,e={eventTargetMatchesSelector:function(t,e){return i.matches(t,e)},addClass:function(e){return t._getHostElement().classList.add(e)},removeClass:function(e){return t._getHostElement().classList.remove(e)},addScrollAreaClass:function(e){return t.area.nativeElement.classList.add(e)},setScrollAreaStyleProperty:function(e,n){return t.area.nativeElement.style.setProperty(e,n)},setScrollContentStyleProperty:function(e,n){return t.content.nativeElement.style.setProperty(e,n)},getScrollContentStyleValue:function(e){return t._platform.isBrowser?window.getComputedStyle(t.content.nativeElement).getPropertyValue(e):""},setScrollAreaScrollLeft:function(e){return t.area.nativeElement.scrollLeft=e},getScrollAreaScrollLeft:function(){return t.area.nativeElement.scrollLeft},getScrollContentOffsetWidth:function(){return t.content.nativeElement.offsetWidth},getScrollAreaOffsetWidth:function(){return t.area.nativeElement.offsetWidth},computeScrollAreaClientRect:function(){return t._platform.isBrowser?t.area.nativeElement.getBoundingClientRect():{}},computeScrollContentClientRect:function(){return t._platform.isBrowser?t.content.nativeElement.getBoundingClientRect():{}},computeHorizontalScrollbarHeight:function(){return t._platform.isBrowser?a.util.computeHorizontalScrollbarHeight(document):0}};return new a.MDCTabScrollerFoundation(e)},l.prototype.ngAfterViewInit=function(){this._foundation.init(),this._loadListeners()},l.prototype.ngOnDestroy=function(){this._destroy.next(),this._destroy.complete(),this._scrollAreaEventsSubscription&&this._scrollAreaEventsSubscription.unsubscribe()},l.prototype.setAlign=function(t){this._getHostElement().classList.remove("mdc-tab-scroller--align-"+this._align),this._align=t,t&&this._getHostElement().classList.add("mdc-tab-scroller--align-"+t)},l.prototype.getScrollPosition=function(){return this._platform.isBrowser?this._foundation.getScrollPosition():-1},l.prototype.getScrollContentWidth=function(){return this.content.nativeElement.offsetWidth},l.prototype.incrementScroll=function(t){if(!this._platform.isBrowser)return-1;this._foundation.incrementScroll(t)},l.prototype.scrollTo=function(t){this._foundation.scrollTo(t)},l.prototype._loadListeners=function(){var t=this;this._scrollAreaEventsSubscription=this.scrollAreaEvents.pipe().subscribe((function(){return t._foundation.handleInteraction()})),this._ngZone.runOutsideAngular((function(){return r.fromEvent(t._getScrollContent(),"transitionend").pipe(o.takeUntil(t._destroy),o.filter((function(e){return e.target===t._getScrollContent()}))).subscribe((function(e){return t._ngZone.run((function(){return t._foundation.handleTransitionEnd(e)}))}))}))},l.prototype._getScrollArea=function(){return this.area.nativeElement},l.prototype._getScrollContent=function(){return this.content.nativeElement},l.prototype._getHostElement=function(){return this.elementRef.nativeElement},l.decorators=[{type:e.Component,args:[{selector:"[mdcTabScroller], mdc-tab-scroller",exportAs:"mdcTabScroller",host:{class:"mdc-tab-scroller"},template:'\n <div #area class="mdc-tab-scroller__scroll-area">\n <div #content class="mdc-tab-scroller__scroll-content">\n <ng-content></ng-content>\n </div>\n </div>\n ',changeDetection:e.ChangeDetectionStrategy.OnPush,encapsulation:e.ViewEncapsulation.None}]}],l.ctorParameters=function(){return[{type:e.NgZone},{type:n.Platform},{type:e.ElementRef}]},l.propDecorators={align:[{type:e.Input}],area:[{type:e.ViewChild,args:["area",{static:!0}]}],content:[{type:e.ViewChild,args:["content",{static:!0}]}]},l}(l.MDCComponent),f=function(){function t(){}return t.decorators=[{type:e.NgModule,args:[{exports:[u],declarations:[u]}]}],t}();t.MdcTabScroller=u,t.MdcTabScrollerModule=f,Object.defineProperty(t,"__esModule",{value:!0})}));