No, unfortunately there isn’t a way to do lazy loading for views.
I think the virtualized
feature should work though, but I can’t say I’ve tested it; any feedback you could provide about it would be helpful.
No, unfortunately there isn’t a way to do lazy loading for views.
I think the virtualized
feature should work though, but I can’t say I’ve tested it; any feedback you could provide about it would be helpful.
Think I came up with a solution. Atleast it seems to work quite good.
I load images from a database stored as varbinary and I want to stop this if the Swiper contains alot of images.
def valueChanged(self, previousValue, currentValue, origin, missedEvents):
if currentValue.value == True and self.view.custom.image == "":
import base64
sqlParams = {"imageId": self.view.params.imageId}
image = system.db.runNamedQuery("getImage", sqlParams).getValueAt(0,0)
self.view.custom.image = base64.b64encode(image)
def realIndex(self):
component = self.getChild("Swiper")
proxy = component.getJavaScriptProxy("swiper")
currentIndex = proxy.runBlocking('''() => this.realIndex''')
if currentIndex != self.view.custom.currentIndex:
self.view.custom.currentIndex = currentIndex
for i in range(3):
self.getChild("Swiper").props.instances[currentIndex + i].viewParams.load = True
def runAction(self, event):
self.parent.realIndex()
This seems to work fine for me. But I'm not really sure how effecient it is. And depending on the Swiper settings it could cause the message to not get triggered enough (more dots (have to preload more then +2), or with a scroll etc.). If there was a better way to get the current index it would probably work better.
EDIT: Used Message Handler on the Embedded Views to load the images but felt wrong to send out a message that ~100 views handled on each Swiper-click. This solution feels better, but I'm open for a better one