nativescript-slides icon indicating copy to clipboard operation
nativescript-slides copied to clipboard

Render unnormal when slideContainer addChild async

Open imwalson opened this issue 8 years ago • 5 comments

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.

imwalson avatar Nov 04 '16 14:11 imwalson

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

andreasotto avatar Nov 05 '16 10:11 andreasotto

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 :(

JoshDSommer avatar Nov 05 '16 12:11 JoshDSommer

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 avatar Nov 06 '16 03:11 imwalson

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

imwalson avatar Nov 22 '16 07:11 imwalson

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.

toddanglin avatar Jan 05 '17 19:01 toddanglin