Skip to content

Commit a91eba1

Browse files
lincolnthreeihadeed
authored andcommitted
View scroll (Depends on PR#353) (#354)
* Support tabDragStart/tabDragStop events * Support passthrough NavController lifecycle events * Add option to disdable view scrolling on swipe
1 parent 65e38ff commit a91eba1

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

src/components/super-tabs-container.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ export class SuperTabsContainer implements AfterViewInit, OnDestroy {
3737
@Input()
3838
tabsCount = 0;
3939

40+
/**
41+
* Whether or not to scroll views when dragging
42+
* @type {number}
43+
*/
44+
@Input() scrollViews = true;
45+
4046
/**
4147
* Selected tab index
4248
* @type {number}
@@ -274,7 +280,7 @@ export class SuperTabsContainer implements AfterViewInit, OnDestroy {
274280

275281
this.containerPosition = positionX;
276282

277-
} else {
283+
} else if (this.scrollViews) {
278284

279285
if (positionX) {
280286
this.containerPosition = positionX;
@@ -287,7 +293,6 @@ export class SuperTabsContainer implements AfterViewInit, OnDestroy {
287293
this.containerPosition = Math.max(this.minPosX, Math.min(this.maxPosX, this.containerPosition));
288294

289295
this.rnd.setStyle(el, this.plt.Css.transform, `translate3d(${-1 * this.containerPosition}px, 0, 0)`);
290-
291296
}
292297
}
293298

src/components/super-tabs.ts

+21-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export interface SuperTabsConfig {
8383
[scrollTabs]="scrollTabs"
8484
[selectedTab]="selectedTabIndex"
8585
(tabSelect)="onToolbarTabSelect($event)"></super-tabs-toolbar>
86-
<super-tabs-container [config]="config" [tabsCount]="_tabs.length" [selectedTabIndex]="selectedTabIndex"
86+
<super-tabs-container [config]="config" [tabsCount]="_tabs.length" [selectedTabIndex]="selectedTabIndex" [scrollViews]="scrollViews"
8787
(tabSelect)="onContainerTabSelect($event)" (onDrag)="onDrag()" (onDragStart)="tabDragStart.emit()" (onDragEnd)="tabDragEnd.emit()">
8888
<ng-content></ng-content>
8989
</super-tabs-container>
@@ -181,6 +181,19 @@ export class SuperTabsComponent
181181
return this._scrollTabs;
182182
}
183183

184+
/**
185+
* Set to true to enable view scrolling
186+
* @param val
187+
*/
188+
@Input()
189+
set scrollViews (val: boolean) {
190+
this._scrollViews = typeof val !== 'boolean' || val === true;
191+
}
192+
193+
get scrollViews () {
194+
return this._scrollViews;
195+
}
196+
184197
/**
185198
* Tab buttons placement. Can be `top` or `bottom`.
186199
* @type {string}
@@ -229,6 +242,13 @@ export class SuperTabsComponent
229242
*/
230243
private _scrollTabs = false;
231244

245+
/**
246+
* Indicates whether the views should scroll
247+
* @type {boolean}
248+
* @private
249+
*/
250+
private _scrollViews = true;
251+
232252
/**
233253
* Selected tab index
234254
* @type {number}

0 commit comments

Comments
 (0)