Flex Mobile - 视图内容完全显示在屏幕上后是否触发事件
我正在尝试构建一个图片库,其中包含通过 API 获取的照片。该 API 一次仅允许获取 1 张照片。
我想显示一张照片,当用户向左/向右滑动时显示上一张或下一张照片。
我希望用户体验是无缝/快速的。为了实现这一目标,我正在考虑执行以下操作:- 全屏查看照片时,在后台获取上一张和下一张照片。 但是,我应该使用什么事件才能使API调用过程不会对用户造成任何延迟。
所以我的问题是,视图的照片/内容显示在屏幕上后是否会触发一个事件。
这样,我可以在该事件中调用 API 并预取数据。
如果我应该采取完全不同的方法,那么也请提出建议。
谢谢。
I'm trying to build an image gallery with photos fetched through an API. The API only allows 1 photo to be fetched at a time.
I want to display a photo and when the use swipes left/right display the previous or next photo.
I'd like the user experience to be seamless/fast. In order to achieve this I was thinking of doing the following:-
When a photo is viewed in full screen, fetch the previous and next photo in the background.
However, what event should I use so that the API call process does not cause any delay to the user.
So my question is, is there an event that is triggered after the photo/contents of the view is displayed on the screen.
That way , I can call the API in that event and pre-fetch the data.
If there's a different approach altogether I should take then please do suggest that too.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以采取的方法与您的想法略有不同。我相信 viewActivate 事件是在视图完全渲染并准备好推送到屏幕时触发的事件,但我相信触发您的请求会在转换中导致一些粗大的行为,从而将视图带入屏幕。您真正想要做的是将事件侦听器添加到将视图带到屏幕上的实际转换中,当转换完成时,您应该触发 API 请求以获取其他图片。转换完成时,转换会触发 FlexEvent.TRANSITION_END 事件。因此,将您的监听器附加到该监听器上,它应该可以满足您的要求。
The approach you can take is slightly different that what you think. The viewActivate event I believe is the one that is fired off when the view is fully rendered and is ready to be pushed to the screen, but I believe that firing off your request will cause some chunky behavior in the transition which brings the view on to the screen. What you really want to do is add an event listener to the actual transition that brings the view onto the screen and when the transition completes you should then fire off your API request to get the additional pictures. A transition fires off a FlexEvent.TRANSITION_END event when a transition is completed. So attach your listener to that and it should do what you are looking for.