Skip to content

Commit 1953ee9

Browse files
eduardoRothihadeed
authored andcommitted
feat(): allow elements inside tabs to be dragged/scrolled before tabs swipe event is triggered (#243)
* Allow elements to scroll inside tabs * Allow elements to scroll inside tabs * Allow elements to scroll inside tabs * Allow element scroll
1 parent dcb5217 commit 1953ee9

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ _(optional)_ Advanced configuration.
131131
Param | Description | Default
132132
--- | --- | ---
133133
`dragThreshold` | The number of pixels that the user must swipe through before the drag event triggers. | `20`
134+
`allowElementScroll` | Allow elements inside tabs to be dragged before triggering the tab swipe event. | `false`
134135
`maxDragAngle` | The maximum angle that the user can drag at for the drag event to trigger. | `40`
135136
`transitionEase` | The transition timing function to use in animations. | `'cubic-bezier(0.35, 0, 0.25, 1)'`
136137
`transitionDuration` | The duration of animations in milliseconds. | `300`

src/components/super-tabs.ts

+11
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ export interface SuperTabsConfig {
2727
* Defaults to 20
2828
*/
2929
dragThreshold?: number;
30+
/**
31+
* Allows elements inside tabs to be dragged, defaults to false
32+
*/
33+
allowElementScroll?: boolean;
3034
/**
3135
* Defaults to ease-in-out
3236
*/
@@ -287,6 +291,7 @@ export class SuperTabs implements OnInit, AfterContentInit, AfterViewInit, OnDes
287291
ngOnInit() {
288292
const defaultConfig: SuperTabsConfig = {
289293
dragThreshold: 10,
294+
allowElementScroll: false,
290295
maxDragAngle: 40,
291296
sideMenuThreshold: 50,
292297
transitionDuration: 300,
@@ -299,6 +304,12 @@ export class SuperTabs implements OnInit, AfterContentInit, AfterViewInit, OnDes
299304
}
300305

301306
this.config = defaultConfig;
307+
308+
if(this.config.allowElementScroll === true){
309+
if(this.config.dragThreshold < 110){
310+
this.config.dragThreshold = 110;
311+
}
312+
}
302313

303314
this.id = this.id || `super-tabs-${++superTabsIds}`;
304315
this.superTabsCtrl.registerInstance(this);

src/super-tabs-pan-gesture.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,10 @@ export class SuperTabsPanGesture {
9090
}
9191

9292
// stop anything else from capturing these events, to make sure the content doesn't slide
93-
ev.stopPropagation();
94-
ev.preventDefault();
93+
if(this.config.allowElementScroll !== true){
94+
ev.stopPropagation();
95+
ev.preventDefault();
96+
}
9597

9698
// get delta X
9799
const deltaX: number = this.lastPosX - coords.x;

0 commit comments

Comments
 (0)