Swiper is a modern mobile touch slider with hardware accelerated transitions and native behaviour. It is intended to be used in mobile websites and mobile apps (ad-slot). The Swiper is not compatible with all platforms, for instance the 3D Cube (setting) will not work well in older Internet Explorer versions and Android phones with the native "browser" or even old Chrome browsers.
We have some basic format banners with the swiper library already imported and ready to use. Formats like a 300x250, 320x240 and full-page (interstitial). Please contact support@weborama.nl for these templates.
If you have a different format where you would like to add a swiper library, or you already have a creation and would like to add the swiper library, follow the instructions bellow.
Add the Swiper Library to existing creation
- Add the Swiper library from our CDN
<script type="text/javascript" src="//media.adrcdn.com/ad-resources/swiper/weborama.swiper.1.0.7.min.js"></script>
-
Add the Swiper CSS from our CDN
<link rel="stylesheet" href="//media.adrcdn.com/ad-resources/swiper/weborama.swiper.1.0.7.min.css">
-
Add the Swiper basic HTML
<div class="webo-swiper-icon"></div>
<div class="swiper-container">
<!-- Pagination -->
<div class="swiper-pagination"></div>
<!-- You can adjust the color of the paginationType in styles.css-->
<!-- Arrows -->
<div class="swiper-button-next swiper-button-white"></div>
<div class="swiper-button-prev swiper-button-white"></div>
<!-- You can adjust the color to black by changing "white" into "black"
Add the class swipe-up and swipe-down to the arrows if you make use of a vertical direction -->
<div class="swiper-wrapper">
<div data-report="slide001" class="swiper-slide" style="background-image:url(side_01.jpg)" onclick="screenad.click();"></div>
<div data-report="slide002" class="swiper-slide" style="background-image:url(side_02.jpg)" onclick="screenad.click('extra1');"></div>
<div data-report="slide003" class="swiper-slide" style="background-image:url(side_03.jpg)" onclick="screenad.click('extra2');"></div>
<div data-report="slide004" class="swiper-slide" style="background-image:url(side_04.jpg)" onclick="screenad.click('extra3');"></div>
<!-- You can easily add more slides to the swiper container, just copy-paste the above div and adjust the background image -->
</div>
</div> -
Initialize Swiper
var swiper = new Swiper('.swiper-container', {
effect: 'cube',
direction: 'horizontal',
speed: 700,
autoplay: 1500,
loop: true
}); -
Add optional callbacks for the swiper
swiper.on('onSlideChangeEnd', function () {
console.log('current slide: ', swiper.slides[swiper.activeIndex]);
console.log('data-report: ', swiper.slides[swiper.activeIndex].getAttribute('data-report'));
console.log('user engaged?: ', swiper.userEngaged());
});
Swiper Parameters
Parameter | Type | Default | Description |
---|---|---|---|
initialSlide | number | 0 | Index number of initial slide. |
direction | string | 'horizontal' | Could be 'horizontal' or 'vertical' (for vertical slider). |
speed | number | 300 | Duration of transition between slides (in ms) |
weboSwipeIcon | boolean | true | Show or hide the Swipe Icon. True, false or remove (remove will show the icon in touch device, not in desktop) |
Autoplay | |||
autoplay | number | - |
Delay between transitions (in ms). If this parameter is not specified, auto play will be disabled. If you need to specify different delay for specifi slides you can do it by using
|
autoplayStopOnLast | boolean | false | Enable this parameter and autoplay will be stopped when it reaches last slide (has no effect in loop mode) |
autoplayDisableOnInteraction | boolean | true | Set to false and autoplay will not be disabled after user interactions (swipes), it will be restarted every time after interaction |
Effects | |||
effect | string | 'slide' | Could be "slide", "fade", "cube", "coverflow" or "flip" |
fade | object |
|
Fade effect parameters |
cube | object |
|
Cube effect parameters. For better performance you may disable shadows |
coverflow | object |
|
Coverflow effect parameters. For better performance you may disable shadows |
flip | object |
|
Flip effect parameters. limitRotation (when enabled) limits slides rotation angle to 180deg maximum. It allows to quickly "flip" between different slides. If you use "slow" transitions then it is better to disable it. |
Parallax | |||
parallax | boolean | false | Enable, if you want to use "parallaxed" elements inside of slider |
Slides grid | |||
spaceBetween | number | 0 | Distance between slides in px. |
slidesPerView | number or 'auto' | 1 |
Number of slides per view (slides visible at the same time on slider's container). If you use it with "auto" value and along with loop: true then you need to specify loopedSlides parameter with amount of slides to loop (duplicate) slidesPerView: 'auto' is currently not compatible with multirow mode, when slidesPerColumn > 1 |
centeredSlides | boolean | false | If true, then active slide will be centered, not always on the left side. |
Touches | |||
touchEventsTarget | string | 'container' | Target element to listen touch events on. Can be 'container' (to listen for touch events on swiper-container) or 'wrapper' (to listen for touch events on swiper-wrapper) |
simulateTouch | boolean | true | If true, Swiper will accept mouse events like touch events (click and drag to change slides) |
Pagination | |||
pagination | string / HTMLElement | null | String with CSS selector or HTML element of the container with pagination |
paginationType | string | 'bullets' | String with type of pagination. Can be "bullets", "fraction", "progress" or "custom" |
paginationHide | boolean | true | Toggle (hide/true) pagination container visibility when click on Slider's container |
paginationClickable | boolean | false | If true then clicking on pagination button will cause transition to appropriate slide. Only for bullets pagination type |
paginationElement | string | 'span' | Defines which HTML tag will be use to represent single pagination bullet. . Only for bullets pagination type |
paginationBulletRender(swiper, index, className) | function | null | This parameter allows totally customize pagination bullets, you need to pass here a function that accepts index number of pagination bullet and required element class name (className). Only for bullets pagination type
For example, with this code, we can add slide number into pagination bullet:
|
Navigation Buttons | |||
nextButton | string / HTMLElement | null | String with CSS selector or HTML element of the element that will work like "next" button after click on it |
prevButton | string / HTMLElement | null | String with CSS selector or HTML element of the element that will work like "prev" button after click on it |
Images | |||
preloadImages | boolean | true | When enabled Swiper will force to load all images |
updateOnImagesReady | boolean | true | When enabled Swiper will be reinitialized after all inner images (<img> tags) are loaded. Required preloadImages: true |
lazyLoading | boolean | false | Set to "true" to enable images lazy loading. Note that preloadImages should be disabled |
lazyLoadingInPrevNext | boolean | false | Set to "true" to enable lazy loading for the closest slides images (for previous and next slide images) |
lazyLoadingInPrevNextAmount | number | 1 | Amount of next/prev slides to preload lazy images in. Can't be less than slidesPerView |
lazyLoadingOnTransitionStart | boolean | false | By default, Swiper will load lazy images after transition to this slide, so you may enable this parameter if you need it to start loading of new image in the beginning of transition |
Loop | |||
loop | boolean | false |
Set to true to enable continuous loop mode If you use it along with Also, because of nature of how the loop mode works, it will add duplicated slides. Such duplicated classes will have additional classes:
|
loopAdditionalSlides | number | 0 | Addition number of slides that will be cloned after creating of loop |
loopedSlides | number | null | If you use slidesPerView:'auto' with loop mode you should tell to Swiper how many slides it should loop (duplicate) using this parameter |
Callbacks | |||
runCallbacksOnInit | boolean | true | Run on[Transition/SlideChange][Start/End] callbacks on swiper initialization. Such callbacks will be fired on initialization in case of your initialSlide is not 0, or you use loop mode |
onInit(swiper) | function | Callback function, will be executed right after Swiper initialization | |
onSlideChangeStart(swiper) | function | Callback function, will be executed in the beginning of animation to other slide (next or previous). Receives swiper instance as an argument. | |
onSlideChangeEnd(swiper) | function | Callback function, will be executed after animation to other slide (next or previous). Receives slider instance as an argument. | |
onTouchStart(swiper, event) | function | Callback function, will be executed when user touch Swiper. Receives swiper instance and 'touchstart' event as an arguments. | |
onTouchMove(swiper, event) | function | Callback function, will be executed when user touch and move finger over Swiper. Receives swiper instance and 'touchmove' event as an arguments. | |
onTouchMoveOpposite(swiper, event) | function | Callback function, will be executed when user touch and move finger over Swiper in direction opposite to direction parameter. Receives swiper instance and 'touchmove' event as an arguments. |
|
onTouchEnd(swiper, event) | function | Callback function, will be executed when user release Swiper. Receives swiper instance and 'touchend' event as an arguments. | |
onClick(swiper, event) | function | Callback function, will be executed when user click/tap on Swiper after 300ms delay. Receives swiper instance and 'touchend' event as an arguments. | |
onImagesReady(swiper) | function | Callback function, will be executed right after all inner images are loaded. updateOnImagesReady should be also enabled |
|
onReachBeginning(swiper) | function | Callback function, will be executed when Swiper reach its beginning (initial position) | |
onReachEnd(swiper) | function | Callback function, will be executed when Swiper reach last slide | |
onKeyPress(swiper, kc) | function | Callback function, will be executed on "keydown" event when keyboard control is enabled |
Comments
0 comments
Please sign in to leave a comment.