ionic-team / ionic-framework

A powerful cross-platform UI toolkit for building native-quality iOS, Android, and Progressive Web Apps with HTML, CSS, and JavaScript.
https://ionicframework.com
MIT License
50.96k stars 13.51k forks source link

feat: swipeable segment (swipe on content to move segment) #17804

Open NgYueHong opened 5 years ago

NgYueHong commented 5 years ago

Feature Request

Ionic version:

[x] 4.x

Describe the Feature Request

Swipeable tabs is a common and long requested feature to have on Ionic. Really hope to see swipeable tabs feature in Ionic 4 soon.

brandyscarney commented 5 years ago

Thanks for the issue! The scrollable tabs that you see in the Material Design spec is available in our Segment component using the scrollable property.

Please see the usage information on that page: https://ionicframework.com/docs/api/segment#usage

They can be combined with slides to achieve a swipe between views effect, see this example Codepen: https://codepen.io/brandyscarney/pen/maOabQ?editors=1010

nicolasrhone commented 5 years ago

But this way, we don't have possibility to lazy load slides... which would be great!

uriannrima commented 5 years ago

Thanks for the great example @brandyscarney!!! Was having some trouble using the tabs for that.

By the way, for those looking for a better "feel" for when changing the segment when scrolling the panel, you may use "ionSlideWillChange". It seems a bit better than "onDid".

bunday commented 5 years ago

Very Helpful

khashashin commented 5 years ago

Some additional api for swiping segments would be also greate. There are no way to swipe them programmatically. Otherwise please provide some issue solver hier https://stackoverflow.com/q/57047922/7986808

sagits commented 4 years ago

Hi, in my case using sliders was a bad solution because i need the lazyloading. I ended up using segments with this lib:

https://github.com/diogoqueiros/ionic-swipe-all

NgYueHong commented 4 years ago

@BrandonShar Are we able to see Swipeable Tab on Ionic 5?

hellokingdom commented 4 years ago

@BrandonShar it's typical in this scenario for each slide to have an independently scrollable content area but the examples I have seen a linked due to a single ion-content.

Is there an agreed approach for this inside the constraints of the ionic framework?

shashwat44 commented 4 years ago

in ionic 5 : issue occurs

[ng] ERROR in node_modules/ionic2-super-tabs/dist/components/super-tab.d.ts:2:132 - error TS2307: Cannot find module 'ionic-angular'. [ng] 2 import { App, Config, DeepLinker, DomController, GestureController, NavControllerBase, NavOptions, Platform, ViewController } from 'ionic-angular'; [ng] ~~~ [ng] node_modules/ionic2-super-tabs/dist/components/super-tab.d.ts:3:38 - error TS2307: Cannot find module 'ionic-angular/transitions/transition-controller'. [ng] 3 import { TransitionController } from 'ionic-angular/transitions/transition-controller'; [ng] ~~~~~~~~~~~~~ [ng] node_modules/ionic2-super-tabs/dist/components/super-tabs.d.ts:5:118 - error TS2307: Cannot find module 'ionic-angular'. [ng] 5 import { App, DeepLinker, DomController, NavController, NavControllerBase, Platform, RootNode, ViewController } from 'ionic-angular'; [ng] ~~~ [ng] node_modules/ionic2-super-tabs/dist/components/super-tabs.d.ts:6:37 - error TS2307: Cannot find module 'ionic-angular/navigation/navigation-container'. [ng] 6 import { NavigationContainer } from 'ionic-angular/navigation/navigation-container'; [ng] ~~~~~~~~~~~ [ng]

NeckbreakerPascal commented 4 years ago

Thanks for the issue! The scrollable tabs that you see in the Material Design spec is available in our Segment component using the scrollable property.

Please see the usage information on that page: https://ionicframework.com/docs/api/segment#usage

They can be combined with slides to achieve a swipe between views effect, see this example Codepen: https://codepen.io/brandyscarney/pen/maOabQ?editors=1010

Are there any changes with this for ionic5? I tried but it did not work. I use ion-tabs and have 3 tabs with ion-slides.

Only on the First (initial) slider I can use the ion-segment to change the sliders, on the others the segment-indicator is moving but slideTo does not work. Also getActiveIndex and the rest of it.

It is kind of strange that the ionslidedidLoad event is triggered multiple times. Maybe there is some error, or I did something wrong. or I should open an new issue, not sure if it is related to this .Was just hoping your code will save me. :D

juny58 commented 4 years ago

I have long waited for this, finally made one web-component with ionic's stencil. It works in any platform and in all popular frameworks.

https://www.npmjs.com/package/mat-tab-swiper

juny58 commented 4 years ago

Thanks for the issue! The scrollable tabs that you see in the Material Design spec is available in our Segment component using the scrollable property.

Please see the usage information on that page: https://ionicframework.com/docs/api/segment#usage

They can be combined with slides to achieve a swipe between views effect, see this example Codepen: https://codepen.io/brandyscarney/pen/maOabQ?editors=1010

I have long waited for this, finally made one web-component with ionic's stencil. It works in any platform and in all popular frameworks.

https://www.npmjs.com/package/mat-tab-swiper tabswiperexample

ntorrey commented 2 years ago

Would love to see this as a built-in feature!