Ouchbox
Original: Https://github.com/maxzhang/touchbox
Mobile single-page view library for mobile theme making
DEMO
Http://jsbin.com/vatuma/latest
Mobile Scan the following QR code to see the example:
How to use
First, the page must be the following structure
<html> //... <body> <id="Touchboxct" > <div>//Sub-view 1 </div> <Div >//Sub-view 2 </div> <div>//Child view 3 </div> </div> </body></ html>
Initial CSS, except for the following two styles, Touchbox does not depend on any other style
/* If the body margin is not set to 0, it will cause the view aspect calculation inaccurate */div { 0; 0;}
Touchbox (' #touchBoxCt', { looptrue, animation' Flow'});
Configuration parameter configsitemselector:string
Child View Selector, default ', if set, use selector-selected child elements for view switching
Active:number
First view index, default 0, first child element by default
Loop:boolean
Whether the child view toggle can be cycled, by default false
Animation:string
View Toggle animation effect, default ' flow ', Value range: ' Slide ', ' flow '
Duration:number
View Toggle animation time, default 400, Unit MS
Lockscreen:string
Lock screen status, default ' off ', value:
- ' Off ' does not lock screen
- ' Landscape ' locked for horizontal screen
- ' Portrait ' Locked to vertical screen
Rotatebody:string/function
The lock screen prompt is valid when the lockscreen is not ' off '.
When the value is string, the HTML string is inserted into the page and displayed.
When the value is function, the return values of the function are inserted into the page and displayed.
beforeslide:functiondeprecated, using event interface overrides
The callback function when the child view starts to toggle, or if the return value is false, terminates the secondary switch operation.
callback function Parameters:
- Toindex Switch to view index
- Active Current View Index
onslide:functiondeprecated, using event interface overrides
callback function at end of child view toggle
callback function Parameters:
- Active Current View Index
onresize:function deprecated, using event interface overrides
Called when Touchbox aspect is reset.
callback function Parameters:
- Width height
- Height width
Scope:object
Scope of the callback function
Events Event
callback function Event Listener method:
Boxer. On (' beforeslidefunction (console. Log (' to index:' current index:', Activeindex);});
Touchstart
Touchstart event, return False to abort this touch action.
callback function Parameters:
- Active Current View Index
Touchmove
The Touchmove event, which returns false, aborts the view offset.
callback function Parameters:
- Active Current View Index
- OffsetY y-axis position offset, greater than 0 means the finger moves up, less than 0 means the finger moves down
Touchend
The Touchend event, which returns false, aborts the view toggle and resets the view to the current view.
callback function Parameters:
- Active Current View Index
- OffsetY y-axis position offset, greater than 0 means the finger moves up, less than 0 means the finger moves down
Beforeslide
The callback function when the child view starts to toggle, or if the return value is false, terminates the secondary switch operation.
callback function Parameters:
- Toindex Switch to view index
- Active Current View Index
Slide
callback function at end of child view toggle
callback function Parameters:
- Active Current View Index
Resize
Called when Touchbox aspect is reset
callback function Parameters:
- Width height
- Height width
Mobile Single-page view library for making mobile web Touchbox