mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 12:29:55 +08:00
fix(slides): update Swiper dependency to resolve error when doing SSR (#21350)
This commit is contained in:
@ -39,7 +39,7 @@
|
|||||||
"@types/jest": "24.9.1",
|
"@types/jest": "24.9.1",
|
||||||
"@types/node": "12.12.3",
|
"@types/node": "12.12.3",
|
||||||
"@types/puppeteer": "1.19.1",
|
"@types/puppeteer": "1.19.1",
|
||||||
"@types/swiper": "5.2.1",
|
"@types/swiper": "5.3.1",
|
||||||
"aws-sdk": "^2.497.0",
|
"aws-sdk": "^2.497.0",
|
||||||
"clean-css-cli": "^4.1.11",
|
"clean-css-cli": "^4.1.11",
|
||||||
"domino": "^2.1.3",
|
"domino": "^2.1.3",
|
||||||
@ -55,7 +55,7 @@
|
|||||||
"sass": "^1.22.9",
|
"sass": "^1.22.9",
|
||||||
"stylelint": "10.1.0",
|
"stylelint": "10.1.0",
|
||||||
"stylelint-order": "3.0.1",
|
"stylelint-order": "3.0.1",
|
||||||
"swiper": "5.3.7",
|
"swiper": "5.4.1",
|
||||||
"tslint": "^5.10.0",
|
"tslint": "^5.10.0",
|
||||||
"tslint-ionic-rules": "0.0.21",
|
"tslint-ionic-rules": "0.0.21",
|
||||||
"tslint-react": "^3.6.0"
|
"tslint-react": "^3.6.0"
|
||||||
|
@ -1,88 +1,145 @@
|
|||||||
/**
|
/**
|
||||||
* SSR Window 1.0.1
|
* SSR Window 2.0.0
|
||||||
* Better handling for window object in SSR environment
|
* Better handling for window object in SSR environment
|
||||||
* https://github.com/nolimits4web/ssr-window
|
* https://github.com/nolimits4web/ssr-window
|
||||||
*
|
*
|
||||||
* Copyright 2018, Vladimir Kharlampidi
|
* Copyright 2020, Vladimir Kharlampidi
|
||||||
*
|
*
|
||||||
* Licensed under MIT
|
* Licensed under MIT
|
||||||
*
|
*
|
||||||
* Released on: July 18, 2018
|
* Released on: May 12, 2020
|
||||||
*/
|
*/
|
||||||
var doc = (typeof document === 'undefined') ? {
|
/* eslint-disable no-param-reassign */
|
||||||
|
function isObject(obj) {
|
||||||
|
return (obj !== null &&
|
||||||
|
typeof obj === 'object' &&
|
||||||
|
'constructor' in obj &&
|
||||||
|
obj.constructor === Object);
|
||||||
|
}
|
||||||
|
function extend(target, src) {
|
||||||
|
if (target === void 0) { target = {}; }
|
||||||
|
if (src === void 0) { src = {}; }
|
||||||
|
Object.keys(src).forEach(function (key) {
|
||||||
|
if (typeof target[key] === 'undefined')
|
||||||
|
target[key] = src[key];
|
||||||
|
else if (isObject(src[key]) &&
|
||||||
|
isObject(target[key]) &&
|
||||||
|
Object.keys(src[key]).length > 0) {
|
||||||
|
extend(target[key], src[key]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
var doc = typeof document !== 'undefined' ? document : {};
|
||||||
|
var ssrDocument = {
|
||||||
body: {},
|
body: {},
|
||||||
addEventListener: function addEventListener() {},
|
addEventListener: function () { },
|
||||||
removeEventListener: function removeEventListener() {},
|
removeEventListener: function () { },
|
||||||
activeElement: {
|
activeElement: {
|
||||||
blur: function blur() {},
|
blur: function () { },
|
||||||
nodeName: '',
|
nodeName: '',
|
||||||
},
|
},
|
||||||
querySelector: function querySelector() {
|
querySelector: function () {
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
querySelectorAll: function querySelectorAll() {
|
querySelectorAll: function () {
|
||||||
return [];
|
return [];
|
||||||
},
|
},
|
||||||
getElementById: function getElementById() {
|
getElementById: function () {
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
createEvent: function createEvent() {
|
createEvent: function () {
|
||||||
return {
|
return {
|
||||||
initEvent: function initEvent() {},
|
initEvent: function () { },
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
createElement: function createElement() {
|
createElement: function () {
|
||||||
return {
|
return {
|
||||||
children: [],
|
children: [],
|
||||||
childNodes: [],
|
childNodes: [],
|
||||||
style: {},
|
style: {},
|
||||||
setAttribute: function setAttribute() {},
|
setAttribute: function () { },
|
||||||
getElementsByTagName: function getElementsByTagName() {
|
getElementsByTagName: function () {
|
||||||
return [];
|
return [];
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
location: { hash: '' },
|
createElementNS: function () {
|
||||||
} : document; // eslint-disable-line
|
return {};
|
||||||
|
},
|
||||||
|
importNode: function () {
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
location: {
|
||||||
|
hash: '',
|
||||||
|
host: '',
|
||||||
|
hostname: '',
|
||||||
|
href: '',
|
||||||
|
origin: '',
|
||||||
|
pathname: '',
|
||||||
|
protocol: '',
|
||||||
|
search: '',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
extend(doc, ssrDocument);
|
||||||
|
|
||||||
var win = (typeof window === 'undefined') ? {
|
var win = typeof window !== 'undefined' ? window : {};
|
||||||
document: doc,
|
var ssrWindow = {
|
||||||
|
document: ssrDocument,
|
||||||
navigator: {
|
navigator: {
|
||||||
userAgent: '',
|
userAgent: '',
|
||||||
},
|
},
|
||||||
location: {},
|
location: {
|
||||||
history: {},
|
hash: '',
|
||||||
|
host: '',
|
||||||
|
hostname: '',
|
||||||
|
href: '',
|
||||||
|
origin: '',
|
||||||
|
pathname: '',
|
||||||
|
protocol: '',
|
||||||
|
search: '',
|
||||||
|
},
|
||||||
|
history: {
|
||||||
|
replaceState: function () { },
|
||||||
|
pushState: function () { },
|
||||||
|
go: function () { },
|
||||||
|
back: function () { },
|
||||||
|
},
|
||||||
CustomEvent: function CustomEvent() {
|
CustomEvent: function CustomEvent() {
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
addEventListener: function addEventListener() {},
|
addEventListener: function () { },
|
||||||
removeEventListener: function removeEventListener() {},
|
removeEventListener: function () { },
|
||||||
getComputedStyle: function getComputedStyle() {
|
getComputedStyle: function () {
|
||||||
return {
|
return {
|
||||||
getPropertyValue: function getPropertyValue() {
|
getPropertyValue: function () {
|
||||||
return '';
|
return '';
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
Image: function Image() {},
|
Image: function () { },
|
||||||
Date: function Date() {},
|
Date: function () { },
|
||||||
screen: {},
|
screen: {},
|
||||||
setTimeout: function setTimeout() {},
|
setTimeout: function () { },
|
||||||
clearTimeout: function clearTimeout() {},
|
clearTimeout: function () { },
|
||||||
} : window; // eslint-disable-line
|
matchMedia: function () {
|
||||||
|
return {};
|
||||||
|
},
|
||||||
|
};
|
||||||
|
extend(win, ssrWindow);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dom7 2.1.3
|
* Dom7 2.1.5
|
||||||
* Minimalistic JavaScript library for DOM manipulation, with a jQuery-compatible API
|
* Minimalistic JavaScript library for DOM manipulation, with a jQuery-compatible API
|
||||||
* http://framework7.io/docs/dom.html
|
* http://framework7.io/docs/dom.html
|
||||||
*
|
*
|
||||||
* Copyright 2019, Vladimir Kharlampidi
|
* Copyright 2020, Vladimir Kharlampidi
|
||||||
* The iDangero.us
|
* The iDangero.us
|
||||||
* http://www.idangero.us/
|
* http://www.idangero.us/
|
||||||
*
|
*
|
||||||
* Licensed under MIT
|
* Licensed under MIT
|
||||||
*
|
*
|
||||||
* Released on: February 11, 2019
|
* Released on: May 15, 2020
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class Dom7 {
|
class Dom7 {
|
||||||
@ -773,7 +830,7 @@ function add(...args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Swiper 5.3.7
|
* Swiper 5.4.1
|
||||||
* Most modern mobile touch slider and framework with hardware accelerated transitions
|
* Most modern mobile touch slider and framework with hardware accelerated transitions
|
||||||
* http://swiperjs.com
|
* http://swiperjs.com
|
||||||
*
|
*
|
||||||
@ -781,7 +838,7 @@ function add(...args) {
|
|||||||
*
|
*
|
||||||
* Released under the MIT License
|
* Released under the MIT License
|
||||||
*
|
*
|
||||||
* Released on: April 10, 2020
|
* Released on: May 20, 2020
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const Methods = {
|
const Methods = {
|
||||||
@ -939,11 +996,9 @@ const Utils = {
|
|||||||
|
|
||||||
const Support = (function Support() {
|
const Support = (function Support() {
|
||||||
return {
|
return {
|
||||||
touch: (win.Modernizr && win.Modernizr.touch === true) || (function checkTouch() {
|
touch: !!(('ontouchstart' in win) || (win.DocumentTouch && doc instanceof win.DocumentTouch)),
|
||||||
return !!((win.navigator.maxTouchPoints > 0) || ('ontouchstart' in win) || (win.DocumentTouch && doc instanceof win.DocumentTouch));
|
|
||||||
}()),
|
|
||||||
|
|
||||||
pointerEvents: !!win.PointerEvent && ('maxTouchPoints' in win.navigator) && win.navigator.maxTouchPoints > 0,
|
pointerEvents: !!win.PointerEvent && ('maxTouchPoints' in win.navigator) && win.navigator.maxTouchPoints >= 0,
|
||||||
|
|
||||||
observer: (function checkObserver() {
|
observer: (function checkObserver() {
|
||||||
return ('MutationObserver' in win || 'WebkitMutationObserver' in win);
|
return ('MutationObserver' in win || 'WebkitMutationObserver' in win);
|
||||||
@ -2764,7 +2819,7 @@ function onTouchMove (event) {
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (data.isTouchEvent && e.type === 'mousemove') return;
|
if (data.isTouchEvent && e.type !== 'touchmove') return;
|
||||||
const targetTouch = e.type === 'touchmove' && e.targetTouches && (e.targetTouches[0] || e.changedTouches[0]);
|
const targetTouch = e.type === 'touchmove' && e.targetTouches && (e.targetTouches[0] || e.changedTouches[0]);
|
||||||
const pageX = e.type === 'touchmove' ? targetTouch.pageX : e.pageX;
|
const pageX = e.type === 'touchmove' ? targetTouch.pageX : e.pageX;
|
||||||
const pageY = e.type === 'touchmove' ? targetTouch.pageY : e.pageY;
|
const pageY = e.type === 'touchmove' ? targetTouch.pageY : e.pageY;
|
||||||
@ -2852,7 +2907,7 @@ function onTouchMove (event) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
swiper.allowClick = false;
|
swiper.allowClick = false;
|
||||||
if (!params.cssMode) {
|
if (!params.cssMode && e.cancelable) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
if (params.touchMoveStopPropagation && !params.nested) {
|
if (params.touchMoveStopPropagation && !params.nested) {
|
||||||
@ -3152,13 +3207,14 @@ function onTouchEnd (event) {
|
|||||||
$wrapperEl.transitionEnd(() => {
|
$wrapperEl.transitionEnd(() => {
|
||||||
if (!swiper || swiper.destroyed || !data.allowMomentumBounce) return;
|
if (!swiper || swiper.destroyed || !data.allowMomentumBounce) return;
|
||||||
swiper.emit('momentumBounce');
|
swiper.emit('momentumBounce');
|
||||||
|
|
||||||
swiper.setTransition(params.speed);
|
swiper.setTransition(params.speed);
|
||||||
|
setTimeout(() => {
|
||||||
swiper.setTranslate(afterBouncePosition);
|
swiper.setTranslate(afterBouncePosition);
|
||||||
$wrapperEl.transitionEnd(() => {
|
$wrapperEl.transitionEnd(() => {
|
||||||
if (!swiper || swiper.destroyed) return;
|
if (!swiper || swiper.destroyed) return;
|
||||||
swiper.transitionEnd();
|
swiper.transitionEnd();
|
||||||
});
|
});
|
||||||
|
}, 0);
|
||||||
});
|
});
|
||||||
} else if (swiper.velocity) {
|
} else if (swiper.velocity) {
|
||||||
swiper.updateProgress(newPosition);
|
swiper.updateProgress(newPosition);
|
||||||
@ -3591,7 +3647,9 @@ function loadImage (imageEl, src, srcset, sizes, checkForComplete, callback) {
|
|||||||
function onReady() {
|
function onReady() {
|
||||||
if (callback) callback();
|
if (callback) callback();
|
||||||
}
|
}
|
||||||
if (!imageEl.complete || !checkForComplete) {
|
const isPicture = $(imageEl).parent('picture')[0];
|
||||||
|
|
||||||
|
if (!isPicture && (!imageEl.complete || !checkForComplete)) {
|
||||||
if (src) {
|
if (src) {
|
||||||
image = new win.Image();
|
image = new win.Image();
|
||||||
image.onload = onReady;
|
image.onload = onReady;
|
||||||
@ -4605,7 +4663,7 @@ const Mousewheel = {
|
|||||||
// Else (this is the first time the wheel is moved):
|
// Else (this is the first time the wheel is moved):
|
||||||
// Animate the slider.
|
// Animate the slider.
|
||||||
if (prevEvent) {
|
if (prevEvent) {
|
||||||
if (newEvent.direction !== prevEvent.direction || newEvent.delta > prevEvent.delta) {
|
if (newEvent.direction !== prevEvent.direction || newEvent.delta > prevEvent.delta || newEvent.time > prevEvent.time + 150) {
|
||||||
swiper.mousewheel.animateSlider(newEvent);
|
swiper.mousewheel.animateSlider(newEvent);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -5592,7 +5650,7 @@ const Zoom = {
|
|||||||
const { gesture, image } = zoom;
|
const { gesture, image } = zoom;
|
||||||
if (!gesture.$imageEl || gesture.$imageEl.length === 0) return;
|
if (!gesture.$imageEl || gesture.$imageEl.length === 0) return;
|
||||||
if (image.isTouched) return;
|
if (image.isTouched) return;
|
||||||
if (Device.android) e.preventDefault();
|
if (Device.android && e.cancelable) e.preventDefault();
|
||||||
image.isTouched = true;
|
image.isTouched = true;
|
||||||
image.touchesStart.x = e.type === 'touchstart' ? e.targetTouches[0].pageX : e.pageX;
|
image.touchesStart.x = e.type === 'touchstart' ? e.targetTouches[0].pageX : e.pageX;
|
||||||
image.touchesStart.y = e.type === 'touchstart' ? e.targetTouches[0].pageY : e.pageY;
|
image.touchesStart.y = e.type === 'touchstart' ? e.targetTouches[0].pageY : e.pageY;
|
||||||
@ -5653,7 +5711,9 @@ const Zoom = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (e.cancelable) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
}
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
|
||||||
image.isMoved = true;
|
image.isMoved = true;
|
||||||
|
Reference in New Issue
Block a user