Page data loading method and loading device

By generating and detecting whether the canvas container of page data collides, infinite loading of page data is achieved, solving the problems of limitations and unstable performance in the existing technology, and improving user experience.

CN113688336BActive Publication Date: 2024-10-18BEIJING WODONG TIANJUN INFORMATION TECH CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202010419060.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-05-18
Publication Date
2024-10-18
Estimated Expiration
2040-05-18

AI Technical Summary

Technical Problem

The existing technology requires at least three location information when implementing infinite page loading, which leads to limitations. Moreover, monitoring window scroll events will cause unstable performance and affect the user experience.

Method used

By generating the first canvas container and the second canvas container corresponding to the page data, and detecting whether the two containers collide, infinite loading of page data is achieved and real-time monitoring of window scrolling events is avoided.

Benefits of technology

It solves the limitations of infinite page loading and unstable performance, provides a better user experience, and reduces the complexity of performance optimization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113688336B_ABST
    Figure CN113688336B_ABST
Patent Text Reader

Abstract

The present invention discloses a method and device for loading page data, and relates to the field of computer technology. A specific implementation of the method includes: obtaining target page data, determining a data container and a loading container corresponding to the target page data; generating a first canvas container and a second canvas container corresponding to the target page data according to a visible window, a data container and a loading container; detecting whether the first canvas container and the second canvas container collide, and if so, loading the next page data corresponding to the current page data; wherein the current page data and the next page data belong to the data in the target page data. This implementation can achieve an infinite loading effect of page data, solve the limitations and performance instability problems in the prior art, and bring a better experience to users.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a method and device for loading page data. Background Art

[0002] In the Internet age, more and more users use smart devices to search for content they are interested in, such as searching for books they are interested in through electronic libraries, searching for items they are interested in through online shopping platforms, etc. When users browse pages, when the page slides to the bottom, the page data will be automatically loaded to the bottom of the page, thereby realizing infinite page loading and allowing users to continue browsing.

[0003] Infinite loading means that when the visible window of the page scrolls to the bottom, loading is triggered and the data of the next page is added to the back of the existing content. At present, the infinite loading effect of the page requires the following three position information: the distance top from the scroll bar to the top of the page document, the height clientHeight of the visible area of ​​the page, and the total height scrollHeight of the obtained document. When these three position information meet a certain relationship, such as top+clientHeight>=scrollHeight, it means that the data of the next page needs to be requested. Among them, documents have a certain format, and there are specific programs or languages ​​to identify them. The document here refers to the document in page format.

[0004] In the process of implementing the present invention, the inventors found that there are at least the following problems in the prior art: (1) at least three location information are required, which causes certain limitations; (2) it is necessary to monitor the scrolling events of the window to obtain data in real time, which will cause unstable performance and affect the user experience; (3) it is necessary to use certain technical means for optimization, otherwise performance problems will easily occur. Summary of the invention

[0005] In view of this, an embodiment of the present invention provides a method and a device for loading page data, which can achieve an infinite loading effect of page data, solve the limitations and unstable performance problems in the prior art, and bring a better experience to users.

[0006] To achieve the above objective, according to a first aspect of an embodiment of the present invention, a method for loading page data is provided.

[0007] A page data loading method according to an embodiment of the present invention includes: acquiring target page data, determining a data container and a loading container corresponding to the target page data; generating a first canvas container and a second canvas container corresponding to the target page data according to a visible window, the data container and the loading container; detecting whether the first canvas container and the second canvas container collide, and if so, loading the next page data corresponding to the current page data; wherein the current page data and the next page data belong to the data in the target page data.

[0008] Optionally, generating the first canvas container and the second canvas container corresponding to the target page data based on the visible window, the data container and the loading container includes: performing fixed positioning outside the visible window or the data container to generate the first canvas container; and performing absolute positioning inside the loading container to generate the second canvas container.

[0009] Optionally, after generating the first canvas container, the method further includes: setting the width of the first canvas container to the width of the visible window, and setting the height of the first canvas container to the height of the visible window; and after generating the second canvas container, the method further includes: setting the width of the second canvas container to the width of the visible window, and setting the height of the second canvas container to the height of the loading container.

[0010] Optionally, before detecting whether the first canvas container collides with the second canvas container, the method further includes: acquiring a first rectangle corresponding to the first canvas container according to a size and a position of the first canvas container; and acquiring a second rectangle corresponding to the second canvas container according to a size and a position of the second canvas container.

[0011] Optionally, detecting whether the first canvas container collides with the second canvas container includes: executing an animation function and determining whether a difference between a top of the first rectangle and a top of the second rectangle is not greater than a height of the first rectangle; if so, determining that the first canvas container collides with the second canvas container; if not, determining that the first canvas container does not collide with the second canvas container, and continuing to execute the animation function.

[0012] Optionally, before loading the next page data corresponding to the current page data, the method further includes: judging whether the next page data exists based on the current page data and the target page data; if so, asynchronously loading the next page data; if not, ending the animation function.

[0013] Optionally, the loading container is located at the bottom of the data container; and the width of the loading container and the width of the data container are the same as the width of the visible window.

[0014] To achieve the above objective, according to a second aspect of an embodiment of the present invention, a device for loading page data is provided.

[0015] A page data loading device according to an embodiment of the present invention includes: a determination module, used to obtain target page data, and determine a data container and a loading container corresponding to the target page data; a generation module, used to generate a first canvas container and a second canvas container corresponding to the target page data according to a visible window, the data container and the loading container; a loading module, used to detect whether the first canvas container and the second canvas container collide, and if so, load the next page data corresponding to the current page data; wherein the current page data and the next page data belong to the data in the target page data.

[0016] Optionally, the generating module is further used for: performing fixed positioning outside the visible window or the data container to generate the first canvas container; performing absolute positioning inside the loading container to generate the second canvas container.

[0017] Optionally, the generation module is further used to: set the width of the first canvas container to the width of the visible window, and set the height of the first canvas container to the height of the visible window; and set the width of the second canvas container to the width of the visible window, and set the height of the second canvas container to the height of the loading container.

[0018] Optionally, the loading module is further used to: obtain a first rectangle corresponding to the first canvas container according to the size and position of the first canvas container; and obtain a second rectangle corresponding to the second canvas container according to the size and position of the second canvas container.

[0019] Optionally, the loading module is further used to: execute an animation function, and determine whether the difference between the top of the first rectangle and the top of the second rectangle is not greater than the height of the first rectangle; if so, determine that the first canvas container and the second canvas container collide; if not, determine that the first canvas container and the second canvas container do not collide, and continue to execute the animation function.

[0020] Optionally, the loading module is further used to: determine whether the next page data exists according to the current page data and the target page data; if so, asynchronously load the next page data; if not, end the animation function.

[0021] Optionally, the loading container is located at the bottom of the data container; and the width of the loading container and the width of the data container are the same as the width of the visible window.

[0022] To achieve the above objective, according to a third aspect of an embodiment of the present invention, an electronic device is provided.

[0023] An electronic device according to an embodiment of the present invention includes: one or more processors; a storage device for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors implement the page data loading method according to the embodiment of the present invention.

[0024] To achieve the above objective, according to a fourth aspect of an embodiment of the present invention, a computer-readable medium is provided.

[0025] A computer-readable medium according to an embodiment of the present invention stores a computer program, and when the program is executed by a processor, the method for loading page data according to an embodiment of the present invention is implemented.

[0026] An embodiment of the above invention has the following advantages or beneficial effects: it can generate a first canvas container and a second canvas container corresponding to the page data, and detect whether the two canvas containers collide, thereby achieving an infinite loading effect of the page data, solving the limitations and performance instability problems in the prior art, and bringing a better experience to users.

[0027] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with specific implementation examples. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.

[0029] Figure 1 is a schematic diagram of main steps of a method for loading page data according to an embodiment of the present invention;

[0030] Figure 2 is a schematic diagram of the main process of a method for loading page data according to an embodiment of the present invention;

[0031] Figure 3 is a schematic diagram of main modules of a device for loading page data according to an embodiment of the present invention;

[0032] Figure 4 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;

[0033] Figure 5 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION

[0034] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.

[0035] The existing technology requires at least three pieces of location information to achieve the infinite loading effect of the page, which causes certain limitations; it is necessary to monitor the scrolling event of the window to obtain data in real time, which will cause unstable performance and poor user experience; it is necessary to use certain technical means for optimization, such as using throttling functions for optimization, otherwise performance problems will easily occur. Among them, the page refers to the web page, which is the basic element of the website and the platform for carrying various website applications; the monitoring window refers to a container of the monitoring page, which refers to the window opened in the browser by default; the scrolling event can be a scroll event, which will be triggered when the user scrolls to the specified position or element, and the scroll event is applicable to all scrollable elements and windows.

[0036] In order to solve the above problems, the present invention provides a method for loading page data, which can generate a first canvas container and a second canvas container corresponding to the page data, and detect whether the two canvas containers collide, thereby achieving an infinite loading effect of page data, solving the limitations and performance instability problems in the prior art, and bringing a better experience to users. Figure 1 FIG. 1 is a schematic diagram of the main steps of a method for loading page data according to an embodiment of the present invention. Figure 1 As shown, the main steps of the method for loading page data may include steps S101 to S103.

[0037] Step S101: Acquire target page data, and determine a data container and a loading container corresponding to the target page data.

[0038] Among them, the target page data refers to the page data that needs to be loaded. For example, if a user searches for books related to winter in an electronic library, the target page data is the data of books related to winter provided by the electronic library. It should be noted that the page data loading method of the embodiment of the present invention can achieve an infinite loading effect, so it is required that the target page data needs to cover the entire visible window. This is because if the target page data cannot cover the entire visible window, it means that there is no possibility of infinite loading of the target page data. For example, a certain target page data contains 10 data, and the visible window can display 20 data, then the target page data can be directly displayed in full without infinite loading. In specific operations, the following judgment conditions can be used for verification: Document.body.scrollHeight (height of the target page data)>=window.innerHeight (height of the visible window). If this condition is met, it means that the target page data meets the condition, and the method provided by the embodiment of the present invention can be used to load the page data. In addition, the visible window refers to a visible page window.

[0039] The container refers to the DOM element that carries the list. The DOM is a collection of nodes or information fragments organized in a hierarchical structure. The data container corresponding to the target page covers all data lists that contain the target page; the loading container refers to the DOM element that carries the words "Load More"; the loading container is located at the bottom of the data container; and the width of the loading container and the width of the data container are the same as the width of the visible window. Loading more means loading data, that is, more data in the data list.

[0040] For example, if you search for keywords and the target page data you get contains 20 data items from A1 to A20, then the data container covers the 20 data items from A1 to A20. The target page data can load 15 data items at a time, that is, once loaded, you can request up to 15 data items from the server or backend, so that when you load for the first time, you get 15 data items from A1 to A15. However, since the visible window can only display 10 data items at most, when you load for the first time, the visible window displays 10 data items from A1 to A10, and then by sliding the scroll bar, you can continue to display 5 data items from A11 to A15. At this time, if you continue to slide the scroll bar, you need to load the remaining 5 data items from A16 to A20, that is, you need to request 5 data items from A16 to A20 from the server or backend. It can be seen that the 15 data items A1 to A15 will be displayed in the data container when they are loaded for the first time, and the remaining 5 data items A16 to A20 are obtained by loading again, so the 5 data items A16 to A20 are equivalent to being located in the loading container at the bottom of the data container. When the second loading request is sent, the 5 data items A16 to A20 can be loaded below the 15 data items A1 to A15.

[0041] Therefore, after the first data loading request (equivalent to sending a page request to the server or background), the height of the data container is the height of the 15 data items A1 to A15 plus the height of the loading container. After the second data loading request (equivalent to continuing to slide the scroll bar downward after the 15 data items A1 to A15 are fully displayed), the height of the data container is the height of the 20 data items A1 to A20 plus the height of the loading container. Obviously, the height of the data container changes dynamically, and the loading container is located at the bottom of the data container.

[0042] Step S102: Generate a first canvas container and a second canvas container corresponding to the target page data according to the visible window, the data container and the loading container.

[0043] In an embodiment of the present invention, canvas can be used to generate a first canvas container and a second canvas container corresponding to the target page data. Canvas is used to draw images and animations on the page. It can be understood as a canvas on which the desired effect is constructed. Considering that the page cannot be operated directly, a canvas container corresponding to the target page data is generated, and then the canvas container is operated to determine whether more data needs to be loaded. This can avoid the limitations and unstable performance problems caused by the need for at least three location information and scrolling events of the listening window to obtain data in real time in the prior art. Step S103, detect whether the first canvas container and the second canvas container collide. If so, load the next page data corresponding to the current page data.

[0044] Among them, the current page data and the next page data are both data in the target page data. The current page data refers to the page data currently being displayed. For example, the target page data contains 100 data items, and each page has 20 data items, so there are 5 pages of data. The third page of data is currently being displayed, so the current page data is the third page of data, and the corresponding next page of data is the fourth page of data. When a collision is detected between the first canvas container and the second canvas container, it means that the current page data has been fully displayed, and the next page of data needs to be displayed on the visible window. At this time, the next page of data needs to be loaded.

[0045] In the method for loading page data in the embodiment of the present invention, by generating the first canvas container and the second canvas container corresponding to the target page data, and by detecting whether the two canvas containers collide, the infinite loading effect of the page data is achieved. Therefore, generating the two canvas containers is an important part of the technical solution for loading page data. Therefore, in some embodiments, generating the first canvas container and the second canvas container corresponding to the target page data according to the visible window, the data container and the loading container may include:

[0046] Step S1021, performing fixed positioning outside the visible window or data container to generate a first canvas container;

[0047] Step S1022, perform absolute positioning inside the loading container to generate a second canvas container.

[0048] In an embodiment of the present invention, canvas can be used to generate a first canvas container and a second canvas container, namely, a canvas1 element and a canvas2 element. Fixed positioning, i.e., fixed positioning, means that the generated canvas1 element will not move with the scrolling of the scroll bar. Fixed positioning is performed outside the visible window or data container, which means that the generated first canvas container is fixed to the visible window, so that when the scroll bar is scrolled, the first canvas container will not scroll with the scroll bar. Absolute positioning, i.e., absolute positioning, means that the generated canvas2 element will move with the scrolling of the scroll bar. Absolute positioning is performed inside the loading container, so that the size and position of the generated second canvas container are consistent with the outer loading container, and the generated second canvas container can change with the change of the loading container.

[0049] It should be noted that the outside and inside in step S1021 and step S1022 both represent a hierarchical relationship, specifically the hierarchical relationship in the z-axis direction. Both fixed positioning and absolute positioning generate absolutely positioned elements; fixed is positioned relative to the visible window, and the position of the element can be specified by left, top, bottom, and right, and can be hierarchically graded through the z-axis; absolute is positioned relative to the first parent element other than static positioning, and the position of the element can be specified by left, top, bottom, and right, and can be hierarchically graded through the z-axis, with static being the default value.

[0050] In addition, the canvas element can be generated by writing directly in the body <canvas id=”can vas1”>< / canvas> , and then get it in the code snippet: var canvas1 = document.get ElementById('canvas1'), and canvas2 can be obtained similarly.

[0051] In some embodiments, the page data loading method may further include: after generating a first canvas container, setting the width of the first canvas container to the width of the visible window, and setting the height of the first canvas container to the height of the visible window; and after generating a second canvas container, setting the width of the second canvas container to the width of the visible window, and setting the height of the second canvas container to the height of the loading container.

[0052] The reason for setting the height and width of the first canvas container and the second canvas container is to facilitate the use in collision detection later. Collision refers to the collision of two rectangles. If a collision occurs, it means that the loading container has reached the visible window.

[0053] After generating the first canvas container and the second canvas container, it is possible to detect whether the two canvas containers collide. The embodiment of the present invention uses a rectangle for detection. Therefore, in some embodiments, before detecting whether the first canvas container and the second canvas container collide, the method for loading page data may also include: obtaining a first rectangle corresponding to the first canvas container according to the size and position of the first canvas container; obtaining a second rectangle corresponding to the second canvas container according to the size and position of the second canvas container. Specifically, the canvas API can be used to draw rectangles according to the sizes of the canvas1 element and the canvas2 element respectively. The canvas API provides a way to draw graphics through the canvas element of JavaScript (i.e., a scripting language) and HTML (i.e., Hypertext Markup Language), which can be used for animation, game screens, data visualization, image editing, and real-time video processing.

[0054] After obtaining the first rectangle and the second rectangle, it is possible to detect whether the first canvas container and the second canvas container collide. Specifically, the animation function is executed, and it is determined whether the difference between the top of the first rectangle and the top of the second rectangle is not greater than the height of the first rectangle; if so, it is determined that the first canvas container and the second canvas container collide; if not, it is determined that the first canvas container and the second canvas container do not collide, and the animation function continues to be executed.

[0055] Among them, the animation function can be requestAnimationFrame, which is an application that can be used to request animation. In the embodiment of the present invention, the screen refresh frequency of the animation function can be dynamically set, and the screen here is equivalent to a visible window. The screen refresh frequency is the speed at which the image is updated on the screen, that is, the number of times the image on the screen appears per second. Its unit is Hertz. For general smart devices, this frequency can be set to 60Hz, that is, if the animation function is executed, even if nothing is done to the screen of the smart device, the display of the smart device will continuously update the image on the screen at a frequency of 60 times per second. In addition, the biggest advantage of requestAnimationFrame is that the execution time of the callback function is determined by the system. Specifically, if the screen refresh rate is 60Hz, then the callback function is executed once every 16.7ms. If the refresh rate is 75Hz, then this time interval becomes 1000 / 75=13.3ms, that is, the pace of requestAnimationFrame follows the refresh pace of the system, which can ensure that the callback function is only executed once in each refresh interval of the screen, so that it will not cause frame loss or animation jamming. In the embodiment of the present invention, the collision time between the first rectangle and the second rectangle can be detected by means of an animation function, thereby avoiding the performance instability problem caused by using a scrolling event of a monitoring window in the prior art.

[0056] As explained in step S1021 and step S1021 above, the first canvas container is fixed relative to the visible window and can maintain its position unchanged; the second canvas container is absolutely behaved, and its position will change with the position of the loading container during the page sliding process. The change here is mainly the change of the top of the second canvas container. When the top of the second canvas container changes to a certain value, it will begin to intersect with the position of the first canvas container. When the intersection begins, it can be considered that the first canvas container and the second canvas container have collided. The specific collision condition can be: the difference between canvas1.top (i.e., the top of the first rectangle) and canvas2.top (i.e., the top of the second rectangle) is not greater than canvas1.height (i.e., the height of the first rectangle), that is, when the difference between canvas1.top and canvas2.top is less than or equal to canvas1.height, it means that a collision between the first canvas container and the second canvas container is detected.

[0057] In addition, when the difference between canvas1.top and canvas2.top is greater than canvas1.height, it means that the first canvas container and the second canvas container have not collided, and the animation function will continue to be executed, that is, the first canvas function and the second canvas function will continue to be detected according to the screen refresh frequency. Since it has been mentioned in step S101 that the target page data of the embodiment of the present invention needs to cover the entire visible window, if the scroll bar is slid downward, there will be no situation where the first canvas container and the second canvas container do not collide, which means that the judgment here will not fall into an infinite loop.

[0058] In some embodiments, before loading the next page data corresponding to the current page data, the page data loading method may also include: judging whether the next page data exists based on the current page data and the target page data; if so, asynchronously loading the next page data; if not, ending the animation function.

[0059] When the collision between the first canvas container and the second canvas container is detected, it means that more data needs to be loaded. However, before loading more data, it is necessary to determine whether there is more data to load. If so, asynchronous loading can be performed. If not, it means that the target page data has been fully loaded, and the animation function can be terminated at this time. Considering that the programming language of the page is a single-threaded language, such as JavaScript, if all are performed in sequence, there will often be no response, so the form of asynchronous task loading is required. Synchronous tasks refer to tasks queued for execution on the main thread. Only when the previous task is completed can the next task be executed. The advantage of this mode is that it is relatively simple to implement and the execution environment is relatively simple. Asynchronous tasks refer to tasks that do not enter the main thread, but enter the task queue. Only when the task queue notifies the main thread that a certain asynchronous task can be executed, this task will enter the main thread for execution. In the embodiment of the present invention, the next page of data can be loaded through asynchronous tasks. At this time, the task of the main thread is uncertain. It is possible that the user clicks on one of the data to operate a certain function, such as clicking on the picture to zoom in and view it, etc.

[0060] In addition, the next page of data can be calculated by the current page number, the number of items displayed per page, and the total number of lists, and the calculation formula is: currentPage (current page number) * pageSize (number displayed per page) >= total (total number of lists). For example, the current page is the third page, the number of items displayed per page is fixed at 20, and the total number of items in the list is 100. Then it is obviously not satisfied according to the above formula. Then it can be judged that when the current page is the third page, there is still more data in the sliding down loading process. Then, it is necessary to determine whether it is necessary to load the next page of data (that is, the fourth page of data) at this time by detecting whether there is a collision. In addition, executing loading does not mean that loading can be executed immediately as long as it is determined that there is more data. Usually, the next page of data is loaded when sliding to the bottom of the page. The purpose of the collision judgment in the embodiment of the present invention is to detect whether the current page has slid to the bottom, that is, whether the conditions for loading the next page of data are met.

[0061] Figure 2 FIG. 1 is a schematic diagram of the main flow of a method for loading page data according to an embodiment of the present invention. Figure 2 As shown, the main process of the page data loading method may include:

[0062] Step 201, obtaining target page data, and determining a data container and a loading container corresponding to the target page data;

[0063] Step 202, performing fixed positioning outside the visible window or data container to generate a first canvas container corresponding to the target page data;

[0064] Step 203, setting the width of the first canvas container to the width of the visible window, and setting the height of the first canvas container to the height of the visible window;

[0065] Step 204, obtaining a first rectangle corresponding to the first canvas container according to the size and position of the first canvas container;

[0066] Step 205, perform absolute positioning inside the loading container to generate a second canvas container corresponding to the target page data;

[0067] Step 206, setting the width of the second canvas container to the width of the visible window, and setting the height of the second canvas container to the height of the loading container;

[0068] Step 207, obtaining a second rectangle corresponding to the second canvas container according to the size and position of the second canvas container;

[0069] Step 208, executing the animation function;

[0070] Step 209, determining whether the difference between the top of the first rectangle and the top of the second rectangle is not greater than the height of the first rectangle, if so, executing step 210, if not, executing step 208;

[0071] Step 210, determining that the first canvas container and the second canvas container collide, judging whether there is a next page of data according to the current page data and the target page data, if yes, executing step 211, if no, executing step 212;

[0072] Step 211, asynchronously loading the next page of data;

[0073] Step 212, end the animation function.

[0074] Among them, the loading container is located at the bottom of the data container, and the width of the loading container and the width of the data container are the same as the width of the visible window. In addition, the current page data and the next page data are data in the target page data. In addition, steps 202 to 204 are used to generate the first canvas container and its corresponding first rectangle, and steps 205 to 207 are used to generate the second canvas container and its corresponding second rectangle. Their execution order can be adjusted according to actual conditions, such as first executing steps 202 to 204, and then executing steps 205 to 207. The embodiment of the present invention does not limit this. In step 208, executing the animation function means refreshing the page according to the set frequency, such as setting the frequency to 60Hz, then refreshing 60 times per second. In the embodiment of the present invention, the animation function is executed, and each refresh is performed, step 209 is executed to determine whether the difference between the top of the first rectangle and the top of the second rectangle is not greater than the height of the first rectangle. If so, it is determined that the first canvas container and the second canvas container collide, if not, it is determined that the first canvas container and the second canvas container have not collided at this time, and then the animation function continues to be executed.

[0075] The technical solution for loading page data in the embodiment of the present invention can generate a first canvas container and a second canvas container corresponding to the page data, and detect whether the two canvas containers collide, thereby achieving an infinite loading effect of the page data, solving the limitations and performance instability problems in the prior art, and bringing a better experience to users.

[0076] Figure 3 Schematic diagram of the main modules of the device for loading page data according to an embodiment of the present invention. Figure 3 As shown, the device 300 for loading page data may include: a determination module 301 , a generation module 302 and a loading module 303 .

[0077] The determination module 301 can be used to obtain the target page data and determine the data container and the loading container corresponding to the target page data; the generation module 302 can be used to generate the first canvas container and the second canvas container corresponding to the target page data according to the visible window, the data container and the loading container; the loading module 303 can be used to detect whether the first canvas container and the second canvas container collide, and if so, load the next page data corresponding to the current page data. The current page data and the next page data are both data in the target page data.

[0078] In the embodiment of the present invention, the generation module 302 can also be used to: perform fixed positioning outside the visible window or data container to generate a first canvas container; perform absolute positioning inside the loading container to generate a second canvas container.

[0079] In the embodiment of the present invention, the generation module 302 can also be used to: set the width of the first canvas container to the width of the visible window, set the height of the first canvas container to the height of the visible window; and set the width of the second canvas container to the width of the visible window, and set the height of the second canvas container to the height of the loading container.

[0080] In the embodiment of the present invention, the loading module 303 may also be used to: obtain a first rectangle corresponding to the first canvas container according to the size and position of the first canvas container; and obtain a second rectangle corresponding to the second canvas container according to the size and position of the second canvas container.

[0081] In the embodiment of the present invention, the loading module 303 can also be used to: execute the animation function, and determine whether the difference between the top of the first rectangle and the top of the second rectangle is not greater than the height of the first rectangle; if so, determine that the first canvas container and the second canvas container collide; if not, determine that the first canvas container and the second canvas container do not collide, and continue to execute the animation function.

[0082] In the embodiment of the present invention, the loading module 303 can also be used to: determine whether there is a next page of data according to the current page data and the target page data; if so, asynchronously load the next page of data; if not, end the animation function.

[0083] In the embodiment of the present invention, the loading container is located at the bottom of the data container; and the width of the loading container and the width of the data container are the same as the width of the visible window.

[0084] From the above description, it can be seen that the page data loading device of the embodiment of the present invention can generate a first canvas container and a second canvas container corresponding to the page data, and realize the infinite loading effect of the page data by detecting whether the two canvas containers collide, thereby solving the limitations and performance instability problems in the prior art and bringing a better experience to users.

[0085] Figure 4 An exemplary system architecture 400 is shown to which the method for loading page data or the apparatus for loading page data according to the embodiment of the present invention can be applied.

[0086] like Figure 4 As shown, system architecture 400 may include terminal devices 401, 402, 403, network 404 and server 405. Network 404 is used to provide a medium for communication links between terminal devices 401, 402, 403 and server 405. Network 404 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.

[0087] Users can use terminal devices 401, 402, 403 to interact with server 405 through network 404 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 401, 402, 403, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only as examples).

[0088] The terminal devices 401 , 402 , and 403 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers.

[0089] The server 405 may be a server that provides various services, such as a backend management server (only an example) that provides support for shopping websites browsed by users using the terminal devices 401, 402, and 403. The backend management server may analyze and process the received data such as product information query requests, and feed back the processing results (such as target push information, product information - only an example) to the terminal device.

[0090] It should be noted that the page data loading method provided in the embodiment of the present invention is generally executed by the server 405 , and accordingly, the page data loading device is generally disposed in the server 405 .

[0091] It should be understood that Figure 4 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.

[0092] Reference below Figure 5 , which shows a schematic diagram of the structure of a computer system 500 of a terminal device suitable for implementing an embodiment of the present invention. Figure 5 The terminal device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0093] like Figure 5 As shown, the computer system 500 includes a central processing unit (CPU) 501, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 502 or a program loaded from a storage part 508 into a random access memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the system 500 are also stored. The CPU 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.

[0094] The following components are connected to the I / O interface 505: an input section 506 including a keyboard, a mouse, etc.; an output section 507 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 508 including a hard disk, etc.; and a communication section 509 including a network interface card such as a LAN card, a modem, etc. The communication section 509 performs communication processing via a network such as the Internet. A drive 510 is also connected to the I / O interface 505 as needed. A removable medium 511, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 510 as needed, so that a computer program read therefrom is installed into the storage section 508 as needed.

[0095] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 509, and / or installed from the removable medium 511. When the computer program is executed by the central processing unit (CPU) 501, the above-mentioned functions defined in the system of the present invention are executed.

[0096] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.

[0097] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0098] The modules involved in the embodiments of the present invention may be implemented by software or hardware. The modules described may also be set in a processor, for example, it may be described as: a processor includes a determination module, a generation module and a loading module. The names of these modules do not constitute a limitation on the modules themselves in some cases, for example, the determination module may also be described as "a module for obtaining target page data, determining a data container corresponding to the target page data and a loading container".

[0099] As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiment; or it may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device includes: obtaining target page data, determining the data container and loading container corresponding to the target page data; generating the first canvas container and the second canvas container corresponding to the target page data according to the visible window, the data container and the loading container; detecting whether the first canvas container and the second canvas container collide, and if so, loading the next page data corresponding to the current page data; wherein the current page data and the next page data belong to the data in the target page data.

[0100] According to the technical solution of the embodiment of the present invention, a first canvas container and a second canvas container corresponding to the page data can be generated. By detecting whether the two canvas containers collide, an infinite loading effect of the page data can be achieved, thereby solving the limitations and performance instability problems in the prior art and bringing a better experience to users.

[0101] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A method for loading page data, characterized in that: include: Acquire target page data, and determine a data container and a loading container corresponding to the target page data; Generate a first canvas container and a second canvas container corresponding to the target page data according to the visible window, the data container and the loading container; Detecting whether the first canvas container and the second canvas container collide, and if so, loading next page data corresponding to the current page data, including: obtaining a first rectangle corresponding to the first canvas container, obtaining a second rectangle corresponding to the second canvas container, executing an animation function, and determining whether a difference between a top of the first rectangle and a top of the second rectangle is not greater than a height of the first rectangle; if so, determining that the first canvas container and the second canvas container collide; if not, determining that the first canvas container and the second canvas container do not collide, and continuing to execute the animation function; wherein the current page data and the next page data belong to data in the target page data.

2. The method according to claim 1, characterized in that The step of generating a first canvas container and a second canvas container corresponding to the target page data according to the visible window, the data container and the loading container includes: Performing fixed positioning outside the visible window or the data container to generate the first canvas container; Perform absolute positioning inside the loading container to generate the second canvas container.

3. The method according to claim 2, characterized in that After generating the first canvas container, the method further includes: setting the width of the first canvas container to the width of the visible window, and setting the height of the first canvas container to the height of the visible window; and After generating the second canvas container, the method further includes: setting the width of the second canvas container to the width of the visible window, and setting the height of the second canvas container to the height of the loading container.

4. The method according to claim 1, characterized in that: The obtaining a first rectangle corresponding to the first canvas container includes: According to the size and position of the first canvas container, obtaining a first rectangle corresponding to the first canvas container; The acquiring the second rectangle corresponding to the second canvas container includes: acquiring the second rectangle corresponding to the second canvas container according to the size and position of the second canvas container.

5. The method according to claim 1, characterized in that: Before loading the next page of data corresponding to the current page of data, the method further includes: According to the current page data and the target page data, determining whether the next page data exists; If yes, then the next page of data is asynchronously loaded; if no, then the animation function is terminated.

6. The method according to claim 1, characterized in that The loading container is located at the bottom of the data container; and the width of the loading container and the width of the data container are the same as the width of the visible window.

7. A device for loading page data, characterized in that: include: A determination module, used to obtain target page data and determine a data container and a loading container corresponding to the target page data; A generating module, used for generating a first canvas container and a second canvas container corresponding to the target page data according to the visible window, the data container and the loading container; A loading module is used to detect whether the first canvas container and the second canvas container collide, and if so, load the next page data corresponding to the current page data, including: obtaining a first rectangle corresponding to the first canvas container, obtaining a second rectangle corresponding to the second canvas container, executing an animation function, and determining whether the difference between the top of the first rectangle and the top of the second rectangle is not greater than the height of the first rectangle; if so, determining that the first canvas container and the second canvas container collide; if not, determining that the first canvas container and the second canvas container do not collide, and continuing to execute the animation function; wherein, The current page data and the next page data belong to the data in the target page data.

8. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 6.

9. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Webpage display method and system of mobile terminal

    CN106055600A

  • Home page presentation method of smart television based on Web video preview

    CN110809185A