-
Notifications
You must be signed in to change notification settings - Fork 34
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
dynamic slides not working #15
Comments
That's because the slides are created before the ngFor populates the dom. The slides aren't recreated after that though. I did somewhat hacky fix for that: slides are created first, then further recreation of slides is being done after 'changes' observable fires on ContentChildren. It's not ideal - changes to iterable ngFor is using will be reflected in the slides, but the slides may not be in correct order before first sliding action, resulting in slides jumping or not showing properly during the first slide after change. The other thing, because AFAIK "changes" observable isn't replaying content already emitted, slides have to be created once before subscribing to ContentChildren. If you want to try there's a "ngfor" branch on my fork, however keep in mind its not ideal solution. |
@sarpt so what is the ideal solution? |
@charaya I think the code called in the ngAfterViewInit (https://github.com/TheOriginalJosh/nativescript-ngx-slides/blob/master/slides/app/slides/slides.component.ts#L96) needs to be abstracted out into a public function you can then call after your dynamic data has loaded. This might be all you need to fix it. It's not a use cased i've had myself(yet) but I understand the need. |
Hmm, I'm not sure really. could you open a Pull Request with your ManualInit in it? it would probably be a nice addition once the kinks are worked out. |
ok, i will do it later, a question. its there a way that i can know when the slides gonna be slide to other page ? before the change event occured? 'cause with that i can implement a parcial solution to my problem and make the slides "dynamic" but really not dynamic just know when no to slide to the next slide |
I'm not sure I follow. There are changed and finished events you can watch for |
+1 - is there a solution available in the meanwhile? I'm having the same problem. I have a first slide which comes from the view directly and further slides which comes dynamically from a json file which is loaded in the .ts See code here: https://pastebin.com/G9EQXKMP Looking forward for any help with this. Thanks! |
I fixed this by placing a ngIf into the slides tag that is checking weather the array is empty and only shows after data is laded into the array. Obviousely there is ap problem with changing the content of the array that is used in the ngfor. If there are changes maybe it also would help to make the array empty first and then set the refreshed data. then angular would rereder the slides-element (hopefully). |
I have forked the project and changed the file It is more a hack than a solution (and I don't have time to test it properly) but it works in my situation quite well -- maybe, you have a similar one. Here is the git repository: https://github.com/heese/nativescript-ngx-slides @TheOriginalJosh Can this be an approach to solve the dynamic loading of slides? I create a pull request if you want to. |
@heese that sounds great! good work man, thank you! |
I like your plugin and I am happy to contribute. Since I needed it I have also introduced a new attribute |
That sounds perfect. Thank you @heese |
Turned my hack into a solution (still no time to test it properly). You can subscribe to changes of
Note: The dynamic data has to be loaded in ngAfterViewInit or later. |
@heese Sorry to bother you, but could you provide an example of how are you using your fork? I just need something to get me going, I could use your version, but the slides got badly initialized (not the right size). |
please find below an example which is derived from the code I am working on at the moment. In my case I needed the slides to have a certain width (depending on the display) and height (fixed). I have removed all unimportant bits and pieces and hope I haven't deleted anything essential -- meaning I have not tested the code below. Let me know if you need also the unmentioned import statements. Furthermore, I copied the slides module into my project because Josh will hopefully update his code at some point (making my fork superfluous) and make it available on npm. The method I found it helpful having the slides change automatically because you can then easily see if the slides are initialised properly and not rendered one over the other. I hope it helps.
|
Thank you! |
@heese please open a PR and I will merge it in. Thank you. |
At a quick glance you are setting |
@nikunjgajera I just published @heese PR in version 0.4.5 #43 |
link is not valid now. can you share again |
This was probably pointing to here: |
hello, i am trying to use this plugin inside *ngFor
<slides pageIndicators="false" loop="false"> <slide *ngFor="let item of items; let i = index"> <GridLayout><Label [text]="i"></Label> </slide> </slides>
the plugin crashes and i am unable to slide between the slides
The text was updated successfully, but these errors were encountered: