Swiper to realize the swipe effect of smug app

Source: Internet
Author: User

First, smug app effect:

My demand is this, the above normal sliding, click on the small card below, the above sliding area also switch to the current click state.

Second, realize:

Css:

Mainly set the location of several cards in the visible area, the attention of several places is, the middle of the activation state and the left and right side of the elements, Swiper has been running when they added a fixed class name.

Html:

<!--swiper--<div class= "Swiper-container" > <div class= "swiper-wrapper" > <div class= "Swiper-slide" > Empress <p class= "card-btn" > Give a friend </p> </div> &lt            ;d IV class= "Swiper-slide" > World <p class= "CARD-BTN" > Give a friend a photo </p> </div>            <div class= "Swiper-slide" > Star <p class= "card-btn" > Give a friend </p> </div> <div class= "Swiper-slide" > Moon <p class= "Card-btn" > Give a friend a photo </p> </div&            Gt            <div class= "Swiper-slide" > Magician <p class= "card-btn" > Give a friend a photo </p> </div> <div class= "Swiper-slide" > Sun <p class= "card-btn" > Give a friend a photo </p> </div&gt        ; </div> </div> <div class= "Contrast-box" > <ul> <li data-index= "5" > MagicDivision </li> <li data-index= "6" > Sun </li> <li data-index= "1" > Empress </li> <li data-index= "2" > World </li> <li data-index= "3" > Stars </li> <li data-index= "4  "> Moon </li> <li class=" combin-btn "> Crafting </li> </ul> </div> <div class= "Button-next" ></div> <div class= "Button-prev" ></div>

  

Javascript:

var myswiper = new Swiper ('. Swiper-container ', {        nextbutton: '. Swiper-button-next ',        Prevbutton: '. Swiper-button-prev ',        effect: ' Coverflow ',//3d sliding        grabcursor:true,        centeredslides:true,        Slidesperview: ' Auto ',        loop:true,        slidesperview:2,        coverflow: {            rotate:0,  //set to 0            stretch:0,            depth:200,            modifier:2,            slideshadows:true        }        });    $ ('. Contrast-box '). On (' Click ', ' Li:not (. combin-btn) ', function () {        var _index = $ (this). Data (' index ') + 1;        Myswiper.slideto (_index, x, False);//Switch to the first slide with a speed of 1 seconds    });    $ ('. Button-prev '). Click (function () {        myswiper.slideprev ();    })    $ ('. Button-next '). Click (function () {        myswiper.slidenext ();    })

To achieve the effect of the Love app, just set a little style on the left and right elements of the middle active element.

Iii. Summary

Swiper to the low version of IE browser and some low-end phone support is not very good, after all, swiper use some advanced C3 properties, but can be learned from the implementation of swiper the principle of a lot of dry.

Swiper to realize the swipe effect of smug app

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.