Socket
Socket
Sign inDemoInstall

swiper

Package Overview
Dependencies
0
Maintainers
1
Versions
324
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    swiper

Most modern mobile touch slider and framework with hardware accelerated transitions


Version published
Weekly downloads
2.1M
decreased by-0.9%
Maintainers
1
Install size
2.10 MB
Created
Weekly downloads
 

Package description

What is swiper?

The swiper npm package is a modern touch slider with hardware accelerated transitions. It is intended for use in mobile websites, mobile web apps, and mobile native/hybrid apps. Swiper is designed to be used in a mobile environment, where touch interactions are fundamental. It provides a number of features like swiping, multiple slides per view, vertical slides, and more.

What are swiper's main functionalities?

Basic Swiper

This code initializes a basic Swiper instance with horizontal direction, loop mode, pagination, navigation arrows, and a scrollbar.

import Swiper from 'swiper';

const swiper = new Swiper('.swiper-container', {
  // Optional parameters
  direction: 'horizontal',
  loop: true,

  // If we need pagination
  pagination: {
    el: '.swiper-pagination',
  },

  // Navigation arrows
  navigation: {
    nextEl: '.swiper-button-next',
    prevEl: '.swiper-button-prev',
  },

  // And if we need scrollbar
  scrollbar: {
    el: '.swiper-scrollbar',
  },
});

Multiple Slides Per View

This code sets up a Swiper instance where you can have multiple slides visible at the same time, with space between the slides and clickable pagination.

import Swiper from 'swiper';

const swiper = new Swiper('.swiper-container', {
  slidesPerView: 3,
  spaceBetween: 30,
  pagination: {
    el: '.swiper-pagination',
    clickable: true,
  },
});

Vertical Swiper

This code snippet demonstrates how to initialize a Swiper instance that allows vertical swiping with clickable pagination.

import Swiper from 'swiper';

const swiper = new Swiper('.swiper-container', {
  direction: 'vertical',
  pagination: {
    el: '.swiper-pagination',
    clickable: true,
  },
});

Other packages similar to swiper

Changelog

Source

3.4.0 - Released on October 16th, 2016

  • Custom build available. Now you can create custom swiper build using the folowing modules: effects, lazy-load, scrollbar, controller, hashnav, history, keyboard, mousewheel, parallax, zoom, a11y. Using cli gulp custom -zoom,effects,lazy-loading
  • New zoom functionality that enables double tap and pinch to zoom slide's inner image:
    • Required slide layout for zoom:
      <div class="swiper-slide">
        <div class="swiper-zoom-container">
          <img src="path/to/image">
        </div>
      </div>
      
    • New zoom parameters:
      • zoom - enable zoom functionality
      • zoomMax - maximum image zoom multiplier, by default is 3
      • zoomMin - minimum image zoom multiplier, by default is 1
      • zoomToggle - enable/disable zoom-in by slide's double tap
    • zoomMax can be also overridden for specific slide by using data-swiper-zoom attribute
  • New swiper.enableTouchControl() and swiper.disableTouchControl() methods to enable disable touch control (it toggles onlyExternal parameter)
  • New swiper.realIndex property in addition to swiper.activeIndex that returns index of active slide considering loop
  • New History API with new history parameter. It uses history pushState to set active slide URL
  • New hashnavWatchState parameter to navigate through slides (when hashnav is enabled) by browser history or by setting directly hash on document location
  • New replaceState parameter that work in addition to hashnav or history to replace current url state with the new one instead of adding it to history
  • New methods s.unsetGrabCursor() and s.setGrabCursor() to enable/disable grab cursor
  • Draggable Scrollbar now works when simulateTouch:false
  • New normalizeSlideIndex parameter to improve work of controller (see #1766)
  • lazyLoadingInPrevNextAmount now works with slidesPerView: 'auto'
  • New passiveListeners parameter to use passive event listeners to improve scrolling performance on mobile devices. Enabled by default
  • New freeModeMomentumVelocityRatio parameter to control moment velocity
  • Now it is possible to specify autoplay delay for every (or specific) slides by using data-swiper-autoplay attribute on them
  • Lazy loading now also respects sizes responsive images attribute
  • Improved mousewheel cross browser behavior (see #1797)
  • New mousewheelEventsTarged parameter (by default 'container') where you can specify mousewheel events target
  • New onScroll event/callback that triggers when swiping/scrolling happens with mousewheel
  • New touchReleaseOnEdges parameter to release touch events on slider edge position (beginning, end) and allow for further page scrolling
  • Multirow (slidesPerColumn) support for vertical direction, which is in this case becomes multicolumn
  • paginationBulletRender now accepts swiper instance as a first argument, paginationBulletRender(index, className) -> paginationBulletRender(swiper, index, className)
  • New "swiper-slide-duplicate-active", "swiper-slide-duplicate-next", "swiper-slide-duplicate-prev" classes that will be added in loop mode to the slides representing duplicated looped slides
  • All css classes are now configurable via new parameters: lazyLoadingClass, notificationClass, containerModifierClass, paginationClickableClass, paginationModifierClass, lazyStatusLoadingClass, lazyStatusLoadedClass, lazyPreloaderClass, notificationClass, preloaderClass, zoomContainerClass, slideDuplicateActiveClass, slideDuplicateNextClass, slideDuplicatePrevClass

Readme

Source

Build Status devDependency Status Flattr this git repo

Swiper

Swiper - is the free and most modern mobile touch slider with hardware accelerated transitions and amazing native behavior. It is intended to be used in mobile websites, mobile web apps, and mobile native/hybrid apps. Designed mostly for iOS, but also works great on latest Android, Windows Phone 8 and modern Desktop browsers

Swiper is not compatible with all platforms, it is a modern touch slider which is focused only on modern apps/platforms to bring the best experience and simplicity.

Getting Started

Dist / Build

On production use files (JS and CSS) only from dist/ folder, there will be the most stable versions, build/ folder is only for development purpose

Build

Swiper uses gulp to build a development (build) and dist versions.

First you need to have gulp-cli which you should install globally.

$ npm install --global gulp

Then install all dependencies, in repo's root:

$ npm install

And build development version of Swiper:

$ gulp build

The result is available in build/ folder.

Dist/Release

After you have made build:

$ gulp dist

Distributable version will available in dist/ folder.

Contributing

All changes should be committed to src/ files. Swiper uses LESS for CSS compliations, and concatenated JS files (look at gulpfile.js for concat files order)

Swiper 2.x.x

If you still using Swiper 2.x.x or you need old browsers support, you may find it in Swiper2 Branch

Keywords

FAQs

Last updated on 16 Oct 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc