From 1953ee9e3abde661c040f5e61d95cfc18127068a Mon Sep 17 00:00:00 2001 From: Eduardo Roth Date: Wed, 24 Jan 2018 23:08:04 -0600 Subject: [PATCH] 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 --- README.md | 1 + src/components/super-tabs.ts | 11 +++++++++++ src/super-tabs-pan-gesture.ts | 6 ++++-- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8eac496..33353ab 100644 --- a/README.md +++ b/README.md @@ -131,6 +131,7 @@ _(optional)_ Advanced configuration. Param | Description | Default --- | --- | --- `dragThreshold` | The number of pixels that the user must swipe through before the drag event triggers. | `20` +`allowElementScroll` | Allow elements inside tabs to be dragged before triggering the tab swipe event. | `false` `maxDragAngle` | The maximum angle that the user can drag at for the drag event to trigger. | `40` `transitionEase` | The transition timing function to use in animations. | `'cubic-bezier(0.35, 0, 0.25, 1)'` `transitionDuration` | The duration of animations in milliseconds. | `300` diff --git a/src/components/super-tabs.ts b/src/components/super-tabs.ts index f1b3624..4cb7c58 100644 --- a/src/components/super-tabs.ts +++ b/src/components/super-tabs.ts @@ -27,6 +27,10 @@ export interface SuperTabsConfig { * Defaults to 20 */ dragThreshold?: number; + /** + * Allows elements inside tabs to be dragged, defaults to false + */ + allowElementScroll?: boolean; /** * Defaults to ease-in-out */ @@ -287,6 +291,7 @@ export class SuperTabs implements OnInit, AfterContentInit, AfterViewInit, OnDes ngOnInit() { const defaultConfig: SuperTabsConfig = { dragThreshold: 10, + allowElementScroll: false, maxDragAngle: 40, sideMenuThreshold: 50, transitionDuration: 300, @@ -299,6 +304,12 @@ export class SuperTabs implements OnInit, AfterContentInit, AfterViewInit, OnDes } this.config = defaultConfig; + + if(this.config.allowElementScroll === true){ + if(this.config.dragThreshold < 110){ + this.config.dragThreshold = 110; + } + } this.id = this.id || `super-tabs-${++superTabsIds}`; this.superTabsCtrl.registerInstance(this); diff --git a/src/super-tabs-pan-gesture.ts b/src/super-tabs-pan-gesture.ts index 6894bec..7f982c9 100644 --- a/src/super-tabs-pan-gesture.ts +++ b/src/super-tabs-pan-gesture.ts @@ -90,8 +90,10 @@ export class SuperTabsPanGesture { } // stop anything else from capturing these events, to make sure the content doesn't slide - ev.stopPropagation(); - ev.preventDefault(); + if(this.config.allowElementScroll !== true){ + ev.stopPropagation(); + ev.preventDefault(); + } // get delta X const deltaX: number = this.lastPosX - coords.x;