Initial commit: GamePortrait 竖屏版 - 深色豪华主题

This commit is contained in:
li
2026-01-16 17:47:53 +08:00
commit 40976e4b45
26611 changed files with 2843638 additions and 0 deletions
+4
View File
@@ -0,0 +1,4 @@
export default function classesToSelector(classes = '') {
return `.${classes.trim().replace(/([\.:!+\/])/g, '\\$1') // eslint-disable-line
.replace(/ /g, '.')}`;
}
+18
View File
@@ -0,0 +1,18 @@
import { createElement, elementChildren } from './utils.js';
export default function createElementIfNotDefined(swiper, originalParams, params, checkProps) {
if (swiper.params.createElements) {
Object.keys(checkProps).forEach(key => {
if (!params[key] && params.auto === true) {
let element = elementChildren(swiper.el, `.${checkProps[key]}`)[0];
if (!element) {
element = createElement('div', checkProps[key]);
element.className = checkProps[key];
swiper.el.append(element);
}
params[key] = element;
originalParams[key] = element;
}
});
}
return params;
}
+11
View File
@@ -0,0 +1,11 @@
import { createElement, getSlideTransformEl } from './utils.js';
export default function createShadow(params, slideEl, side) {
const shadowClass = `swiper-slide-shadow${side ? `-${side}` : ''}`;
const shadowContainer = getSlideTransformEl(slideEl);
let shadowEl = shadowContainer.querySelector(`.${shadowClass}`);
if (!shadowEl) {
shadowEl = createElement('div', `swiper-slide-shadow${side ? `-${side}` : ''}`);
shadowContainer.append(shadowEl);
}
return shadowEl;
}
+56
View File
@@ -0,0 +1,56 @@
export default function effectInit(params) {
const {
effect,
swiper,
on,
setTranslate,
setTransition,
overwriteParams,
perspective,
recreateShadows,
getEffectParams
} = params;
on('beforeInit', () => {
if (swiper.params.effect !== effect) return;
swiper.classNames.push(`${swiper.params.containerModifierClass}${effect}`);
if (perspective && perspective()) {
swiper.classNames.push(`${swiper.params.containerModifierClass}3d`);
}
const overwriteParamsResult = overwriteParams ? overwriteParams() : {};
Object.assign(swiper.params, overwriteParamsResult);
Object.assign(swiper.originalParams, overwriteParamsResult);
});
on('setTranslate', () => {
if (swiper.params.effect !== effect) return;
setTranslate();
});
on('setTransition', (_s, duration) => {
if (swiper.params.effect !== effect) return;
setTransition(duration);
});
on('transitionEnd', () => {
if (swiper.params.effect !== effect) return;
if (recreateShadows) {
if (!getEffectParams || !getEffectParams().slideShadows) return;
// remove shadows
swiper.slides.forEach(slideEl => {
slideEl.querySelectorAll('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left').forEach(shadowEl => shadowEl.remove());
});
// create new one
recreateShadows();
}
});
let requireUpdateOnVirtual;
on('virtualUpdate', () => {
if (swiper.params.effect !== effect) return;
if (!swiper.slides.length) {
requireUpdateOnVirtual = true;
}
requestAnimationFrame(() => {
if (requireUpdateOnVirtual && swiper.slides && swiper.slides.length) {
setTranslate();
requireUpdateOnVirtual = false;
}
});
});
}
+9
View File
@@ -0,0 +1,9 @@
import { getSlideTransformEl } from './utils.js';
export default function effectTarget(effectParams, slideEl) {
const transformEl = getSlideTransformEl(slideEl);
if (transformEl !== slideEl) {
transformEl.style.backfaceVisibility = 'hidden';
transformEl.style['-webkit-backface-visibility'] = 'hidden';
}
return transformEl;
}
+44
View File
@@ -0,0 +1,44 @@
import { elementTransitionEnd } from './utils.js';
export default function effectVirtualTransitionEnd({
swiper,
duration,
transformElements,
allSlides
}) {
const {
activeIndex
} = swiper;
const getSlide = el => {
if (!el.parentElement) {
// assume shadow root
const slide = swiper.slides.filter(slideEl => slideEl.shadowEl && slideEl.shadowEl === el.parentNode)[0];
return slide;
}
return el.parentElement;
};
if (swiper.params.virtualTranslate && duration !== 0) {
let eventTriggered = false;
let transitionEndTarget;
if (allSlides) {
transitionEndTarget = transformElements;
} else {
transitionEndTarget = transformElements.filter(transformEl => {
const el = transformEl.classList.contains('swiper-slide-transform') ? getSlide(transformEl) : transformEl;
return swiper.getSlideIndex(el) === activeIndex;
});
}
transitionEndTarget.forEach(el => {
elementTransitionEnd(el, () => {
if (eventTriggered) return;
if (!swiper || swiper.destroyed) return;
eventTriggered = true;
swiper.animating = false;
const evt = new window.CustomEvent('transitionend', {
bubbles: true,
cancelable: true
});
swiper.wrapperEl.dispatchEvent(evt);
});
});
}
}
+29
View File
@@ -0,0 +1,29 @@
import { getWindow } from 'ssr-window';
let browser;
function calcBrowser() {
const window = getWindow();
let needPerspectiveFix = false;
function isSafari() {
const ua = window.navigator.userAgent.toLowerCase();
return ua.indexOf('safari') >= 0 && ua.indexOf('chrome') < 0 && ua.indexOf('android') < 0;
}
if (isSafari()) {
const ua = String(window.navigator.userAgent);
if (ua.includes('Version/')) {
const [major, minor] = ua.split('Version/')[1].split(' ')[0].split('.').map(num => Number(num));
needPerspectiveFix = major < 16 || major === 16 && minor < 2;
}
}
return {
isSafari: needPerspectiveFix || isSafari(),
needPerspectiveFix,
isWebView: /(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(window.navigator.userAgent)
};
}
function getBrowser() {
if (!browser) {
browser = calcBrowser();
}
return browser;
}
export { getBrowser };
+51
View File
@@ -0,0 +1,51 @@
import { getWindow } from 'ssr-window';
import { getSupport } from './get-support.js';
let deviceCached;
function calcDevice({
userAgent
} = {}) {
const support = getSupport();
const window = getWindow();
const platform = window.navigator.platform;
const ua = userAgent || window.navigator.userAgent;
const device = {
ios: false,
android: false
};
const screenWidth = window.screen.width;
const screenHeight = window.screen.height;
const android = ua.match(/(Android);?[\s\/]+([\d.]+)?/); // eslint-disable-line
let ipad = ua.match(/(iPad).*OS\s([\d_]+)/);
const ipod = ua.match(/(iPod)(.*OS\s([\d_]+))?/);
const iphone = !ipad && ua.match(/(iPhone\sOS|iOS)\s([\d_]+)/);
const windows = platform === 'Win32';
let macos = platform === 'MacIntel';
// iPadOs 13 fix
const iPadScreens = ['1024x1366', '1366x1024', '834x1194', '1194x834', '834x1112', '1112x834', '768x1024', '1024x768', '820x1180', '1180x820', '810x1080', '1080x810'];
if (!ipad && macos && support.touch && iPadScreens.indexOf(`${screenWidth}x${screenHeight}`) >= 0) {
ipad = ua.match(/(Version)\/([\d.]+)/);
if (!ipad) ipad = [0, 1, '13_0_0'];
macos = false;
}
// Android
if (android && !windows) {
device.os = 'android';
device.android = true;
}
if (ipad || iphone || ipod) {
device.os = 'ios';
device.ios = true;
}
// Export object
return device;
}
function getDevice(overrides = {}) {
if (!deviceCached) {
deviceCached = calcDevice(overrides);
}
return deviceCached;
}
export { getDevice };
+17
View File
@@ -0,0 +1,17 @@
import { getWindow, getDocument } from 'ssr-window';
let support;
function calcSupport() {
const window = getWindow();
const document = getDocument();
return {
smoothScroll: document.documentElement && 'scrollBehavior' in document.documentElement.style,
touch: !!('ontouchstart' in window || window.DocumentTouch && document instanceof window.DocumentTouch)
};
}
function getSupport() {
if (!support) {
support = calcSupport();
}
return support;
}
export { getSupport };
+9
View File
@@ -0,0 +1,9 @@
export const processLazyPreloader = (swiper, imageEl) => {
if (!swiper || swiper.destroyed || !swiper.params) return;
const slideSelector = () => swiper.isElement ? `swiper-slide` : `.${swiper.params.slideClass}`;
const slideEl = imageEl.closest(slideSelector());
if (slideEl) {
const lazyEl = slideEl.querySelector(`.${swiper.params.lazyPreloaderClass}`);
if (lazyEl) lazyEl.remove();
}
};
+268
View File
@@ -0,0 +1,268 @@
import { getWindow, getDocument } from 'ssr-window';
function deleteProps(obj) {
const object = obj;
Object.keys(object).forEach(key => {
try {
object[key] = null;
} catch (e) {
// no getter for object
}
try {
delete object[key];
} catch (e) {
// something got wrong
}
});
}
function nextTick(callback, delay = 0) {
return setTimeout(callback, delay);
}
function now() {
return Date.now();
}
function getComputedStyle(el) {
const window = getWindow();
let style;
if (window.getComputedStyle) {
style = window.getComputedStyle(el, null);
}
if (!style && el.currentStyle) {
style = el.currentStyle;
}
if (!style) {
style = el.style;
}
return style;
}
function getTranslate(el, axis = 'x') {
const window = getWindow();
let matrix;
let curTransform;
let transformMatrix;
const curStyle = getComputedStyle(el, null);
if (window.WebKitCSSMatrix) {
curTransform = curStyle.transform || curStyle.webkitTransform;
if (curTransform.split(',').length > 6) {
curTransform = curTransform.split(', ').map(a => a.replace(',', '.')).join(', ');
}
// Some old versions of Webkit choke when 'none' is passed; pass
// empty string instead in this case
transformMatrix = new window.WebKitCSSMatrix(curTransform === 'none' ? '' : curTransform);
} else {
transformMatrix = curStyle.MozTransform || curStyle.OTransform || curStyle.MsTransform || curStyle.msTransform || curStyle.transform || curStyle.getPropertyValue('transform').replace('translate(', 'matrix(1, 0, 0, 1,');
matrix = transformMatrix.toString().split(',');
}
if (axis === 'x') {
// Latest Chrome and webkits Fix
if (window.WebKitCSSMatrix) curTransform = transformMatrix.m41;
// Crazy IE10 Matrix
else if (matrix.length === 16) curTransform = parseFloat(matrix[12]);
// Normal Browsers
else curTransform = parseFloat(matrix[4]);
}
if (axis === 'y') {
// Latest Chrome and webkits Fix
if (window.WebKitCSSMatrix) curTransform = transformMatrix.m42;
// Crazy IE10 Matrix
else if (matrix.length === 16) curTransform = parseFloat(matrix[13]);
// Normal Browsers
else curTransform = parseFloat(matrix[5]);
}
return curTransform || 0;
}
function isObject(o) {
return typeof o === 'object' && o !== null && o.constructor && Object.prototype.toString.call(o).slice(8, -1) === 'Object';
}
function isNode(node) {
// eslint-disable-next-line
if (typeof window !== 'undefined' && typeof window.HTMLElement !== 'undefined') {
return node instanceof HTMLElement;
}
return node && (node.nodeType === 1 || node.nodeType === 11);
}
function extend(...args) {
const to = Object(args[0]);
const noExtend = ['__proto__', 'constructor', 'prototype'];
for (let i = 1; i < args.length; i += 1) {
const nextSource = args[i];
if (nextSource !== undefined && nextSource !== null && !isNode(nextSource)) {
const keysArray = Object.keys(Object(nextSource)).filter(key => noExtend.indexOf(key) < 0);
for (let nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex += 1) {
const nextKey = keysArray[nextIndex];
const desc = Object.getOwnPropertyDescriptor(nextSource, nextKey);
if (desc !== undefined && desc.enumerable) {
if (isObject(to[nextKey]) && isObject(nextSource[nextKey])) {
if (nextSource[nextKey].__swiper__) {
to[nextKey] = nextSource[nextKey];
} else {
extend(to[nextKey], nextSource[nextKey]);
}
} else if (!isObject(to[nextKey]) && isObject(nextSource[nextKey])) {
to[nextKey] = {};
if (nextSource[nextKey].__swiper__) {
to[nextKey] = nextSource[nextKey];
} else {
extend(to[nextKey], nextSource[nextKey]);
}
} else {
to[nextKey] = nextSource[nextKey];
}
}
}
}
}
return to;
}
function setCSSProperty(el, varName, varValue) {
el.style.setProperty(varName, varValue);
}
function animateCSSModeScroll({
swiper,
targetPosition,
side
}) {
const window = getWindow();
const startPosition = -swiper.translate;
let startTime = null;
let time;
const duration = swiper.params.speed;
swiper.wrapperEl.style.scrollSnapType = 'none';
window.cancelAnimationFrame(swiper.cssModeFrameID);
const dir = targetPosition > startPosition ? 'next' : 'prev';
const isOutOfBound = (current, target) => {
return dir === 'next' && current >= target || dir === 'prev' && current <= target;
};
const animate = () => {
time = new Date().getTime();
if (startTime === null) {
startTime = time;
}
const progress = Math.max(Math.min((time - startTime) / duration, 1), 0);
const easeProgress = 0.5 - Math.cos(progress * Math.PI) / 2;
let currentPosition = startPosition + easeProgress * (targetPosition - startPosition);
if (isOutOfBound(currentPosition, targetPosition)) {
currentPosition = targetPosition;
}
swiper.wrapperEl.scrollTo({
[side]: currentPosition
});
if (isOutOfBound(currentPosition, targetPosition)) {
swiper.wrapperEl.style.overflow = 'hidden';
swiper.wrapperEl.style.scrollSnapType = '';
setTimeout(() => {
swiper.wrapperEl.style.overflow = '';
swiper.wrapperEl.scrollTo({
[side]: currentPosition
});
});
window.cancelAnimationFrame(swiper.cssModeFrameID);
return;
}
swiper.cssModeFrameID = window.requestAnimationFrame(animate);
};
animate();
}
function getSlideTransformEl(slideEl) {
return slideEl.querySelector('.swiper-slide-transform') || slideEl.shadowEl && slideEl.shadowEl.querySelector('.swiper-slide-transform') || slideEl;
}
function findElementsInElements(elements = [], selector = '') {
const found = [];
elements.forEach(el => {
found.push(...el.querySelectorAll(selector));
});
return found;
}
function elementChildren(element, selector = '') {
return [...element.children].filter(el => el.matches(selector));
}
function createElement(tag, classes = []) {
const el = document.createElement(tag);
el.classList.add(...(Array.isArray(classes) ? classes : [classes]));
return el;
}
function elementOffset(el) {
const window = getWindow();
const document = getDocument();
const box = el.getBoundingClientRect();
const body = document.body;
const clientTop = el.clientTop || body.clientTop || 0;
const clientLeft = el.clientLeft || body.clientLeft || 0;
const scrollTop = el === window ? window.scrollY : el.scrollTop;
const scrollLeft = el === window ? window.scrollX : el.scrollLeft;
return {
top: box.top + scrollTop - clientTop,
left: box.left + scrollLeft - clientLeft
};
}
function elementPrevAll(el, selector) {
const prevEls = [];
while (el.previousElementSibling) {
const prev = el.previousElementSibling; // eslint-disable-line
if (selector) {
if (prev.matches(selector)) prevEls.push(prev);
} else prevEls.push(prev);
el = prev;
}
return prevEls;
}
function elementNextAll(el, selector) {
const nextEls = [];
while (el.nextElementSibling) {
const next = el.nextElementSibling; // eslint-disable-line
if (selector) {
if (next.matches(selector)) nextEls.push(next);
} else nextEls.push(next);
el = next;
}
return nextEls;
}
function elementStyle(el, prop) {
const window = getWindow();
return window.getComputedStyle(el, null).getPropertyValue(prop);
}
function elementIndex(el) {
let child = el;
let i;
if (child) {
i = 0;
// eslint-disable-next-line
while ((child = child.previousSibling) !== null) {
if (child.nodeType === 1) i += 1;
}
return i;
}
return undefined;
}
function elementParents(el, selector) {
const parents = []; // eslint-disable-line
let parent = el.parentElement; // eslint-disable-line
while (parent) {
if (selector) {
if (parent.matches(selector)) parents.push(parent);
} else {
parents.push(parent);
}
parent = parent.parentElement;
}
return parents;
}
function elementTransitionEnd(el, callback) {
function fireCallBack(e) {
if (e.target !== el) return;
callback.call(el, e);
el.removeEventListener('transitionend', fireCallBack);
}
if (callback) {
el.addEventListener('transitionend', fireCallBack);
}
}
function elementOuterSize(el, size, includeMargins) {
const window = getWindow();
if (includeMargins) {
return el[size === 'width' ? 'offsetWidth' : 'offsetHeight'] + parseFloat(window.getComputedStyle(el, null).getPropertyValue(size === 'width' ? 'margin-right' : 'margin-top')) + parseFloat(window.getComputedStyle(el, null).getPropertyValue(size === 'width' ? 'margin-left' : 'margin-bottom'));
}
return el.offsetWidth;
}
export { animateCSSModeScroll, deleteProps, nextTick, now, getTranslate, isObject, extend, getComputedStyle, setCSSProperty, getSlideTransformEl,
// dom
findElementsInElements, createElement, elementChildren, elementOffset, elementPrevAll, elementNextAll, elementStyle, elementIndex, elementParents, elementTransitionEnd, elementOuterSize };