1 | export default function updateSize() {
|
2 | const swiper = this;
|
3 | let width;
|
4 | let height;
|
5 | const $el = swiper.$el;
|
6 |
|
7 | if (typeof swiper.params.width !== 'undefined' && swiper.params.width !== null) {
|
8 | width = swiper.params.width;
|
9 | } else {
|
10 | width = $el[0].clientWidth;
|
11 | }
|
12 |
|
13 | if (typeof swiper.params.height !== 'undefined' && swiper.params.height !== null) {
|
14 | height = swiper.params.height;
|
15 | } else {
|
16 | height = $el[0].clientHeight;
|
17 | }
|
18 |
|
19 | if (width === 0 && swiper.isHorizontal() || height === 0 && swiper.isVertical()) {
|
20 | return;
|
21 | }
|
22 |
|
23 |
|
24 | width = width - parseInt($el.css('padding-left') || 0, 10) - parseInt($el.css('padding-right') || 0, 10);
|
25 | height = height - parseInt($el.css('padding-top') || 0, 10) - parseInt($el.css('padding-bottom') || 0, 10);
|
26 | if (Number.isNaN(width)) width = 0;
|
27 | if (Number.isNaN(height)) height = 0;
|
28 | Object.assign(swiper, {
|
29 | width,
|
30 | height,
|
31 | size: swiper.isHorizontal() ? width : height
|
32 | });
|
33 | } |
\ | No newline at end of file |