Detailed Description
The application is described in further detail below with reference to the drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the application and are not limiting thereof. It should be further noted that, for convenience of description, only some, but not all of the structures related to the present application are shown in the drawings.
The technical terms related to the application are as follows:
vue: is a set of progressive JavaScript frames for building user interfaces designed to be applied layer by layer from bottom up. The core library of Vue only focuses on the view layer, facilitating integration with third party libraries or existing items. Vue is fully capable of driving complex single page applications that employ single file components and Vue ecosystem-supported library development.
jQuery: the method is a quick and simple JavaScript framework, encapsulates common function codes of JavaScript, provides a simple JavaScript design mode, and optimizes HTML document operation, event processing, animation design and Ajax interaction. The plug-in expansion mechanism is convenient, plug-ins are abundant, and the plug-in expansion mechanism is compatible with various mainstream browsers.
Mobiscrol: is a date and time selector UI component for touch devices whose use does not alter the native user experience of HTML5, phoneGap, and hybrid applications. As a jQuery sliding selection plug-in, a user can customize a theme style and add colors for the UI components of the mobile items. Mobiscrol can be used as an implementation of the preset plug-in of the present application.
Doms: is an abbreviation for Document Object Model document object model. According to the W3C DOM specification, DOM is a browser, platform, language independent interface that allows users to access other standard components in the page, and DOM is a collection of nodes or pieces of information organized in a hierarchy. The hierarchy allows a developer to navigate through the tree for specific information. Analyzing the structure typically requires loading the entire document and constructing the hierarchy before doing anything. Since it is based on an information hierarchy, dom is considered tree-based or object-based.
Class: is a class selector that allows styles to be specified in a manner that is independent of the document elements. Before using the class selector, the specific document markup needs to be modified in order for the class selector to function properly. In order to associate a style of class selector with an element, class must be specified as an appropriate value, class can be referenced multiple times.
Index: list subscript, its initial value is 0.
Example 1
Fig. 1 is a flowchart of a response method of a sliding operation provided in an embodiment of the present application, where the method may be performed by a mobile terminal, and the mobile terminal may be a device with a touch screen, such as a smart phone, a tablet computer, or the like, and the method specifically includes the following steps:
step 110, determining the sliding distance according to the sliding operation.
When the user slides on the touch screen, the sliding operation is triggered. And determining the sliding distance according to the track length corresponding to the sliding operation.
Further, before determining the sliding distance according to the sliding operation in step 110, the method further includes:
configuring nodes with anti-response changing requirements in a document object model;
and determining a node list according to the configured node class with the anti-response change requirement.
The terminal screen area includes one or more document object models dom having a hierarchical structure. Node class with anti-response requirement is preconfigured. The document object model dom displays the node list through a view. Node class with anti-response change requirement can be configured in the dom, and then a node list of the content node class in the dom is obtained.
Further, the node list contains data recorded based on time;
the preset plug-in is a mobiscrol component.
The preset component can be implemented in a variety of ways. Optionally, the preset plug-in is a mobiscrol component. And outputting the time component through the Mobiescroll component. In addition, the node class in the node list may be a node for documenting user billing information. In the above-described scenario, it is possible to implement a mobiscrol component in which when the user slides the billing information, the user displays the time corresponding to the billing information, and the update of the time content is performed in accordance with the sliding operation output by the user.
Step 120, calculating the corresponding offset of the sliding distance in the document object model.
Optionally, before calculating the corresponding offset of the sliding distance in the document object model in step 120, the method further includes:
an offset constant for the view is determined based on the screen width.
And calculating according to the screen width and preset parameters to obtain an offset constant.
Alternatively, the offset constant may be calculated by the following formula:
offset constant=100× (screen width/750) ×c
Wherein, C is a preset parameter, and the value range of the preset parameter C can be 0.9-3.0. Preferably 1.95. The value of the preset parameter can be determined according to the factors such as the size relation between the dot structure of the display node list and the screen.
Alternatively, calculating the corresponding offset of the sliding distance in the document object model may be implemented by:
if the node list subscript is not equal to the node list length minus one, determining a downward offset according to the top coordinate of the document object model, the next undisplayed node coordinate of the target node and the sliding distance, wherein the target node is the node of the node list displayed at the lowest part in the view.
The nodes in the node list may be represented by a node list x. The node sequence number of the node list starts from 0. The target node may be a node list index node. And judging whether the node list subscript is not equal to the node list length minus one, if the node list subscript is not equal to the node list length minus one, calculating a downward offset, wherein the downward offset is the value of the list [ index+1] element minus the sliding distance from the top distance. Wherein, the top refers to the top of the dom structure where the node list is located.
If the node list subscript is equal to the node list length minus one, the downward offset is infinity.
Further, an upward offset is calculated, which is the target node (list [ index ] element) to dom top distance minus the sliding distance.
And 130, determining a node list index according to the size relation between the offset and the offset constant.
Optionally, determining the node list subscript according to the magnitude relation of the offset and the offset constant may be implemented as:
step 301, determining whether the downward offset is less than or equal to an offset constant.
And 302, if the downward offset is smaller than or equal to the offset constant, determining the index of the next undisplayed node of the target node in the node list as the node list index, and adding one to the node list index.
Wherein the list index is index, and the next node not shown in the target node is index+1. The list index being incremented by one means that the list index is incremented by one based on the current value. And assigning the change content corresponding to the list [ index+1] to a value to be inversely responsive to the change in the mobiscrol, and then adding one to the list index.
Further, after determining whether the downward offset is equal to or less than the offset constant, the method further includes:
step 303, if the downward offset is greater than the offset constant, determining whether the upward offset is greater than the offset constant.
If the upward offset is greater than the offset constant, step 304 is performed. If the upward offset is less than the offset constant, step 307 is performed.
Step 304, if the upward offset is greater than the offset constant, determining whether the subscript of the node list is not zero.
If the index of the node list is not zero, step 305 is performed. If the index of the node list is zero, step 306 is performed.
Step 305, if the index of the node list is not zero, determining the index of the last displayed node of the target node as the index of the node list, and subtracting one from the index of the node list.
Step 306, if the subscript of the node list is zero, exiting.
Step 307, if the upward offset is smaller than the offset constant, exiting.
Judging whether the downward offset is smaller than or equal to the offset constant, if so, assigning the change content corresponding to the list [ index+1] to a value needing to respond to the change in the mobile scroll, and then adding 1 to the list index; otherwise, it is determined whether the upward offset is greater than an offset constant. If so, it is determined whether the list index is 0. If 0, exit. If the value is not 0, the change content corresponding to the list [ index-1] is assigned to a value needing to respond to the change in the mobile scroll, and then the list index is reduced by 1.
And 140, feeding back the content of the target node corresponding to the node list index to a preset plug-in, so that the preset plug-in outputs the anti-response content corresponding to the sliding operation.
According to the stream data processing method provided by the embodiment of the application, the sliding distance is determined according to the sliding operation; calculating the corresponding offset of the sliding distance in the document object model; determining node list subscripts according to the size relation between the offset and the offset constant; and feeding back the content of the target node corresponding to the node list index to a preset plug-in, so that the preset plug-in outputs the anti-response content corresponding to the sliding operation. According to the response method for the sliding operation, the sliding distance can be obtained according to the sliding operation of the user, the node list subscript is determined according to the size relation between the offset and the offset constant, and the response content output by the preset plug-in is determined according to the node list subscript. The parameters used in the calculation process are not influenced by other sliding events, so that the anti-response content corresponding to the sliding operation output by the preset plug-in unit can be accurately determined, and the anti-response accuracy of the sliding operation is improved. And quickly determining the node list index according to the sliding distance, so that the preset plug-in unit can smoothly output contents.
Example two
Fig. 2 is a flowchart of a response method of a sliding operation according to an embodiment of the present application, which further illustrates the above embodiment, including:
step 201, configuring node class with anti-response change requirements in a document object model; the node columns are determined according to the node class of the configuration, which is in inverse response to the changing requirement.
Step 202, determining the offset constant of the view according to the screen width.
Step 203, determining the sliding distance according to the sliding operation.
Step 204, calculating the downward offset.
If the node list subscript is not equal to the node list length minus one, determining a downward offset according to the top coordinate of the document object model, the next undisplayed node coordinate of the target node and the sliding distance, wherein the target node is the node of the node list displayed at the lowest part in the view. If the node list subscript is equal to the node list length minus one, the downward offset is infinity.
Step 205, calculating the upward offset.
Subtracting the sliding distance from the target node to the top of the dom structure, to obtain the upward offset.
Step 206, judging whether the downward offset is smaller than or equal to the offset constant;
step 207, if the downward offset is less than or equal to the offset constant, determining the index of the next node not shown in the target node in the node list as the node list index, and adding one to the node list index.
Step 208, if the downward offset is greater than the offset constant, determining whether the upward offset is greater than the offset constant.
Step 209, if the upward offset is greater than the offset constant, determining whether the subscript of the node list is not zero.
Step 210, if the subscript of the node list is not zero, determining the subscript of the last displayed node of the target node as the node list subscript, and subtracting one from the node list subscript.
Step 211, feeding back the content of the target node corresponding to the node list index to the preset plugin, so that the preset plugin outputs the anti-response content corresponding to the sliding operation.
The method has the anti-response capability, prevents possible sliding events from being captured unknown, achieves high accuracy and smooth response, and can be suitable for various sliding plug-ins and scenes needing the anti-response capability, and achieves the effects of smooth sliding and self-definition of boundary values.
Example III
Fig. 3 is a schematic structural diagram of a stream data processing apparatus according to a third embodiment of the present application, where the present embodiment is applicable to a situation of performing an anti-response according to a user sliding operation, and the method may be performed by a mobile terminal, where the mobile terminal may be a device with a touch screen, such as a smart phone, a tablet computer, or the like, and the apparatus specifically includes: a sliding distance determination module 310, an offset calculation module 320, a subscript determination module 330, and a plug-in response module 340.
A sliding distance determining module 310 for determining a sliding distance according to a sliding operation;
an offset calculating module 320, configured to calculate an offset corresponding to the sliding distance in the document object model;
a subscript determining module 330, configured to determine a node list subscript according to a magnitude relation between the offset and the offset constant;
and the plug-in response module 340 is configured to feed back the content of the target node corresponding to the node list index to the preset plug-in, so that the preset plug-in outputs the anti-response content corresponding to the sliding operation.
On the basis of the embodiment, the device further comprises a configuration module and an offset constant determining module. Wherein, the configuration module is used for:
configuring nodes with anti-response changing requirements in a document object model;
and determining a node list according to the configured nodes with the anti-response change requirements.
On the basis of the above embodiment, the device further comprises an offset constant determining module, wherein the offset constant determining module is used for: an offset constant for the view is determined based on the screen width.
On the basis of the above embodiment, the offset calculation module 320 is configured to:
if the node list subscript is not equal to the node list length minus one, determining a downward offset according to the top coordinate of the document object model, the next undisplayed node coordinate of the target node and the sliding distance, wherein the target node is the node of the node list displayed at the lowest part in the view;
if the node list subscript is equal to the node list length minus one, the downward offset is infinity;
subtracting the sliding distance from the target node to the top of the dom structure, to obtain the upward offset.
On the basis of the above embodiment, the subscript determination module 330 is configured to:
judging whether the downward offset is smaller than or equal to an offset constant or not;
if the downward offset is smaller than or equal to the offset constant, determining the index of the next undisplayed node of the target node in the node list as the node list index, and adding one to the node list index.
On the basis of the above embodiment, the subscript determination module 330 is further configured to:
if the downward offset is greater than the offset constant, judging whether the upward offset is greater than the offset constant;
if the upward offset is greater than the offset constant, judging whether the subscript of the node list is not zero;
if the subscript of the node list is not zero, determining the subscript of the last displayed node of the target node as the subscript of the node list, and subtracting one from the subscript of the node list;
and if the subscript of the node list is zero, exiting.
On the basis of the above embodiment, the node list contains data recorded on a time basis; the preset plug-in is a mobiscrol component.
The embodiment of the present application provides a stream data processing apparatus, a sliding distance determining module 310, configured to determine a sliding distance according to a sliding operation; an offset calculating module 320, configured to calculate an offset corresponding to the sliding distance in the document object model; a subscript determining module 330, configured to determine a node list subscript according to a magnitude relation between the offset and the offset constant; and the plug-in response module 340 is configured to feed back the content of the target node corresponding to the node list index to the preset plug-in, so that the preset plug-in outputs the anti-response content corresponding to the sliding operation. According to the response method for the sliding operation, the sliding distance can be obtained according to the sliding operation of the user, the node list subscript is determined according to the size relation between the offset and the offset constant, and the response content output by the preset plug-in is determined according to the node list subscript. The parameters used in the calculation process are not influenced by other sliding events, so that the anti-response content corresponding to the sliding operation output by the preset plug-in unit can be accurately determined, and the anti-response accuracy of the sliding operation is improved. And quickly determining the node list index according to the sliding distance, so that the preset plug-in unit can smoothly output contents.
The stream data processing device provided by the embodiment of the application can execute the stream data processing method provided by any embodiment of the application, and has the corresponding functional modules and beneficial effects of the execution method.
Example IV
Fig. 4 is a schematic structural diagram of a response terminal for sliding operation according to a fourth embodiment of the present application, and as shown in fig. 4, the response terminal for sliding operation includes a processor 40, a memory 41, an input device 42 and an output device 43; the number of processors 40 in the response terminal to the sliding operation may be one or more, and one processor 40 is taken as an example in fig. 4; the processor 40, the memory 41, the input device 42 and the output device 43 in the response terminal to the sliding operation may be connected by a bus or other means, for example by a bus connection in fig. 4.
The memory 41 is a computer-readable storage medium that can be used to store a software program, a computer-executable program, and modules such as program instructions/modules corresponding to the stream data processing method in the embodiment of the present application (for example, a sliding distance determination module 310, an offset calculation module 320, a subscript determination module 330, a plug-in response module 340, a configuration module, and an offset constant determination module in the stream data processing apparatus). The processor 40 performs various functional applications of the response terminal for a sliding operation and data processing, that is, implements the above-described stream data processing method by running software programs, instructions, and modules stored in the memory 41.
The memory 41 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, at least one application program required for functions; the storage data area may store data created according to the use of the terminal, etc. In addition, memory 41 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid-state storage device. In some examples, memory 41 may further include memory remotely located relative to processor 40, which may be connected to the response terminal for the sliding operation via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The input device 42 may be used to receive input numeric or character information and to generate key signal inputs related to user settings and function control of the responsive terminal for a sliding operation. The output means 43 may comprise a display device such as a display screen.
Example five
A fifth embodiment of the present application also provides a storage medium containing computer-executable instructions, which when executed by a computer processor, are for performing a response method of a sliding operation, the method comprising:
determining a sliding distance according to the sliding operation;
calculating the corresponding offset of the sliding distance in the document object model;
determining node list subscripts according to the size relation between the offset and the offset constant;
and feeding back the content of the target node corresponding to the node list index to a preset plug-in, so that the preset plug-in outputs the anti-response content corresponding to the sliding operation.
On the basis of the above embodiment, before determining the sliding distance according to the sliding operation, further comprising:
configuring nodes with anti-response changing requirements in a document object model;
and determining a node list according to the configured nodes with the anti-response change requirements.
On the basis of the above embodiment, before determining the node list subscript according to the magnitude relation between the offset and the offset constant, the method further includes:
an offset constant for the view is determined based on the screen width.
On the basis of the above embodiment, calculating the offset amount of the sliding distance corresponding to the document object model includes:
if the node list subscript is not equal to the node list length minus one, determining a downward offset according to the top coordinate of the document object model, the next undisplayed node coordinate of the target node and the sliding distance, wherein the target node is the node of the node list displayed at the lowest part in the view;
if the node list subscript is equal to the node list length minus one, the downward offset is infinity;
subtracting the sliding distance from the target node to the top of the dom structure, to obtain the upward offset.
On the basis of the above embodiment, determining the node list subscript according to the magnitude relation between the offset and the offset constant includes:
judging whether the downward offset is smaller than or equal to an offset constant or not;
if the downward offset is smaller than or equal to the offset constant, determining the index of the next undisplayed node of the target node in the node list as the node list index, and adding one to the node list index.
On the basis of the above embodiment, after determining whether the downward offset is equal to or smaller than the offset constant, the method further includes:
if the downward offset is greater than the offset constant, judging whether the upward offset is greater than the offset constant;
if the upward offset is greater than the offset constant, judging whether the subscript of the node list is not zero;
if the subscript of the node list is not zero, determining the subscript of the last displayed node of the target node as the subscript of the node list, and subtracting one from the subscript of the node list;
and if the subscript of the node list is zero, exiting.
On the basis of the above embodiment, the node list contains data recorded on a time basis; the preset plug-in is a mobiscrol component.
Of course, the storage medium containing the computer executable instructions provided in the embodiments of the present application is not limited to the above method operations, and may also perform the related operations in the stream data processing method provided in any embodiment of the present application.
From the above description of embodiments, it will be clear to a person skilled in the art that the present application may be implemented by means of software and necessary general purpose hardware, but of course also by means of hardware, although in many cases the former is a preferred embodiment. Based on such understanding, the technical solution of the present application may be embodied essentially or in a part contributing to the prior art in the form of a software product, which may be stored in a computer readable storage medium, such as a floppy disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a FLASH Memory (FLASH), a hard disk or an optical disk of a computer, etc., comprising several instructions for causing a response terminal (which may be a personal computer, a server, a network device, etc.) for performing the method of the embodiments of the present application.
It should be noted that, in the embodiment of the apparatus, each unit and module included are only divided according to the functional logic, but not limited to the above-mentioned division, so long as the corresponding function can be implemented; in addition, the specific names of the functional units are also only for distinguishing from each other, and are not used to limit the protection scope of the present application.
Note that the above is only a preferred embodiment of the present application and the technical principle applied. It will be understood by those skilled in the art that the present application is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the application. Therefore, while the application has been described in connection with the above embodiments, the application is not limited to the embodiments, but may be embodied in many other equivalent forms without departing from the spirit or scope of the application, which is set forth in the following claims.