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

ng-include inside sf-virtual-repeat #14

Closed
huynhhuutai opened this issue Jan 24, 2014 · 8 comments
Closed

ng-include inside sf-virtual-repeat #14

huynhhuutai opened this issue Jan 24, 2014 · 8 comments

Comments

@huynhhuutai
Copy link

Hi stackfull,
I'm trying to combine sf-virtual-repeat with ng-include, but I got error in 2 following cases:

<div>
  <div>
    <div sf-virtual-repeat="item in items"  ng-include src="itemTemplateUrl">
    </div>
  </div>
</div>

Error: [$compile:multidir] Multiple directives [sfVirtualRepeat, ngInclude] asking for transclusion

<div>
  <div>
    <div sf-virtual-repeat="item in items">
        <div ng-include src="itemTemplateUrl"></div>
    </div>
  </div>
</div>

Error: Unable to compute height of row

Could you help me out, or any suggestion, thanks..

@stackfull
Copy link
Owner

I think the first case couldn't work because, as the error says, angular won't allow it.

The second case is a limitation of the way virtual repeaters work. It should be fixable by adding an explicit CSS height to that inner div. Pop a class on it and set "height: 20px" or whatever.

@huynhhuutai
Copy link
Author

I have tried the first case with ng-repeat, it work!
Actually, I don't want the height of element be fixed, it should be depend on content of template.
I'm so sorry about that limitation.
Anyway thanks for your comments.

@stackfull
Copy link
Owner

It is an annoying limitation, to be sure. But it's also fundamental to how virtual scrolling works as a concept. No matter how it's implemented, you need to be able to calculate how high the full set of elements is. You could, in theory, wait until an element was rendered and then read the height of that, but angular doesn't stabilise that way and there's no event you can hook into. The only workaround I've seen is to use a timer to read the height and re-adjust. That's just a hack too far for me.

I'll look again at the first case, maybe something changed in angular that made this work (need to scan through this: angular/angular.js#3584)

@huynhhuutai
Copy link
Author

Okay, I got it.
The other problem about the height of element:
http://demo.stackfull.com/virtual-scroll/#/expose
Why are there so many rows which have been rendered (Active Rows) in unnecessary way than rows seen (Visible Rows) (up 315/15). I think it should be reduced (may be 100/15). Simultaneously,the number of rows which have been rendered is also inversely proportional with their height. Example: the height of a element is 20px -> 100 element which is rendered., but the other side, the height of a element is 100px -> only about 20 element which is rendered.

@huynhhuutai
Copy link
Author

In the first case: "This is not an ideal solution to the problem of multiple transclusions per element"
(angular/angular.js@63c5334)

@huynhhuutai
Copy link
Author

Hi Paul,
You have any solution for these issues?
I hope that can help me out. Thanks.

@stackfull
Copy link
Owner

I'm afraid not - the code you referenced above is explicitly checking for ngRepeat. Short of getting angular to check for sfVirtualRepeat too, I'm not sure I can do anything about it.

Leaving the ticket open to remind myself to have another look though.

@stackfull
Copy link
Owner

Closing - pretty sure I can't fight other directives over transcludes without really nasty things happening

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

No branches or pull requests

2 participants