Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Render unnormal when slideContainer addChild async #80

Open
imwalson opened this issue Nov 4, 2016 · 5 comments
Open

Render unnormal when slideContainer addChild async #80

imwalson opened this issue Nov 4, 2016 · 5 comments
Labels

Comments

@imwalson
Copy link

imwalson commented Nov 4, 2016

I'm trying to add child to the slide container async way dynamically (for example,in the callback of a http request).however,the Interface become unnormal and slide container can't swipe.

To verificate this,just change the file 'dynamic-page.ts' of the demo in line 24,like
setTimeout(function() { slideContainer.addChild(getSlide("Page " + i, "slide-" + i)); }, 100);
and run.

May be use Template and bindingContext (like the Repeater and Listview) is a better way?

Thanks.

@andreasotto
Copy link

andreasotto commented Nov 5, 2016

I have the same problem and stuck with that for many hours.
Is there any solution in sight?!??!

I'm adding slides with an onTap method and it breaks exactly that way you described here (mixes up content over and over and sliding is broken).

Reproduce:

let slideContainer;

// this is working as expected:
export function onSlideContainerLoaded(args) {
  slideContainer = <slides.SlideContainer>args.object;
  slideContainer.addChild(exports.getSlide("Page 1"));
  slideContainer.addChild(exports.getSlide("Page 2"));
  slideContainer.addChild(exports.getSlide("Page 3")); 
}

// this then mixes up everything:
export function onButtonTap() {
  slideContainer.addChild(exports.getSlide("Page 4"));
  slideContainer.addChild(exports.getSlide("Page 5"));
  slideContainer.addChild(exports.getSlide("Page 6"));
}

Seems to be the same than in #63

@JoshDSommer JoshDSommer added the bug label Nov 5, 2016
@JoshDSommer
Copy link
Owner

Thanks for the feed back @andreasotto and @imwalson. I'll look into this more when i have a chance. Off the top of my head I don't have a solution, sorry :(

@imwalson
Copy link
Author

imwalson commented Nov 6, 2016

As the appSettings is sync,so I first converts the data to string and then storage to appSettings in advance:
appSettings.setString("mydata",JSON.stringify(fetchResult));
When use it, like this:
JSON.parse(appSettings.getString("mydata"))

Just the temporarily solution,the disadvantage is that i can't get result timely, the data delayed.

@imwalson
Copy link
Author

Maybe we can use UIScrollView to create a slides on ios,like some native slides library does.I have written a "nativescript-swiper" plugin for ios based on UIScrollView just know :https://github.com/imwalson/nativescript-swiper.Welcome contributors and issues. @andreasotto @TheOriginalJosh

@toddanglin
Copy link
Contributor

This issue is very similar to #63
(Perhaps we should link/close one of these threads to consolidate feedback)

I posted one work around there if you need to create dynamic slides at runtime. In short, you can just create the entire SlideContainer dynamically (along with the slides) and then add to the page at anytime. Doesn't address the challenge of dynamically adding slides one at a time (via a button tap), but I suppose you could "destroy"/removeChild and recreate the SlideContainer with each tap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants