jellekralt / Responsive-Tabs

Responsive Tabs is a jQuery plugin that provides responsive tab functionality. The tabs transform to an accordion when it reaches a CSS breakpoint. You can use this plugin as a solution for displaying tabs elegantly on desktop, tablet and mobile.
http://jellekralt.github.io/Responsive-Tabs/
MIT License
531 stars 227 forks source link

Animation depending on state #107

Open coxrichuk opened 8 years ago

coxrichuk commented 8 years ago

Is it possible to have different animations depending on the state (tabs / accordion).

It seems to make sense to have fade on tabs view and slide on accordion view

I can put through a PR for this if required?

neilgee commented 8 years ago

Was also wanting this, makes sense to have slide animation on accordion and fade or no animation on tabs.

jellekralt commented 7 years ago

I have no plans on adding this myself, but a PR is always welcome

ghost commented 7 years ago

+1 to this, It make sense to activate slide animation for accordion, but not for tabs (strange). It would be great to be able to define different animation depending on state.

jtphelan commented 6 years ago

This mostly works for me. Animation works if you load no mobile but not if you load and desktop and resize down. Not sure why. LINE 438

    if(_this.getState() === 'accordion') {
      switch(method) {
          case 'slide':
              effect = (state === 'open') ? 'slideDown' : 'slideUp';
              break;
          case 'fade':
              effect = (state === 'open') ? 'fadeIn' : 'fadeOut';
              break;
          default:
              effect = (state === 'open') ? 'show' : 'hide';
              // When default is used, set the duration to 0
              _this.options.duration = 0;
              break;
      }
    } else {
      effect = (state === 'open') ? 'show' : 'hide';
      // When default is used, set the duration to 0
      _this.options.duration = 0;
    }
bigfocus commented 2 years ago

Good job!

Then I implemented when click the tabs scroll to Tabs Top with Callbacks.

$('#detail-tabs').responsiveTabs({
    startCollapsed: 'accordion',
    scrollToAccordion: true,
    animation: 'slide',
    duration: 300,
    click: function(e, tab) {
        $('html, body').animate({
            scrollTop: $(this).offset().top
        }, 300)
    },
});