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
51.09k stars 13.51k forks source link

Weird behaviour for slidebox in modals #360

Closed xAlien95 closed 10 years ago

xAlien95 commented 10 years ago

When you try to insert a slidebox in a modal, its width becames 0px. Here's a plnkr. Thanks for reading :)

cdarken commented 10 years ago

For me the content is not visible when in a normal view too, not modal, I'm loading my content from a webservice.

xAlien95 commented 10 years ago

@mlynch it isn't working also in Ionic 0.9.19 "Koala".

mlynch commented 10 years ago

I see the issue for both dynamic and modal. The size just isn't being computed. I'm fixing it now.

mlynch commented 10 years ago

Okay, I made a fix for this, unfortunately it involves updating the slidebox size manually when the content changes.

Inject SlideBoxDelegate into your controllers and when the content changes, call:

SlideBoxDelegate.update() and it will update the child slidebox.

I'm looking for a better solution, which might be as simple as setting the width to be full, but unfortunately when the content changes the slidebox also needs to recompute the number of pages, etc. so it needs a nudge to know its children changed.

xAlien95 commented 10 years ago

Thank you @mlynch, it works, but there's an error in the console log everytime I slide slides:

Error: [$compile:nonassign] Expression 'undefined' used with directive 'slideBox' is non-assignable!
http://errors.angularjs.org/1.2.2/$compile/nonassign?p0=undefined&p1=slideBox
    at http://uxiedex.altervista.org/js/angular/angular-scenario.js:9870:12
    at parentSet (http://uxiedex.altervista.org/js/angular/angular-scenario.js:15837:25)
    at Object.parentValueWatch (http://uxiedex.altervista.org/js/angular/angular-scenario.js:15852:23)
    at Scope.$digest (http://uxiedex.altervista.org/js/angular/angular-scenario.js:21286:47)
    at Scope.$apply (http://uxiedex.altervista.org/js/angular/angular-scenario.js:21532:24)
    at http://uxiedex.altervista.org/js/angular/angular-scenario.js:23057:36
    at completeOutstandingRequest (http://uxiedex.altervista.org/js/angular/angular-scenario.js:13813:10)
    at http://uxiedex.altervista.org/js/angular/angular-scenario.js:14119:7 angular-scenario.js:18951

You can see it here, clicking on "Accedi" and then on "Registrati su Uxie Dex" :)

mlynch commented 10 years ago

Hmm, seems like an issue with angular-scenario. Isn't that just for testing, not production?

xAlien95 commented 10 years ago

That site will be a free database when users could login to set preferences. No ads, zero cost for the server maintenance and the right credits framework and datas used. Could there be problems I haven't thought?

calendee commented 10 years ago

I get the same issue with SlideBox NOT in a modal.

I included angular-scenario and still see this output:

Error: [$compile:nonassign] Expression 'undefined' used with directive 'slideBox' is non-assignable!
http://errors.angularjs.org/1.2.7/$compile/nonassign?p0=undefined&p1=slideBox
    at http://localhost:8000/js/angular/angular-scenario.js:9870:12
    at parentSet (http://localhost:8000/js/angular/angular-scenario.js:15920:25)
    at Object.parentValueWatch (http://localhost:8000/js/angular/angular-scenario.js:15934:23)
    at Object.watchExpression (<anonymous>:754:29)
    at Scope.$digest (http://localhost:8000/js/angular/angular-scenario.js:21567:40)
    at Scope.$delegate.__proto__.$digest (<anonymous>:844:31)
    at Scope.$apply (http://localhost:8000/js/angular/angular-scenario.js:21828:24)
    at Scope.$delegate.__proto__.$apply (<anonymous>:855:30)
    at http://localhost:8000/js/angular/angular-scenario.js:23361:36
    at completeOutstandingRequest (http://localhost:8000/js/angular/angular-scenario.js:13897:10) angular-scenario.js:19194```
calendee commented 10 years ago

This is fixed in PR https://github.com/driftyco/ionic/pull/398

Problem is in sliderView.js : var index = parseInt(options.startSlide, 10) || 0;

The option startSlide is not set in ionicSlidebox.js

calendee commented 10 years ago

Actually… my PR did not fix this. While working on that PR, I modified my slide box so that it had the attribute active-slide="1" set. THAT is what fixes this problem.

jprichardson commented 10 years ago

I'm having this problem in a modal as well. I tried to inject SlideBoxDelegate, but it didn't work. I eventually figured out that I needed to inject $ionicSlideBoxDelegate, but when I call update() I see all of the slides contents. I'm using 0.9.26.

It'd be great to see a working example in the documentation.

skitterm commented 10 years ago

I'm having the same issue where the slidebox's width is sometimes set to 0px initially.

adamdbradley commented 10 years ago

@skitterm can you recreate the issue in a codepen and describe how to replicate the issue? This would help us narrow it down. Thanks

r0boto commented 10 years ago

I have this problem too in 1.0.0-beta.12

adamdbradley commented 10 years ago

@manfromshadow Creating a codepen would help us narrow this down. Thanks

nesk commented 10 years ago

I had the same issue but found why: the slider was instanciated while his parent was hidden, so it was unable to correctly calculate the sizes.

trumbitta commented 10 years ago

Using ng-if fixed it for me: http://forum.ionicframework.com/t/ion-slide-box-and-ng-repeat/9826/5

This makes me think the "ng-if" should be added as a proper conditional inside the ion-slide-box directive.

ionitron-bot[bot] commented 6 years ago

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.