Pure JavaScript Move-first slide effect _javascript tips

Source: Internet
Author: User
Tags goto

Brief tutorial
Wallop is a mobile-priority pure JavaScript slide plugin. This slide plugin is only 4k in size, and its rationale is simply to add and remove the appropriate classes for HTML elements to show and hide them, and you can completely customize these class styles. Features are:
Move First
Both animation and transition effects use CSS to generate
Lightweight, 4k size only
High degree of flexibility and scalability
Customizable events and APIs
Without any external dependencies

How to use
using this slide plugin you first need to introduce WALLOP.CSS and Wallop.min.js files.

<link rel= "stylesheet" href= "Path/to/wallop.css" >
<script src= "Path/to/wallop.min.js" ></script >      

HTML structure

The basic HTML structure of the slide is as follows, and you can add slide for the first slide. Wallop-item--current class.

<div class= "Wallop" >
 <div class= "wallop-list" >
  <div class= "Wallop-item" >...</div>
  <div class= "Wallop-item" >...</div>
  <div class= "Wallop-item" >...</div>
  <div class= "Wallop-item" >...</div>
  <div class= "Wallop-item" >...</div>
 </div>
 < Button class= "wallop-buttonprevious" >Previous</button>
 <button class= "Wallop-buttonnext" >next </button>
</div>        

Initializing Plug-ins

<script>
 var wallopel = Document.queryselector ('. Wallop ');
 var slider = new Wallop (Wallopel);
</script>        

Add animation effects

The slide plugin default is no animation transition effect, if you need to add animation effect, you need to introduce the corresponding WALLOP-ANIMATION.CSS file, and add Wallop--xxxx class for the element. For example, to add a fade effect:

 
 

Available animation types

The transition animation types available for this slide are:
Wallop--slide
Wallop--fade
Wallop--scale
Wallop--rotate
Wallop--fold
Wallop--vertical-slide

There are some built-in transition animation types, and you can customize your own transition animation.
Configuration Parameters
The following are some of the configuration parameters available:
Buttonpreviousclass: ' Wallop-buttonprevious '
Buttonnextclass: ' Wallop-buttonnext '
Itemclass: ' Wallop-item '
Currentitemclass: ' Wallop-item--current '
Showpreviousclass: ' Wallop-item--showprevious '
Shownextclass: ' Wallop-item--shownext '
Hidepreviousclass: ' Wallop-item--hideprevious '
Hidenextclass: ' Wallop-item--hidenext '
Carousel:true
Method
The Wallop slide plugin provides some basic methods for Button control:
GoTo

Allows you to jump to a slide on the specified index.

var slider = Document.queryselector ('. Wallop ');
var wallop = new Wallop (slider);
 
Jumps to the second slide (index starting from 0)
Wallop.goto (1);        

Next

Jump to the next slide slide.

var slider = Document.queryselector ('. Wallop ');
var wallop = new Wallop (slider);
 
Jump to the next slide
wallop.next ();        

Previous

Jumps to the previous slide slide.

var slider = Document.queryselector ('. Wallop ');
var wallop = new Wallop (slider);
 
Jump to the previous slide
wallop.previous ();        

Event
Wallop sends an event every time the slide changes, it returns a detail object that contains the index and wallop objects of the current slide.

var slider = Document.queryselector ('. Wallop ');
var wallop = new Wallop (slider);
 
Wallop.on (' Change ', function (event) {
 //event.detail.wallopEl
 //=> <div class= "Wallop" >...</ Div>
 
 //Event.detail.currentItemIndex
 //=> number
});        

The above is a pure JavaScript mobile priority for you to share the production process, hoping to help you make more beautiful slide effect.

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.