More and more web apps on the phone, introducing a handy tool slip.js
Sweep to see the effect:
With Slip.js , you just write html,css, if logic is simple, a line of JS code can be done, greatly improve the efficiency of development. No bragging, the above demo, in less than half an hour I will write well.
How do you do it specifically? For example, there is a requirement:
We have 4 pages, one for each page, and one for each finger swipe.
First Look at HTML:
<!doctype html>...<script type= "Text/javascript" src= "Slip.js" ></script><body>...<div Id= "Container" > <div class= "page page-1" ></div> <div class= " Page page-2 "></div> <div class=" page page-3 "></div> <div class= "page page-4" ></div></div></body >
Last Look at JS:
var container = document.getElementById (' container '); var pages = Document.queryselectorall ('. Page '); var slip = slip (container, ' Y '). WebApp (pages);
Explanation:
-
Slip: Exposure to the global approach, as long as you introduce slip.js , you can get this practical method.
-
container: The container being slid, inside is each sliding page.
-
‘y‘: page swipe direction, you can also pass in ‘x‘ .
-
webapp: Sets the way the page is displayed as a full screen slide.
-
pages: A list of page elements.
A good line of code is done:
Slip(document.getElementById(‘container‘), ‘y‘).webapp();
You can see that the preceding line of code is not defined pages :
When a webapp method does not pass a parameter, slip acquires container the immediate child element (the son element) as the pages .
At this point, a full-screen sliding Web page is complete, difficult to imagine simple and fast. I'll take half an hour, you should be there in 10 minutes.
Of course: Slip.js There are many more powerful features, such as what you can do to define your own page sliding, PM to see what you have done so quickly, you have added a very interesting demand:
When the page slides to the last page, refresh ...
You just need to add a few lines of code to get it done:
Slip(document.getElementById(' Container '),' Y ').webapp (end (function ({if .page === 3) Locationreload (})
See, is not very simple, is not enough to complain about this demand, has finished it, is not an unprecedented thrill.
Slip.js Chinese API Address: http://binnng.github.io/slip.js/docs/
Source Address: http://binnng.github.io/slip.js/docs/slip.html
This article originates from: Http://www.html-js.com/article/Slipjs-used-to-create-full-screen-slide-fast-Slipjs-mobile-phone-Webpage
Use Slip.js to quickly create a full screen swipe on a mobile page