ionic-framework icon indicating copy to clipboard operation
ionic-framework copied to clipboard

bug: ion-slide-box with two slides and does-continue does not work correctly

Open KillerCodeMonkey opened this issue 11 years ago • 36 comments

Type: bug

Platform: all

hey guys in the rc4 and last nightly i use an ion-slide-box with the does-continue attribute and two slides.

http://codepen.io/bengtweisse/pen/PqYyvM

you can scroll to the second slide, but not back and not forward. If you swipe back from the first slide the pager is not correct. In the dom you can see more than two ion-slides.

If you resize the window there are suddenly four pager-"points".

If you add a third slide everything works fine.

KillerCodeMonkey avatar Apr 24 '15 13:04 KillerCodeMonkey

+1

bojanvidanovic avatar Apr 28 '15 20:04 bojanvidanovic

+1

ronaldcurtis avatar Jun 10 '15 03:06 ronaldcurtis

I have met the same problem recently, and when checking the ioinc souce code of "ionic.bundle.js", I found this souce as below:

  special case if two slides
  if (browser.transitions && options.continuous && slides.length < 3) {
    element.appendChild(slides[0].cloneNode(true));
    element.appendChild(element.children[1].cloneNode(true));
    slides = element.children;
  }

It seems like that If and only if the slide count is 2, ionic will double the count while setting up. I don't quite understand why the author added this special case, and how to fix it properly,

fileupload avatar Jun 11 '15 05:06 fileupload

I am having the same problem now, +1

yu521088 avatar Jul 07 '15 06:07 yu521088

Same here. +1

FME-nstokoe avatar Jul 07 '15 19:07 FME-nstokoe

Same problem. +1

lbickston avatar Jul 09 '15 03:07 lbickston

+1

diegoeduardorios avatar Jul 10 '15 03:07 diegoeduardorios

+1

Xalio08 avatar Jul 20 '15 22:07 Xalio08

Also having an issue with two slides (+1).

tflavin avatar Jul 22 '15 11:07 tflavin

I was able to find a temporary fix for my issue.

My issue was slightly different than the original post in that the pager was showing two pager icons but actually had four slides. When you got to slides 3 and 4 (which were duplicates of 1 and 2), no pager icon was selected. So, whenever I only have two slides and the slide changes (using on-slide-changed), I check the current index via $ionicSlideBoxDelegate.currentIndex(). I have an ng-class applied to the slidebox if the index is 2 (ex: 'first-slide') and one when it is 3 (ex: 'second-slide'). I also overrode the css for the .first-slide .slider-pager span:first_child and .second-slide .slider-pager span:nth-child(2) to have opacity: 1.

This change makes it appear that there are only 2 slides, even though there are really 4. This wouldn't work if the issue didn't let me slide through like in the original post, but for my issue it was good enough until there is a fix.

Edit: Just found that on some devices it's showing 4 pagers. So, I am now applying an ng-class on the slidebox when there are two slides (ex: 'two-slides'). Then I had to modify the css to set .two-slides .slider-pager span:nth-child(3) and .two-slides .slider-pager span:nth-child(4) to have display: none. This appears to work.

tflavin avatar Jul 23 '15 13:07 tflavin

have the same issue as tflavin, 4 slides and only two slides, but if i open a modal over the page when the modal is closed the sliders become 4.

marcocaimi avatar Jul 28 '15 08:07 marcocaimi

@tflavin +1 two slides should definitely not be changed into 4 slides. It's counter intuitive. Or at least it should be in the docs !

JerryBels avatar Jul 28 '15 09:07 JerryBels

Having the same problem. Any proper fix yet?

ghost avatar Jul 31 '15 07:07 ghost

same issue...+1

cheesezhe avatar Aug 17 '15 09:08 cheesezhe

+1

mrtomrichy avatar Aug 20 '15 09:08 mrtomrichy

Same here with 1.1.0

quedicesebas avatar Aug 21 '15 19:08 quedicesebas

+1

mesca avatar Aug 28 '15 13:08 mesca

Another work around is to special case your model to explicitly duplicate your array in the pattern [0, 1, 0, 1] if it has 2 elements.

meticoeus avatar Sep 14 '15 16:09 meticoeus

Hey,guys, I add the following code to my controller script, and it seems that that bug disappeared. function loadIds() is to get json data from server and store data into $scope.ids

$scope.$on('$ionicView.beforeEnter', function(){
        if($scope.ids.length == 0){
          $scope.loadIds();
        }else{
          $ionicSlideBoxDelegate.update();
          $ionicSlideBoxDelegate.loop(true);
        }
      });

cheesezhe avatar Sep 15 '15 01:09 cheesezhe

It seems the copied objects don't inherit the data in their scope, causing the following code to not work:

ng-click="goTo(post)"

tiagojdf avatar Sep 22 '15 15:09 tiagojdf