Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Patryk authored Apr 25, 2018
2 parents ab90a4c + db241ba commit 031fe21
Show file tree
Hide file tree
Showing 81 changed files with 7,739 additions and 4,519 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ module.exports = {
exports: 'always-multiline',
functions: 'never',
}],
'prefer-destructuring': ['off'],
},
globals: {
'window': true,
Expand Down
140 changes: 140 additions & 0 deletions Architecture.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
# Swiper Architecture

Swiper allows you to swipe between “HTML pages”.
The “pages” can be swapped by swiping left to right, right to left or up and down. How does it do this?


Swiper is a mix of javascript, css and div definitions.

Actually each “page” is a separate HTML div.
You create a single web page application. It includes a list (div) of what looks like HTML pages, but are actually also each just a div.

The outermost container div takes up 100% of the screen. Inside that is the swiper div. This gets animated to move left to right or up to down. The
variable aSlider.progress tells you how far this slider div has moved. From 0 to 1. And inside the slider div are the slide divs. There is the active slide div, and possibly a previous and a next slide div. The previous and next slide divs get moved just off of the screen, so that there is no delay in animating moving them onto the screen. The other slide divs are set {visibility:hidden} to save on browser resources.

When a move is detected, animation takes over, and the slider div is moved to the next slide. when
a move is done a javascript callback is issued. Some slides get set to hidden, others get moved off screen, and some are set to display. It all just works.

So how does it do animation? Well in each direction there is a list of slides. There is one active slide, and a next and previous slide. The next and previous are set to visible, but moved off of the screen, and then they are animated to slide onto the screenThe progress variable, between 0 and 1 tells you how far the original slide has moved. And when they are all the way off the screen you get the slideChange event activated. And the other events are triggered at the approapriate time.

So let us take a look at some code. And i will put in lots of comments. (Without comment signs).
```
<div class="swiper-container">
This is the container which takes up the whole viewport (window). There is a Javascript swiper object that looks for this div. You could also do container-h and container-v if you have
horizontal and vertical containers.
<div class="swiper-wrapper">
This wrapper which is actually animated to move divs across the screen.
Next you have some slides. At startup all the slides are set to style {visibility: hidden}. Then once the javascript is loaded, a single slide is made visible. By moving or animating the wrapper div, the neighboring divs can be made isible.
<div class="swiper-slide">Slide 1</div>
<div class="swiper-slide">Slide 2</div>
<div class="swiper-slide">Slide 3</div>
...
</div>
</div>
```

What if you want to be ale to swipe left right up or down? Well then you will need one slider inside of another one. (You can also have one set inside another one, both going the same direction. )
```
<div class="swiper-container">
<div class="swiper-wrapper">
<div class="swiper-container">
<div class="swiper-wrapper">
</div>
</div>
</div>
</div>
```
And of course you have to put the slides into the above html
in the right places.

## Virtual Slides
Now let us talk about virtual slides.

First if you are using virtual slides, then do not include any slides in the HTML. Or you will get a mumbled display. Or else use the removeAllSlides() function before
generating the HTML from virtual slides.

To create virtual slides, you first
create an array of slide objects, and a function to render them, to turn them into HTML.

Okay, so how do we do left right up or down using virtual slides? For left right up and down, you can have two virtual arrays, one in either direction.

Their virtual demo talks about a long list of 500 slides, but in many cases, the slides change every time the user swipes. So you want to do two orthogonal 3 item arrays of slides. That allows the user to swipe in any direction. Each time the user swipes, one should modify the virtual arrays. How does one do that?

The documentation supports appending or prepending a slide to a virtual array. While Swiper supports deleting slides from the DOM, sadly it does not support deleting a slide from a virtual array. A different approach is needed.

The different approach is to create completely new arrays, and use the true argument when updating the display.

```
aSwiper.virtual.update(true);
```

Doing this is a bit tricky because you do not want to suddenly jump the user display. So there are two parts to it.
When you receive the event slideChange, you can go ahead and create the two new virtual arrays. But do
not update the DOM yet, it would jump the display. We will return to the update method shortly. And
remember that the user may swipe back to the old slide. But there is another problem to first pay attention to.

You have to be a bit careful when creating new arrays because the virtual objects have a cache of the slides. This can cause problems. aSwiper.virtual.cache is a dictionary indexed by slide index number. The simplest solution is to set
aSwiper.virtual.cache = false;
And then caching is not used.

But the cache does speed performance. So good to allow the caches, but then you have to deal with
`aSwiper.virtual.from` and `aSwiper.virtual.to`.

These are indexes of which slides have already been rendered and cached. If you set
`aSwiper.virtual.from = 0;` and `aSwiper.virtual.to = -1;`

Also good to delete the old cache.
```
aSwiper.virtual.cache = {};
```

Now all should be well. Although I have not tested it yet.

Okay, so now you know what it takes to just create
the new virtual arrays. But we still have to display them. Meaning we still have to update the DOM.

In principal, all you have to do is to say
```
aSwiper.virtual.update(force);
```
and everything will be redisplayed.

Actually it is a bit harder than that. In fact, there are two arrays. While we see the arrays as orthogonal, the HTML sees them as nested. So first update the outer array, then the inner one. If you do it the other way around, it will not generate the correct html.


Just to state the obvious, the function for generating the outer virtual array should also generate the following lines.
```
<div class="swiper-container-h“>
<div class="swiper-wrapper">
</div>
</div>
```
Or if the inner array is vertical it should use the line:
```
<div class="swiper-container-v“>
```

The next problem is that updating the DOM will probably cause what the user see to jump. So you really need to wait until the animation ends, and then call the `aSliderOUTER.virtual.update(force);` and `aSliderINNER.virtual.update(force);`
commands.

All of this sounds reasonably easy to do, but it gets harder when working in the vertical direction. The problem is that pages have different lengths, and may often overflow the screen. The software cannot tell when you are swiping to the next vertical slide, and when you re just trying to scroll down. So you have to set
`
freeMode = true;
`
And then it will not animate to the next screen, when all you want to do is scroll down. And yet you still get the callbacks on slideChange event, so one can update things.

One more complication. Sometimes one loads content from a server using AJAX. Or whatever the newest version of AJAX is called. Then the page size changes. So in the callback, you have to notify the Swiper that the page size has changed, and that it should recalculate the page sizes and possibly recalculate the progress variable.

I hope that this document helps beginners better understand this wonderful software package.
Christopher Lozinski
PythonLinks.info



82 changes: 81 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,85 @@
# Change Log

## [Swiper 4.2.2](https://github.com/nolimits4web/swiper/compare/v4.2.0...v4.2.2) - Released on April 1, 2018
* Core
* Respect and update breakpoints when calling Swiper's `.update()` method
* Pagination
* New `progressbarOpposite` parameter to make pagination progressbar opposite to `direction` parameter, means vertical progressbar for horizontal swiper direction and horizontal progressbar for vertical swiper direction
* Mousewheel
* Fixed issue in `loop` + `freeMode` for loop not being set correctly
* Minor fixes

## [Swiper 4.2.0](https://github.com/nolimits4web/swiper/compare/v4.1.6...v4.2.0) - Released on March 16, 2018
* Core
* `swiper.updateAutoHeight(speed)` now supports `speed` parameter to resize swiper wrapper with duration
* Fixed issues in free mode with `freeModeSticky` not being able to snap to closest snap point
* New `swiper.slideToClosest()` method to slide to closest snap point when it is somewhere in between
* A11y (Accessibility)
* It is now enabled by default (if installed)
* Controller
* Fixed RTL issue when vertical swiper controls horizontal one
* Lazy
* Fixed issue when lazy loading not always triggered on window resize
* Minor fixes

## [Swiper 4.1.6](https://github.com/nolimits4web/swiper/compare/v4.1.5...v4.1.6) - Released on February 11, 2018
* Fixed onTouchMoveOpposite event on touch devices

## [Swiper 4.1.5](https://github.com/nolimits4web/swiper/compare/v4.1.0...v4.1.5) - Released on February 10, 2018
* Improved touch events support on desktop Windows devices with touch screen
* Improved "loop fix" when slider is in the free mode
* New `noSwipingSelector` parameter that can be used instead of `noSwipingClass`
* New `preventIntercationOnTransition` parameter to prevent interaction during slice change transition
* New `.slideToLoop` method to be used in loop mode
* Fixed issue with `slideChange` events being fired when slide wasn't actually changed
* Scrollbar
* Now doesn't require to enable `simulateTouch` for desktops when it is `draggable`
* Keyboard
* Fixed detection statement whether a swiper is in the viewport
* Pagination
* Added new multiple main bullets support for dynamic bullets pagination
* Zoom
* Now supports Virtual Slides
* Minor fixes

## [Swiper 4.1.0](https://github.com/nolimits4web/swiper/compare/v4.0.7...v4.1.0) - Released on January 13, 2018
* Improved IE 10 support. But it is recommended to use [__proto__ polyfill](https://www.npmjs.com/package/proto-polyfill)
* Improved touch support for Edge
* New `watchOverflow` (disabled by default). When enabled Swiper will be disabled and hide navigation buttons on case there are not enough slides for sliding
* Autoplay
* New `reverseDirection` to enable autoplay in reverse direction
* New `waitForTransition` parameter when autoplay will wait for wrapper transition to continue (enabled by default). Can be disabled in case of using Virtual Translate when your slider may not have transition
* Keyboard
* New `onlyInViewport` parameter (enabled by default). When enabled it will control sliders that are currently in viewport

## [Swiper 4.0.7](https://github.com/nolimits4web/swiper/compare/v4.0.6...v4.0.7) - Released on November 28, 2017
* Fixed issue with not working correctly `touchReleaseOnEdges` on iOS
* Fixed issue with not working allowSlideNext/Prev change on Breakpoints
* Fixed wrong scrollbar dragging when using custom `dragSize`
* Minor fixes

## [Swiper 4.0.6](https://github.com/nolimits4web/swiper/compare/v4.0.5...v4.0.6) - Released on November 13, 2017
* Fixed Coverflow effect issue using with breakpoints
* `iOSEdgeSwipeDetection` will also be in consideration with right-edge swipe
* Fixed `freeModeSticky` behavior in RTL mode
* Swiper now emits `breakpoint` event on breakpoint change
* Minor fixes

## [Swiper 4.0.5](https://github.com/nolimits4web/swiper/compare/v4.0.3...v4.0.5) - Released on November 7, 2017
* Fixed issue with not working `noSwiping` parameter
* Parallax now considers `slidesPerGroup` parameter
* Zoom: imporved gestures handling
* Pagination: fixed issues with wrong positioned dynamic-bullets when there are not enough slides
* Fixed issues with some effects being broken with enabled `breakpoints`
* Minor fixes

## [Swiper 4.0.3](https://github.com/nolimits4web/swiper/compare/v4.0.2...v4.0.3) - Released on October 27, 2017
* Fixed Parallax opacity and scale transitions
* Better compatability with SSR by using dummy `document` object
* Fixed styles for dynamic pagination buttons in RTL mode
* Fixed issue with last pagination button not being active with `slidesPerView: 'auto'`
* Renamed build tasks: `build-dev` -> `build:dev`, `build-prod` -> `build:prod`

## [Swiper 4.0.2](https://github.com/nolimits4web/swiper/compare/v4.0.1...v4.0.2) - Released on October 18, 2017
* Lazy loading support for Virtual slides
* Added `beforeResize` event
Expand Down Expand Up @@ -312,7 +392,7 @@ runCallbacks=false
* Scroll Container. Removed in favor of pure CSS `overflow: auto` with `-webkit-overflow-scrolling: touch`
* New features
* Swiper now uses modern flexbox layout, which by itself give more features and advantages
* Such Swiper 2.x plugins as Hash Navigation, Smooth Progress, 3D Flow and Scrollbar are now incoroporated into Swiper 3.x core
* Such Swiper 2.x plugins as Hash Navigation, Smooth Progress, 3D Flow and Scrollbar are now incorporated into Swiper 3.x core
* Full RTL support
* Built-in navigation buttons/arrows
* Controller. Now one Swiper could be controlled (or control itself) by another Swiper
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
[![Join the chat at https://gitter.im/nolimits4web/Swiper](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/nolimits4web/Swiper)
[![Build Status](https://travis-ci.org/nolimits4web/Swiper.svg?branch=master)](https://travis-ci.org/nolimits4web/Swiper)
[![Build Status](https://travis-ci.org/nolimits4web/swiper.svg?branch=master)](https://travis-ci.org/nolimits4web/swiper)
[![devDependency Status](https://david-dm.org/nolimits4web/swiper/dev-status.svg)](https://david-dm.org/nolimits4web/swiper#info=devDependencies)
[![jsDelivr Hits](https://data.jsdelivr.com/v1/package/npm/swiper/badge?style=rounded)](https://www.jsdelivr.com/package/npm/swiper)

Swiper
==========

[![Greenkeeper badge](https://badges.greenkeeper.io/nolimits4web/Swiper.svg)](https://greenkeeper.io/)

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.
Expand Down Expand Up @@ -38,15 +40,15 @@ $ npm install

And build development version of Swiper:
```
$ npm run build-dev
$ npm run build:dev
```

The result is available in `build/` folder.

### Production Build

```
$ npm run build-prod
$ npm run build:prod
```

Production version will available in `dist/` folder.
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"url": "https://github.com/nolimits4web/Swiper.git"
},
"description": "Most modern mobile touch slider and framework with hardware accelerated transitions",
"version": "4.0.2",
"version": "4.1.6",
"author": "Vladimir Kharlampidi",
"homepage": "http://www.idangero.us/swiper/",
"keywords": ["swiper", "swipe", "slider", "touch", "ios", "mobile", "cordova", "phonegap", "app", "framework", "carousel", "gallery"],
Expand Down
2 changes: 1 addition & 1 deletion component.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "swiper",
"repo": "https://github.com/nolimits4web/Swiper.git",
"description": "Most modern mobile touch slider and framework with hardware accelerated transitions",
"version": "4.0.2",
"version": "4.0.7",
"keywords": ["swiper", "swipe", "slider", "touch", "ios", "mobile", "cordova", "phonegap", "app", "framework", "carousel", "gallery"],
"dependencies": {
},
Expand Down
38 changes: 31 additions & 7 deletions dist/css/swiper.css
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
/**
* Swiper 4.0.2
* Swiper 4.2.2
* Most modern mobile touch slider and framework with hardware accelerated transitions
* http://www.idangero.us/swiper/
*
* Copyright 2014-2017 Vladimir Kharlampidi
* Copyright 2014-2018 Vladimir Kharlampidi
*
* Released under the MIT License
*
* Released on: October 18, 2017
* Released on: April 1, 2018
*/
.swiper-container {
margin-left: auto;
margin-right: auto;
margin: 0 auto;
position: relative;
overflow: hidden;
list-style: none;
padding: 0;
/* Fix of Webkit flickering */
z-index: 1;
}
Expand Down Expand Up @@ -201,6 +202,9 @@
.swiper-container-rtl .swiper-button-prev.swiper-button-black {
background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20viewBox%3D'0%200%2027%2044'%3E%3Cpath%20d%3D'M27%2C22L27%2C22L5%2C44l-2.1-2.1L22.8%2C22L2.9%2C2.1L5%2C0L27%2C22L27%2C22z'%20fill%3D'%23000000'%2F%3E%3C%2Fsvg%3E");
}
.swiper-button-lock {
display: none;
}
.swiper-pagination {
position: absolute;
text-align: center;
Expand Down Expand Up @@ -238,6 +242,11 @@
-ms-transform: scale(1);
transform: scale(1);
}
.swiper-pagination-bullets-dynamic .swiper-pagination-bullet-active-main {
-webkit-transform: scale(1);
-ms-transform: scale(1);
transform: scale(1);
}
.swiper-pagination-bullets-dynamic .swiper-pagination-bullet-active-prev {
-webkit-transform: scale(0.66);
-ms-transform: scale(0.66);
Expand Down Expand Up @@ -325,6 +334,13 @@ button.swiper-pagination-bullet {
transition: 200ms transform, 200ms left;
transition: 200ms transform, 200ms left, 200ms -webkit-transform;
}
.swiper-container-horizontal.swiper-container-rtl > .swiper-pagination-bullets-dynamic .swiper-pagination-bullet {
-webkit-transition: 200ms right, 200ms -webkit-transform;
transition: 200ms right, 200ms -webkit-transform;
-o-transition: 200ms transform, 200ms right;
transition: 200ms transform, 200ms right;
transition: 200ms transform, 200ms right, 200ms -webkit-transform;
}
/* Progress */
.swiper-pagination-progressbar {
background: rgba(0, 0, 0, 0.25);
Expand All @@ -349,13 +365,15 @@ button.swiper-pagination-bullet {
-ms-transform-origin: right top;
transform-origin: right top;
}
.swiper-container-horizontal > .swiper-pagination-progressbar {
.swiper-container-horizontal > .swiper-pagination-progressbar,
.swiper-container-vertical > .swiper-pagination-progressbar.swiper-pagination-progressbar-opposite {
width: 100%;
height: 4px;
left: 0;
top: 0;
}
.swiper-container-vertical > .swiper-pagination-progressbar {
.swiper-container-vertical > .swiper-pagination-progressbar,
.swiper-container-horizontal > .swiper-pagination-progressbar.swiper-pagination-progressbar-opposite {
width: 4px;
height: 100%;
left: 0;
Expand All @@ -379,6 +397,9 @@ button.swiper-pagination-bullet {
.swiper-pagination-progressbar.swiper-pagination-black .swiper-pagination-progressbar-fill {
background: #000000;
}
.swiper-pagination-lock {
display: none;
}
/* Scrollbar */
.swiper-scrollbar {
border-radius: 10px;
Expand Down Expand Up @@ -414,6 +435,9 @@ button.swiper-pagination-bullet {
.swiper-scrollbar-cursor-drag {
cursor: move;
}
.swiper-scrollbar-lock {
display: none;
}
.swiper-zoom-container {
width: 100%;
height: 100%;
Expand Down
Loading

0 comments on commit 031fe21

Please sign in to comment.