Commit 44b22a3b sunneyouyang

update

1 个父辈 2141fd7c
正在显示 151 个修改的文件 包含 150 行增加4533 行删除
import App from './App'
// 关闭热更新
if (process.env.NODE_ENV === 'production') {
plus.runtime.getProperty(plus.runtime.appid, function(widgetInfo) {
plus.runtime.setAutoupdate(false);
});
}
// #ifndef VUE3
import Vue from 'vue'
Vue.config.productionTip = false
......
{
"name" : "金球体育",
"appid" : "__UNI__E81960F",
"description" : "金球体育",
"versionName" : "1.0.2",
"versionCode" : 102,
"name" : "红单体育",
"appid" : "__UNI__F4EDEA4",
"description" : "红单体育",
"versionName" : "1.1.1",
"versionCode" : 111,
"transformPx" : false,
/* 5+App特有相关 */
"app-plus" : {
......@@ -44,7 +44,8 @@
},
/* ios打包配置 */
"ios" : {
"dSYMs" : false
"dSYMs" : false,
"idfa" : false
},
/* SDK配置 */
"sdkConfigs" : {
......
......@@ -36,22 +36,6 @@
}
}, {
"path": "pages/login_pwd/login_pwd",
"style": {
"navigationBarTitleText": "账号登录",
"enablePullDownRefresh": false,
"navigationStyle": "custom"
}
}, {
"path": "pages/login_yzm/login_yzm",
"style": {
"navigationBarTitleText": "验证码登录",
"enablePullDownRefresh": false,
"navigationStyle": "custom"
}
}, {
"path": "pages/suggest/suggest",
"style": {
"navigationBarTitleText": "提建议",
......
......@@ -64,98 +64,116 @@
}
},
async onLoad() {
this.loading = true
await this.requestData()
this.loading = false
this.loading = true
try{
await this.requestData();
this.loading = false;
}catch(e){
let that = this;
var id = setInterval(async ()=>{
try{
await that.requestData();
that.loading = false;
clearInterval(id);
}catch(ee){
}
},500);
console.info(`home error ${e.message}`);
}
},
async onPullDownRefresh() {
await this.requestData()
await this.requestData();
this.loading = false;
uni.stopPullDownRefresh(); //停止刷新
},
methods: {
async requestData() {
let infoRes = await http.gql({
"query": `{
liveScore(lotIds: "72,45",order:[["MatchTime","desc"]], limit:100) {
count
matchs {
Id
InfoId
LotteryId
IssueName
MatchTime
MatchNumber
HostName
HostRed
HostYellow
GuestName
GuestRed
GuestYellow
GameName
QcBf
BcBf
HostTeam {
LogoFullPath
}
GuestTeam {
LogoFullPath
}
MatchState
MatchRound
PreTotalScore
Temperature
SportsInjury
SportsInfoCount
Sportsdt {
SportsdtMatchId
}
}
}
} `
})
let matchs = infoRes.data.liveScore.matchs
if (this.match_map.size > 0) {
this.match_map.clear()
}
this.tabs.length = 0
let zhongyao = []
let wancheng = []
for (let m of matchs) {
if (m.MatchState === "完") {
wancheng.push(m)
} else if (m.MatchState === "未") {
zhongyao.push(m)
}
async requestData() {
try{
let infoRes = await http.gql({
"query": `{
liveScore(lotIds: "72,45",order:[["MatchTime","desc"]], limit:100) {
count
matchs {
Id
InfoId
LotteryId
IssueName
MatchTime
MatchNumber
HostName
HostRed
HostYellow
GuestName
GuestRed
GuestYellow
GameName
QcBf
BcBf
HostTeam {
LogoFullPath
}
GuestTeam {
LogoFullPath
}
MatchState
MatchRound
PreTotalScore
Temperature
SportsInjury
SportsInfoCount
Sportsdt {
SportsdtMatchId
}
}
}
} `
})
let matchs = infoRes.data.liveScore.matchs
if (this.match_map.size > 0) {
this.match_map.clear()
}
this.tabs.length = 0
let zhongyao = []
let wancheng = []
for (let m of matchs) {
if (m.MatchState === "完") {
wancheng.push(m)
} else if (m.MatchState === "未") {
zhongyao.push(m)
}
}
zhongyao.sort((item1, item2) => (new Date(item1.IssueName) - new Date(item2.IssueName)))
this.match_map.set("重要", zhongyao)
this.match_map.set("完赛", wancheng)
var followList = await followHelper.getFollowList()
this.match_map.set("关注", followList)
for (let m of matchs) {
if (m.GameName) {
var list = this.match_map.get(m.GameName)
if (!list) {
list = []
}
list.push(m)
this.match_map.set(m.GameName, list)
}
}
for (const [key, value] of this.match_map.entries()) {
console.log(key, value.length);
}
this.tabs.push(...this.match_map.keys())
}catch(e){
console.info(e.message);
}
zhongyao.sort((item1, item2) => (new Date(item1.IssueName) - new Date(item2.IssueName)))
this.match_map.set("重要", zhongyao)
this.match_map.set("完赛", wancheng)
var followList = await followHelper.getFollowList()
this.match_map.set("关注", followList)
for (let m of matchs) {
if (m.GameName) {
var list = this.match_map.get(m.GameName)
if (!list) {
list = []
}
list.push(m)
this.match_map.set(m.GameName, list)
}
}
for (const [key, value] of this.match_map.entries()) {
console.log(key, value.length);
}
this.tabs.push(...this.match_map.keys())
},
updateItem(id, index) {
console.log("id:" + id + "index:" + index)
......
......@@ -18,7 +18,7 @@
<text style="font-size: 36rpx; color: #333333; font-weight: 600;">
{{ this.hasLogin ? this.userName : '登陆/注册' }}</text>
<view style="margin-top: 15rpx;">
<text style="font-size: 26rpx; color: #999999;">欢迎来到金球体育</text>
<text style="font-size: 26rpx; color: #999999;">欢迎来到红单体育</text>
</view>
</view>
......@@ -31,26 +31,26 @@
<view class="qh-list-c" @click="gotoSuggest()">
<view style="display: flex;">
<image src="../../static/mine_icons/mine_feedback_icon.png" style="width: 50rpx; height: 50rpx;" />
<text class="list-text">提建议/问题反馈</text>
</view>
<image src="../../static/mine_icons/mine_right_arrow.png" style="width: 40rpx; height: 40rpx;" />
<image src="../../static/mine_icons/right_arrow.png" style="width: 40rpx; height: 40rpx;" />
</view>
<view class="qh-list-c" @tap="share">
<view style="display: flex;">
<image src="../../static/mine_icons/mine_share_icon.png" style="width: 50rpx; height: 50rpx;" />
<text class="list-text">分享给好友</text>
</view>
<image src="../../static/mine_icons/mine_right_arrow.png" style="width: 40rpx; height: 40rpx;" />
<image src="../../static/mine_icons/right_arrow.png" style="width: 40rpx; height: 40rpx;" />
</view>
<view class="qh-list-c" @click="gotoSettings()">
<view style="display: flex;">
<image src="../../static/mine_icons/mine_settings_icon.png" style="width: 50rpx; height: 50rpx;" />
<text class="list-text">设置</text>
</view>
<image src="../../static/mine_icons/mine_right_arrow.png" style="width: 40rpx; height: 40rpx;" />
<image src="../../static/mine_icons/right_arrow.png" style="width: 40rpx; height: 40rpx;" />
</view>
</view>
......@@ -178,11 +178,11 @@
},
success: e => {
if (e.tapIndex == 0) {
_this.clip_board("推荐一个很好用的体育APP给你玩,上苹果应用市场搜索:金球体育。你试试看! ");
_this.clip_board("推荐一个很好用的体育APP给你玩,上苹果应用市场搜索:红单体育。你试试看! ");
plus.runtime.openURL("weixin://");
}
if (e.tapIndex == 1) {
_this.clip_board("推荐一个很好用的体育APP给你玩,上苹果应用市场搜索:金球体育。你试试看! ");
_this.clip_board("推荐一个很好用的体育APP给你玩,上苹果应用市场搜索:红单体育。你试试看! ");
}
}
});
......
<template>
<view>
<web-view :src="url"></web-view>
<web-view style="padding-top: 10rem;" :src="url"></web-view>
</view>
</template>
......@@ -33,26 +33,26 @@ export default {
AppVersion: encodeURI(JSON.stringify(appInfo))
}
// #ifdef APP-PLUS
var nwating = plus.nativeUI.showWaiting();
wv = plus.webview.create("", "normal_h5-webview", {
additionalHttpHeaders: {
header: header,
},
plusrequire: "none", //禁止远程网页使用plus的API,有些使用mui制作的网页可能会监听plus.key,造成关闭页面混乱,可以通过这种方式禁止
'uni-app': 'none', //不加载uni-app渲染层框架,避免样式冲突
top: common.customBarH,
height: uni.getSystemInfoSync().windowHeight
})
let pages = getCurrentPages()
let currentPage = pages[pages.length - 1]
var currentWebview = currentPage.$getAppWebview() //此对象相当于html5plus里的plus.webview.currentWebview()。在uni-app里vue页面直接使用plus.webview.currentWebview()无效
currentWebview.append(wv);
wv.loadURL(this.url, header);
wv.addEventListener('loaded', function () {
// wv.evalJS("$(\".header\").hide();");
nwating.close();
wv.show();
}, false);
// var nwating = plus.nativeUI.showWaiting();
// wv = plus.webview.create("", "normal_h5-webview", {
// additionalHttpHeaders: {
// header: header,
// },
// plusrequire: "none", //禁止远程网页使用plus的API,有些使用mui制作的网页可能会监听plus.key,造成关闭页面混乱,可以通过这种方式禁止
// 'uni-app': 'none', //不加载uni-app渲染层框架,避免样式冲突
// top: common.customBarH,
// height: uni.getSystemInfoSync().windowHeight
// })
// let pages = getCurrentPages()
// let currentPage = pages[pages.length - 1]
// var currentWebview = currentPage.$getAppWebview() //此对象相当于html5plus里的plus.webview.currentWebview()。在uni-app里vue页面直接使用plus.webview.currentWebview()无效
// currentWebview.append(wv);
// wv.loadURL(this.url, header);
// wv.addEventListener('loaded', function () {
// // wv.evalJS("$(\".header\").hide();");
// nwating.close();
// wv.show();
// }, false);
// #endif
}
}
......
......@@ -4,21 +4,21 @@
<view style="display: flex;">
<text class="list-text">账号注销</text>
</view>
<image src="@/static/mine_icons/arrow_right.png"
<image src="@/static/mine_icons/right.png"
style="width: 50rpx; height: 50rpx; margin-right: 30rpx;" />
</view>
<view class="qh-list-c" @click="onPrivacyPolicy()">
<view style="display: flex;">
<text class="list-text">用户隐私政策</text>
</view>
<image src="@/static/mine_icons/arrow_right.png"
<image src="@/static/mine_icons/right.png"
style="width: 50rpx; height: 50rpx; margin-right: 30rpx;" />
</view>
<view class="qh-list-c" @click="showUpdateVersion()">
<text class="update_text">{{this.versionName}}</text>
<view style="display: flex; " >
<text style="font-size: 27rpx;">{{this.updateInfoStr}}</text>
<image src="@/static/mine_icons/arrow_right.png"
<image src="@/static/mine_icons/right.png"
style="width: 50rpx; height: 50rpx; margin-right: 30rpx;" />
</view>
</view>
......
此文件类型无法预览
<template>
<view class="chartsview">
<view class="charts-error"></view>
<view class="charts-font">{{errorMessage==null?'请点击重试':errorMessage}}</view>
</view>
</template>
<script>
export default {
name: 'qiun-error',
props: {
errorMessage: {
type: String,
default: null
},
},
data() {
return {
};
},
}
</script>
<style>
.chartsview {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
flex: 1;
justify-content: center;
align-items: center;
}
.charts-font{
font-size: 14px;
color: #CCCCCC;
margin-top: 10px;
}
.charts-error{
width: 128px;
height: 128px;
background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAUz0lEQVR4Xu1de3Bc1X3+zmp3jYVWfkPAgCWwY8zLEglNQCSW0yT9o2SQaDKdNulUykwfM+k09p+J3ImYIPJXi9yZzDSZZiwyaZuZBCwnNG1DMogEmUAAy7xs/MAyNhCMjWWtsK1deU/n23Ov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kTSuxfuNq7IwJhODTCv4YUYunsjkc3f8+Bo7M4v8KYy5cixmPKVxXaWymnDWXLQGGxiVjAmaCoZy1XPbPSon9O+4VHSYhaIdJid2lhJESUzvu1f80nBNhywYA3cY5oOhI8uqlaLk+hfWXPUc1CHAijSOnL2CGXePAZKHBzd0PgEG50jZR6pZrTGXZpWwA+J248Vw4KNAAQDj4ULNVBA6Abz8ru8Ul9SVyITCVbUY/DRsjxLxLSmhdYSYEHh3oEiMch2rm0iXssqHSxI57xfZKU/ChZ+QjAOb1c6XnM+g3T4NKzRc4AIbGZR8TSeaCYzH0Ua8ZIeY8QzXbSBEAcvlSZyvwBKYPndb10LjkBQ1a4NV8P51u8zTQ6eynT+AA8LOIxjO1o0ADALWjfShmjhwACgNPoaCgsnWOO+VLwrJOq3VEDgCGLrbMjdeK0EEGZqr9DpEDgFXgqdpEK50vlsPUQJf/nHwt1///89bqDjCPWPAAAAAASUVORK5CYII=");
background-position: center;
}
</style>
<template>
<view class="container loading1">
<view class="shape shape1"></view>
<view class="shape shape2"></view>
<view class="shape shape3"></view>
<view class="shape shape4"></view>
</view>
</template>
<script>
export default {
name: 'loading1',
data() {
return {
};
}
}
</script>
<style scoped="true">
.container {
width: 30px;
height: 30px;
position: relative;
}
.container.loading1 {
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
}
.container .shape {
position: absolute;
width: 10px;
height: 10px;
border-radius: 1px;
}
.container .shape.shape1 {
left: 0;
background-color: #1890FF;
}
.container .shape.shape2 {
right: 0;
background-color: #91CB74;
}
.container .shape.shape3 {
bottom: 0;
background-color: #FAC858;
}
.container .shape.shape4 {
bottom: 0;
right: 0;
background-color: #EE6666;
}
.loading1 .shape1 {
-webkit-animation: animation1shape1 0.5s ease 0s infinite alternate;
animation: animation1shape1 0.5s ease 0s infinite alternate;
}
@-webkit-keyframes animation1shape1 {
from {
-webkit-transform: translate(0, 0);
transform: translate(0, 0);
}
to {
-webkit-transform: translate(16px, 16px);
transform: translate(16px, 16px);
}
}
@keyframes animation1shape1 {
from {
-webkit-transform: translate(0, 0);
transform: translate(0, 0);
}
to {
-webkit-transform: translate(16px, 16px);
transform: translate(16px, 16px);
}
}
.loading1 .shape2 {
-webkit-animation: animation1shape2 0.5s ease 0s infinite alternate;
animation: animation1shape2 0.5s ease 0s infinite alternate;
}
@-webkit-keyframes animation1shape2 {
from {
-webkit-transform: translate(0, 0);
transform: translate(0, 0);
}
to {
-webkit-transform: translate(-16px, 16px);
transform: translate(-16px, 16px);
}
}
@keyframes animation1shape2 {
from {
-webkit-transform: translate(0, 0);
transform: translate(0, 0);
}
to {
-webkit-transform: translate(-16px, 16px);
transform: translate(-16px, 16px);
}
}
.loading1 .shape3 {
-webkit-animation: animation1shape3 0.5s ease 0s infinite alternate;
animation: animation1shape3 0.5s ease 0s infinite alternate;
}
@-webkit-keyframes animation1shape3 {
from {
-webkit-transform: translate(0, 0);
transform: translate(0, 0);
}
to {
-webkit-transform: translate(16px, -16px);
transform: translate(16px, -16px);
}
}
@keyframes animation1shape3 {
from {
-webkit-transform: translate(0, 0);
transform: translate(0, 0);
}
to {
-webkit-transform: translate(16px, -16px);
transform: translate(16px, -16px);
}
}
.loading1 .shape4 {
-webkit-animation: animation1shape4 0.5s ease 0s infinite alternate;
animation: animation1shape4 0.5s ease 0s infinite alternate;
}
@-webkit-keyframes animation1shape4 {
from {
-webkit-transform: translate(0, 0);
transform: translate(0, 0);
}
to {
-webkit-transform: translate(-16px, -16px);
transform: translate(-16px, -16px);
}
}
@keyframes animation1shape4 {
from {
-webkit-transform: translate(0, 0);
transform: translate(0, 0);
}
to {
-webkit-transform: translate(-16px, -16px);
transform: translate(-16px, -16px);
}
}
</style>
<template>
<view class="container loading2">
<view class="shape shape1"></view>
<view class="shape shape2"></view>
<view class="shape shape3"></view>
<view class="shape shape4"></view>
</view>
</template>
<script>
export default {
name: 'loading2',
data() {
return {
};
}
}
</script>
<style scoped="true">
.container {
width: 30px;
height: 30px;
position: relative;
}
.container.loading2 {
-webkit-transform: rotate(10deg);
transform: rotate(10deg);
}
.container.loading2 .shape {
border-radius: 5px;
}
.container.loading2{
-webkit-animation: rotation 1s infinite;
animation: rotation 1s infinite;
}
.container .shape {
position: absolute;
width: 10px;
height: 10px;
border-radius: 1px;
}
.container .shape.shape1 {
left: 0;
background-color: #1890FF;
}
.container .shape.shape2 {
right: 0;
background-color: #91CB74;
}
.container .shape.shape3 {
bottom: 0;
background-color: #FAC858;
}
.container .shape.shape4 {
bottom: 0;
right: 0;
background-color: #EE6666;
}
.loading2 .shape1 {
-webkit-animation: animation2shape1 0.5s ease 0s infinite alternate;
animation: animation2shape1 0.5s ease 0s infinite alternate;
}
@-webkit-keyframes animation2shape1 {
from {
-webkit-transform: translate(0, 0);
transform: translate(0, 0);
}
to {
-webkit-transform: translate(20px, 20px);
transform: translate(20px, 20px);
}
}
@keyframes animation2shape1 {
from {
-webkit-transform: translate(0, 0);
transform: translate(0, 0);
}
to {
-webkit-transform: translate(20px, 20px);
transform: translate(20px, 20px);
}
}
.loading2 .shape2 {
-webkit-animation: animation2shape2 0.5s ease 0s infinite alternate;
animation: animation2shape2 0.5s ease 0s infinite alternate;
}
@-webkit-keyframes animation2shape2 {
from {
-webkit-transform: translate(0, 0);
transform: translate(0, 0);
}
to {
-webkit-transform: translate(-20px, 20px);
transform: translate(-20px, 20px);
}
}
@keyframes animation2shape2 {
from {
-webkit-transform: translate(0, 0);
transform: translate(0, 0);
}
to {
-webkit-transform: translate(-20px, 20px);
transform: translate(-20px, 20px);
}
}
.loading2 .shape3 {
-webkit-animation: animation2shape3 0.5s ease 0s infinite alternate;
animation: animation2shape3 0.5s ease 0s infinite alternate;
}
@-webkit-keyframes animation2shape3 {
from {
-webkit-transform: translate(0, 0);
transform: translate(0, 0);
}
to {
-webkit-transform: translate(20px, -20px);
transform: translate(20px, -20px);
}
}
@keyframes animation2shape3 {
from {
-webkit-transform: translate(0, 0);
transform: translate(0, 0);
}
to {
-webkit-transform: translate(20px, -20px);
transform: translate(20px, -20px);
}
}
.loading2 .shape4 {
-webkit-animation: animation2shape4 0.5s ease 0s infinite alternate;
animation: animation2shape4 0.5s ease 0s infinite alternate;
}
@-webkit-keyframes animation2shape4 {
from {
-webkit-transform: translate(0, 0);
transform: translate(0, 0);
}
to {
-webkit-transform: translate(-20px, -20px);
transform: translate(-20px, -20px);
}
}
@keyframes animation2shape4 {
from {
-webkit-transform: translate(0, 0);
transform: translate(0, 0);
}
to {
-webkit-transform: translate(-20px, -20px);
transform: translate(-20px, -20px);
}
}
</style>
<template>
<view class="container loading3">
<view class="shape shape1"></view>
<view class="shape shape2"></view>
<view class="shape shape3"></view>
<view class="shape shape4"></view>
</view>
</template>
<script>
export default {
name: 'loading3',
data() {
return {
};
}
}
</script>
<style scoped="true">
.container {
width: 30px;
height: 30px;
position: relative;
}
.container.loading3 {
-webkit-animation: rotation 1s infinite;
animation: rotation 1s infinite;
}
.container.loading3 .shape1 {
border-top-left-radius: 10px;
}
.container.loading3 .shape2 {
border-top-right-radius: 10px;
}
.container.loading3 .shape3 {
border-bottom-left-radius: 10px;
}
.container.loading3 .shape4 {
border-bottom-right-radius: 10px;
}
.container .shape {
position: absolute;
width: 10px;
height: 10px;
border-radius: 1px;
}
.container .shape.shape1 {
left: 0;
background-color: #1890FF;
}
.container .shape.shape2 {
right: 0;
background-color: #91CB74;
}
.container .shape.shape3 {
bottom: 0;
background-color: #FAC858;
}
.container .shape.shape4 {
bottom: 0;
right: 0;
background-color: #EE6666;
}
.loading3 .shape1 {
-webkit-animation: animation3shape1 0.5s ease 0s infinite alternate;
animation: animation3shape1 0.5s ease 0s infinite alternate;
}
@-webkit-keyframes animation3shape1 {
from {
-webkit-transform: translate(0, 0);
transform: translate(0, 0);
}
to {
-webkit-transform: translate(5px, 5px);
transform: translate(5px, 5px);
}
}
@keyframes animation3shape1 {
from {
-webkit-transform: translate(0, 0);
transform: translate(0, 0);
}
to {
-webkit-transform: translate(5px, 5px);
transform: translate(5px, 5px);
}
}
.loading3 .shape2 {
-webkit-animation: animation3shape2 0.5s ease 0s infinite alternate;
animation: animation3shape2 0.5s ease 0s infinite alternate;
}
@-webkit-keyframes animation3shape2 {
from {
-webkit-transform: translate(0, 0);
transform: translate(0, 0);
}
to {
-webkit-transform: translate(-5px, 5px);
transform: translate(-5px, 5px);
}
}
@keyframes animation3shape2 {
from {
-webkit-transform: translate(0, 0);
transform: translate(0, 0);
}
to {
-webkit-transform: translate(-5px, 5px);
transform: translate(-5px, 5px);
}
}
.loading3 .shape3 {
-webkit-animation: animation3shape3 0.5s ease 0s infinite alternate;
animation: animation3shape3 0.5s ease 0s infinite alternate;
}
@-webkit-keyframes animation3shape3 {
from {
-webkit-transform: translate(0, 0);
transform: translate(0, 0);
}
to {
-webkit-transform: translate(5px, -5px);
transform: translate(5px, -5px);
}
}
@keyframes animation3shape3 {
from {
-webkit-transform: translate(0, 0);
transform: translate(0, 0);
}
to {
-webkit-transform: translate(5px, -5px);
transform: translate(5px, -5px);
}
}
.loading3 .shape4 {
-webkit-animation: animation3shape4 0.5s ease 0s infinite alternate;
animation: animation3shape4 0.5s ease 0s infinite alternate;
}
@-webkit-keyframes animation3shape4 {
from {
-webkit-transform: translate(0, 0);
transform: translate(0, 0);
}
to {
-webkit-transform: translate(-5px, -5px);
transform: translate(-5px, -5px);
}
}
@keyframes animation3shape4 {
from {
-webkit-transform: translate(0, 0);
transform: translate(0, 0);
}
to {
-webkit-transform: translate(-5px, -5px);
transform: translate(-5px, -5px);
}
}
</style>
<template>
<view class="container loading5">
<view class="shape shape1"></view>
<view class="shape shape2"></view>
<view class="shape shape3"></view>
<view class="shape shape4"></view>
</view>
</template>
<script>
export default {
name: 'loading5',
data() {
return {
};
}
}
</script>
<style scoped="true">
.container {
width: 30px;
height: 30px;
position: relative;
}
.container.loading5 .shape {
width: 15px;
height: 15px;
}
.container .shape {
position: absolute;
width: 10px;
height: 10px;
border-radius: 1px;
}
.container .shape.shape1 {
left: 0;
background-color: #1890FF;
}
.container .shape.shape2 {
right: 0;
background-color: #91CB74;
}
.container .shape.shape3 {
bottom: 0;
background-color: #FAC858;
}
.container .shape.shape4 {
bottom: 0;
right: 0;
background-color: #EE6666;
}
.loading5 .shape1 {
animation: animation5shape1 2s ease 0s infinite reverse;
}
@-webkit-keyframes animation5shape1 {
0% {
-webkit-transform: translate(0, 0);
transform: translate(0, 0);
}
25% {
-webkit-transform: translate(0, 15px);
transform: translate(0, 15px);
}
50% {
-webkit-transform: translate(15px, 15px);
transform: translate(15px, 15px);
}
75% {
-webkit-transform: translate(15px, 0);
transform: translate(15px, 0);
}
}
@keyframes animation5shape1 {
0% {
-webkit-transform: translate(0, 0);
transform: translate(0, 0);
}
25% {
-webkit-transform: translate(0, 15px);
transform: translate(0, 15px);
}
50% {
-webkit-transform: translate(15px, 15px);
transform: translate(15px, 15px);
}
75% {
-webkit-transform: translate(15px, 0);
transform: translate(15px, 0);
}
}
.loading5 .shape2 {
animation: animation5shape2 2s ease 0s infinite reverse;
}
@-webkit-keyframes animation5shape2 {
0% {
-webkit-transform: translate(0, 0);
transform: translate(0, 0);
}
25% {
-webkit-transform: translate(-15px, 0);
transform: translate(-15px, 0);
}
50% {
-webkit-transform: translate(-15px, 15px);
transform: translate(-15px, 15px);
}
75% {
-webkit-transform: translate(0, 15px);
transform: translate(0, 15px);
}
}
@keyframes animation5shape2 {
0% {
-webkit-transform: translate(0, 0);
transform: translate(0, 0);
}
25% {
-webkit-transform: translate(-15px, 0);
transform: translate(-15px, 0);
}
50% {
-webkit-transform: translate(-15px, 15px);
transform: translate(-15px, 15px);
}
75% {
-webkit-transform: translate(0, 15px);
transform: translate(0, 15px);
}
}
.loading5 .shape3 {
animation: animation5shape3 2s ease 0s infinite reverse;
}
@-webkit-keyframes animation5shape3 {
0% {
-webkit-transform: translate(0, 0);
transform: translate(0, 0);
}
25% {
-webkit-transform: translate(15px, 0);
transform: translate(15px, 0);
}
50% {
-webkit-transform: translate(15px, -15px);
transform: translate(15px, -15px);
}
75% {
-webkit-transform: translate(0, -15px);
transform: translate(0, -15px);
}
}
@keyframes animation5shape3 {
0% {
-webkit-transform: translate(0, 0);
transform: translate(0, 0);
}
25% {
-webkit-transform: translate(15px, 0);
transform: translate(15px, 0);
}
50% {
-webkit-transform: translate(15px, -15px);
transform: translate(15px, -15px);
}
75% {
-webkit-transform: translate(0, -15px);
transform: translate(0, -15px);
}
}
.loading5 .shape4 {
animation: animation5shape4 2s ease 0s infinite reverse;
}
@-webkit-keyframes animation5shape4 {
0% {
-webkit-transform: translate(0, 0);
transform: translate(0, 0);
}
25% {
-webkit-transform: translate(0, -15px);
transform: translate(0, -15px);
}
50% {
-webkit-transform: translate(-15px, -15px);
transform: translate(-15px, -15px);
}
75% {
-webkit-transform: translate(-15px, 0);
transform: translate(-15px, 0);
}
}
@keyframes animation5shape4 {
0% {
-webkit-transform: translate(0, 0);
transform: translate(0, 0);
}
25% {
-webkit-transform: translate(0, -15px);
transform: translate(0, -15px);
}
50% {
-webkit-transform: translate(-15px, -15px);
transform: translate(-15px, -15px);
}
75% {
-webkit-transform: translate(-15px, 0);
transform: translate(-15px, 0);
}
}
</style>
<template>
<view class="container loading6">
<view class="shape shape1"></view>
<view class="shape shape2"></view>
<view class="shape shape3"></view>
<view class="shape shape4"></view>
</view>
</template>
<script>
export default {
name: 'loading6',
data() {
return {
};
}
}
</script>
<style scoped="true">
.container {
width: 30px;
height: 30px;
position: relative;
}
.container.loading6 {
-webkit-animation: rotation 1s infinite;
animation: rotation 1s infinite;
}
.container.loading6 .shape {
width: 12px;
height: 12px;
border-radius: 2px;
}
.container .shape {
position: absolute;
width: 10px;
height: 10px;
border-radius: 1px;
}
.container .shape.shape1 {
left: 0;
background-color: #1890FF;
}
.container .shape.shape2 {
right: 0;
background-color: #91CB74;
}
.container .shape.shape3 {
bottom: 0;
background-color: #FAC858;
}
.container .shape.shape4 {
bottom: 0;
right: 0;
background-color: #EE6666;
}
.loading6 .shape1 {
-webkit-animation: animation6shape1 2s linear 0s infinite normal;
animation: animation6shape1 2s linear 0s infinite normal;
}
@-webkit-keyframes animation6shape1 {
0% {
-webkit-transform: translate(0, 0);
transform: translate(0, 0);
}
25% {
-webkit-transform: translate(0, 18px);
transform: translate(0, 18px);
}
50% {
-webkit-transform: translate(18px, 18px);
transform: translate(18px, 18px);
}
75% {
-webkit-transform: translate(18px, 0);
transform: translate(18px, 0);
}
}
@keyframes animation6shape1 {
0% {
-webkit-transform: translate(0, 0);
transform: translate(0, 0);
}
25% {
-webkit-transform: translate(0, 18px);
transform: translate(0, 18px);
}
50% {
-webkit-transform: translate(18px, 18px);
transform: translate(18px, 18px);
}
75% {
-webkit-transform: translate(18px, 0);
transform: translate(18px, 0);
}
}
.loading6 .shape2 {
-webkit-animation: animation6shape2 2s linear 0s infinite normal;
animation: animation6shape2 2s linear 0s infinite normal;
}
@-webkit-keyframes animation6shape2 {
0% {
-webkit-transform: translate(0, 0);
transform: translate(0, 0);
}
25% {
-webkit-transform: translate(-18px, 0);
transform: translate(-18px, 0);
}
50% {
-webkit-transform: translate(-18px, 18px);
transform: translate(-18px, 18px);
}
75% {
-webkit-transform: translate(0, 18px);
transform: translate(0, 18px);
}
}
@keyframes animation6shape2 {
0% {
-webkit-transform: translate(0, 0);
transform: translate(0, 0);
}
25% {
-webkit-transform: translate(-18px, 0);
transform: translate(-18px, 0);
}
50% {
-webkit-transform: translate(-18px, 18px);
transform: translate(-18px, 18px);
}
75% {
-webkit-transform: translate(0, 18px);
transform: translate(0, 18px);
}
}
.loading6 .shape3 {
-webkit-animation: animation6shape3 2s linear 0s infinite normal;
animation: animation6shape3 2s linear 0s infinite normal;
}
@-webkit-keyframes animation6shape3 {
0% {
-webkit-transform: translate(0, 0);
transform: translate(0, 0);
}
25% {
-webkit-transform: translate(18px, 0);
transform: translate(18px, 0);
}
50% {
-webkit-transform: translate(18px, -18px);
transform: translate(18px, -18px);
}
75% {
-webkit-transform: translate(0, -18px);
transform: translate(0, -18px);
}
}
@keyframes animation6shape3 {
0% {
-webkit-transform: translate(0, 0);
transform: translate(0, 0);
}
25% {
-webkit-transform: translate(18px, 0);
transform: translate(18px, 0);
}
50% {
-webkit-transform: translate(18px, -18px);
transform: translate(18px, -18px);
}
75% {
-webkit-transform: translate(0, -18px);
transform: translate(0, -18px);
}
}
.loading6 .shape4 {
-webkit-animation: animation6shape4 2s linear 0s infinite normal;
animation: animation6shape4 2s linear 0s infinite normal;
}
@-webkit-keyframes animation6shape4 {
0% {
-webkit-transform: translate(0, 0);
transform: translate(0, 0);
}
25% {
-webkit-transform: translate(0, -18px);
transform: translate(0, -18px);
}
50% {
-webkit-transform: translate(-18px, -18px);
transform: translate(-18px, -18px);
}
75% {
-webkit-transform: translate(-18px, 0);
transform: translate(-18px, 0);
}
}
@keyframes animation6shape4 {
0% {
-webkit-transform: translate(0, 0);
transform: translate(0, 0);
}
25% {
-webkit-transform: translate(0, -18px);
transform: translate(0, -18px);
}
50% {
-webkit-transform: translate(-18px, -18px);
transform: translate(-18px, -18px);
}
75% {
-webkit-transform: translate(-18px, 0);
transform: translate(-18px, 0);
}
}
</style>
<template>
<view>
<Loading1 v-if="loadingType==1"/>
<Loading2 v-if="loadingType==2"/>
<Loading3 v-if="loadingType==3"/>
<Loading4 v-if="loadingType==4"/>
<Loading5 v-if="loadingType==5"/>
</view>
</template>
<script>
import Loading1 from "./loading1.vue";
import Loading2 from "./loading2.vue";
import Loading3 from "./loading3.vue";
import Loading4 from "./loading4.vue";
import Loading5 from "./loading5.vue";
export default {
components:{Loading1,Loading2,Loading3,Loading4,Loading5},
name: 'qiun-loading',
props: {
loadingType: {
type: Number,
default: 2
},
},
data() {
return {
};
},
}
</script>
<style>
</style>
/*
* uCharts®
* 高性能跨平台图表库,支持H5、APP、小程序(微信/支付宝/百度/头条/QQ/360)、Vue、Taro等支持canvas的框架平台
* Copyright (c) 2021 QIUN®秋云 https://www.ucharts.cn All rights reserved.
* Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
* 复制使用请保留本段注释,感谢支持开源!
*
* uCharts®官方网站
* https://www.uCharts.cn
*
* 开源地址:
* https://gitee.com/uCharts/uCharts
*
* uni-app插件市场地址:
* http://ext.dcloud.net.cn/plugin?id=271
*
*/
// 通用配置项
// 主题颜色配置:如每个图表类型需要不同主题,请在对应图表类型上更改color属性
const color = ['#1890FF', '#91CB74', '#FAC858', '#EE6666', '#73C0DE', '#3CA272', '#FC8452', '#9A60B4', '#ea7ccc'];
const cfe = {
//demotype为自定义图表类型
"type": ["pie", "ring", "rose", "funnel", "line", "column", "area", "radar", "gauge","candle","demotype"],
//增加自定义图表类型,如果需要categories,请在这里加入您的图表类型例如最后的"demotype"
"categories": ["line", "column", "area", "radar", "gauge", "candle","demotype"],
//instance为实例变量承载属性,option为eopts承载属性,不要删除
"instance": {},
"option": {},
//下面是自定义format配置,因除H5端外的其他端无法通过props传递函数,只能通过此属性对应下标的方式来替换
"formatter":{
"tooltipDemo1":function(res){
let result = ''
for (let i in res) {
if (i == 0) {
result += res[i].axisValueLabel + '年销售额'
}
let value = '--'
if (res[i].data !== null) {
value = res[i].data
}
// #ifdef H5
result += '\n' + res[i].seriesName + ':' + value + ' 万元'
// #endif
// #ifdef APP-PLUS
result += '<br/>' + res[i].marker + res[i].seriesName + ':' + value + ' 万元'
// #endif
}
return result;
},
legendFormat:function(name){
return "自定义图例+"+name;
},
yAxisFormatDemo:function (value, index) {
return value + '元';
},
seriesFormatDemo:function(res){
return res.name + '年' + res.value + '元';
}
},
//这里演示了自定义您的图表类型的option,可以随意命名,之后在组件上 type="demotype" 后,组件会调用这个花括号里的option,如果组件上还存在eopts参数,会将demotype与eopts中option合并后渲染图表。
"demotype":{
"color": color,
//在这里填写echarts的option即可
},
//下面是自定义配置,请添加项目所需的通用配置
"column": {
"color": color,
"title": {
"text": ''
},
"tooltip": {
"trigger": 'axis'
},
"grid": {
"top": 30,
"bottom": 50,
"right": 15,
"left": 40
},
"legend": {
"bottom": 'left',
},
"toolbox": {
"show": false,
},
"xAxis": {
"type": 'category',
"axisLabel": {
"color": '#666666'
},
"axisLine": {
"lineStyle": {
"color": '#CCCCCC'
}
},
"boundaryGap": true,
"data": []
},
"yAxis": {
"type": 'value',
"axisTick": {
"show": false,
},
"axisLabel": {
"color": '#666666'
},
"axisLine": {
"lineStyle": {
"color": '#CCCCCC'
}
},
},
"seriesTemplate": {
"name": '',
"type": 'bar',
"data": [],
"barwidth": 20,
"label": {
"show": true,
"color": "#666666",
"position": 'top',
},
},
},
"line": {
"color": color,
"title": {
"text": ''
},
"tooltip": {
"trigger": 'axis'
},
"grid": {
"top": 30,
"bottom": 50,
"right": 15,
"left": 40
},
"legend": {
"bottom": 'left',
},
"toolbox": {
"show": false,
},
"xAxis": {
"type": 'category',
"axisLabel": {
"color": '#666666'
},
"axisLine": {
"lineStyle": {
"color": '#CCCCCC'
}
},
"boundaryGap": true,
"data": []
},
"yAxis": {
"type": 'value',
"axisTick": {
"show": false,
},
"axisLabel": {
"color": '#666666'
},
"axisLine": {
"lineStyle": {
"color": '#CCCCCC'
}
},
},
"seriesTemplate": {
"name": '',
"type": 'line',
"data": [],
"barwidth": 20,
"label": {
"show": true,
"color": "#666666",
"position": 'top',
},
},
},
"area": {
"color": color,
"title": {
"text": ''
},
"tooltip": {
"trigger": 'axis'
},
"grid": {
"top": 30,
"bottom": 50,
"right": 15,
"left": 40
},
"legend": {
"bottom": 'left',
},
"toolbox": {
"show": false,
},
"xAxis": {
"type": 'category',
"axisLabel": {
"color": '#666666'
},
"axisLine": {
"lineStyle": {
"color": '#CCCCCC'
}
},
"boundaryGap": true,
"data": []
},
"yAxis": {
"type": 'value',
"axisTick": {
"show": false,
},
"axisLabel": {
"color": '#666666'
},
"axisLine": {
"lineStyle": {
"color": '#CCCCCC'
}
},
},
"seriesTemplate": {
"name": '',
"type": 'line',
"data": [],
"areaStyle": {},
"label": {
"show": true,
"color": "#666666",
"position": 'top',
},
},
},
"pie": {
"color": color,
"title": {
"text": ''
},
"tooltip": {
"trigger": 'item'
},
"grid": {
"top": 40,
"bottom": 30,
"right": 15,
"left": 15
},
"legend": {
"bottom": 'left',
},
"seriesTemplate": {
"name": '',
"type": 'pie',
"data": [],
"radius": '50%',
"label": {
"show": true,
"color": "#666666",
"position": 'top',
},
},
},
"ring": {
"color": color,
"title": {
"text": ''
},
"tooltip": {
"trigger": 'item'
},
"grid": {
"top": 40,
"bottom": 30,
"right": 15,
"left": 15
},
"legend": {
"bottom": 'left',
},
"seriesTemplate": {
"name": '',
"type": 'pie',
"data": [],
"radius": ['40%', '70%'],
"avoidLabelOverlap": false,
"label": {
"show": true,
"color": "#666666",
"position": 'top',
},
"labelLine": {
"show": true
},
},
},
"rose": {
"color": color,
"title": {
"text": ''
},
"tooltip": {
"trigger": 'item'
},
"legend": {
"top": 'bottom'
},
"seriesTemplate": {
"name": '',
"type": 'pie',
"data": [],
"radius": "55%",
"center": ['50%', '50%'],
"roseType": 'area',
},
},
"funnel": {
"color": color,
"title": {
"text": ''
},
"tooltip": {
"trigger": 'item',
"formatter": "{b} : {c}%"
},
"legend": {
"top": 'bottom'
},
"seriesTemplate": {
"name": '',
"type": 'funnel',
"left": '10%',
"top": 60,
"bottom": 60,
"width": '80%',
"min": 0,
"max": 100,
"minSize": '0%',
"maxSize": '100%',
"sort": 'descending',
"gap": 2,
"label": {
"show": true,
"position": 'inside'
},
"labelLine": {
"length": 10,
"lineStyle": {
"width": 1,
"type": 'solid'
}
},
"itemStyle": {
"bordercolor": '#fff',
"borderwidth": 1
},
"emphasis": {
"label": {
"fontSize": 20
}
},
"data": [],
},
},
"gauge": {
"color": color,
"tooltip": {
"formatter": '{a} <br/>{b} : {c}%'
},
"seriesTemplate": {
"name": '业务指标',
"type": 'gauge',
"detail": {"formatter": '{value}%'},
"data": [{"value": 50, "name": '完成率'}]
},
},
"candle": {
"xAxis": {
"data": []
},
"yAxis": {},
"color": color,
"title": {
"text": ''
},
"dataZoom": [{
"type": 'inside',
"xAxisIndex": [0, 1],
"start": 10,
"end": 100
},
{
"show": true,
"xAxisIndex": [0, 1],
"type": 'slider',
"bottom": 10,
"start": 10,
"end": 100
}
],
"seriesTemplate": {
"name": '',
"type": 'k',
"data": [],
},
}
}
export default cfe;
\ No newline at end of file
# uCharts JSSDK说明
1、如不使用uCharts组件,可直接引用u-charts.js,打包编译后会`自动压缩`,压缩后体积约为`120kb`
2、如果120kb的体积仍需压缩,请手到uCharts官网通过在线定制选择您需要的图表。
3、config-ucharts.js为uCharts组件的用户配置文件,升级前请`自行备份config-ucharts.js`文件,以免被强制覆盖。
4、config-echarts.js为ECharts组件的用户配置文件,升级前请`自行备份config-echarts.js`文件,以免被强制覆盖。
\ No newline at end of file
{
"id": "qiun-data-charts",
"displayName": "秋云 ucharts echarts 高性能跨全端图表组件",
"version": "2.5.0-20230101",
"description": "uCharts 新增正负柱状图!支持H5及APP用 ucharts echarts 渲染图表,uniapp可视化首选组件",
"keywords": [
"ucharts",
"echarts",
"f2",
"图表",
"可视化"
],
"repository": "https://gitee.com/uCharts/uCharts",
"engines": {
"HBuilderX": "^3.3.8"
},
"dcloudext": {
"sale": {
"regular": {
"price": "0.00"
},
"sourcecode": {
"price": "0.00"
}
},
"contact": {
"qq": "474119"
},
"declaration": {
"ads": "无",
"data": "插件不采集任何数据",
"permissions": "无"
},
"npmurl": "https://www.npmjs.com/~qiun",
"type": "component-vue"
},
"uni_modules": {
"dependencies": [],
"encrypt": [],
"platforms": {
"cloud": {
"tcb": "y",
"aliyun": "y"
},
"client": {
"App": {
"app-vue": "y",
"app-nvue": "y"
},
"H5-mobile": {
"Safari": "y",
"Android Browser": "y",
"微信浏览器(Android)": "y",
"QQ浏览器(Android)": "y"
},
"H5-pc": {
"Chrome": "y",
"IE": "y",
"Edge": "y",
"Firefox": "y",
"Safari": "y"
},
"小程序": {
"微信": "y",
"阿里": "y",
"百度": "y",
"字节跳动": "y",
"QQ": "y"
},
"快应用": {
"华为": "y",
"联盟": "y"
},
"Vue": {
"vue2": "y",
"vue3": "y"
}
}
}
}
}
\ No newline at end of file
![logo](https://img-blog.csdnimg.cn/4a276226973841468c1be356f8d9438b.png)
[![star](https://gitee.com/uCharts/uCharts/badge/star.svg?theme=gvp)](https://gitee.com/uCharts/uCharts/stargazers)
[![fork](https://gitee.com/uCharts/uCharts/badge/fork.svg?theme=gvp)](https://gitee.com/uCharts/uCharts/members)
[![License](https://img.shields.io/badge/license-Apache%202-4EB1BA.svg)](https://www.apache.org/licenses/LICENSE-2.0.html)
[![npm package](https://img.shields.io/npm/v/@qiun/ucharts.svg?style=flat-square)](https://www.npmjs.com/~qiun)
## uCharts简介
`uCharts`是一款基于`canvas API`开发的适用于所有前端应用的图表库,开发者编写一套代码,可运行到 Web、iOS、Android(基于 uni-app / taro )、以及各种小程序(微信/支付宝/百度/头条/飞书/QQ/快手/钉钉/淘宝)、快应用等更多支持 canvas API 的平台。
## 官方网站
## [https://www.ucharts.cn](https://www.ucharts.cn)
## 快速体验
一套代码编到多个平台,依次扫描二维码,亲自体验uCharts图表跨平台效果!其他平台请自行编译。
![](https://www.ucharts.cn/images/web/guide/qrcode20220224.png)
![](https://img-blog.csdnimg.cn/7d0115593ff24ac39a224fb7c6ed72a4.png)
## 致开发者
感谢各位开发者`五年`来对秋云及uCharts的支持,uCharts的进步离不开各位开发者的鼓励与贡献。为更好的帮助各位开发者使用图表工具,我们推出了新版官网,增加了在线定制、问答社区、在线配置等一些增值服务,为确保您能更好的应用图表组件,建议您先`仔细阅读官网指南`以及`常见问题`,而不是下载下来`直接使用`。如仍然不能解决,请到`官网社区`或开通会员后加入`专属VIP会员群`提问将会很快得到回答。
## 视频教程
## [uCharts新手入门教程](https://www.bilibili.com/video/BV1qA411Q7se/?share_source=copy_web&vd_source=42a1242f9aaade6427736af69eb2e1d9)
## 社群支持
uCharts官方拥有5个2000人的QQ群及专属VIP会员群支持,庞大的用户量证明我们一直在努力,请各位放心使用!uCharts的开源图表组件的开发,团队付出了大量的时间与精力,经过四来的考验,不会有比较明显的bug,请各位放心使用。如果您有更好的想法,可以在`码云提交Pull Requests`以帮助更多开发者完成需求,再次感谢各位对uCharts的鼓励与支持!
#### 官方交流群
- 交流群1:371774600(已满)
- 交流群2:619841586(已满)
- 交流群3:955340127(已满)
- 交流群4:641669795(已满)
- 交流群5:236294809(只能扫码加入)
![](https://www.ucharts.cn/images/web/qq5.jpg)
- 口令`uniapp`
#### 专属VIP会员群
- 开通会员后详见【账号详情】页面中顶部的滚动通知
- 口令`您的用户ID`
## 版权信息
uCharts始终坚持开源,遵循 [Apache Licence 2.0](https://www.apache.org/licenses/LICENSE-2.0.html) 开源协议,意味着您无需支付任何费用,即可将uCharts应用到您的产品中。
注意:这并不意味着您可以将uCharts应用到非法的领域,比如涉及赌博,暴力等方面。如因此产生纠纷或法律问题,uCharts相关方及秋云科技不承担任何责任。
## 合作伙伴
[![DIY官网](https://www.ucharts.cn/images/web/guide/links/diy-gw.png)](https://www.diygw.com/)
[![HasChat](https://www.ucharts.cn/images/web/guide/links/haschat.png)](https://gitee.com/howcode/has-chat)
[![uViewUI](https://www.ucharts.cn/images/web/guide/links/uView.png)](https://www.uviewui.com/)
[![图鸟UI](https://www.ucharts.cn/images/web/guide/links/tuniao.png)](https://ext.dcloud.net.cn/plugin?id=7088)
[![thorui](https://www.ucharts.cn/images/web/guide/links/thorui.png)](https://ext.dcloud.net.cn/publisher?id=202)
[![FirstUI](https://www.ucharts.cn/images/web/guide/links/first.png)](https://www.firstui.cn/)
[![nProUI](https://www.ucharts.cn/images/web/guide/links/nPro.png)](https://ext.dcloud.net.cn/plugin?id=5169)
[![GraceUI](https://www.ucharts.cn/images/web/guide/links/grace.png)](https://www.graceui.com/)
## 更新记录
详见官网指南中说明,[点击此处查看](https://www.ucharts.cn/v2/#/guide/index?id=100)
## 相关链接
- [uCharts官网](https://www.ucharts.cn)
- [DCloud插件市场地址](https://ext.dcloud.net.cn/plugin?id=271)
- [uCharts码云开源托管地址](https://gitee.com/uCharts/uCharts) [![star](https://gitee.com/uCharts/uCharts/badge/star.svg?theme=gvp)](https://gitee.com/uCharts/uCharts/stargazers)
- [uCharts npm开源地址](https://www.ucharts.cn)
- [ECharts官网](https://echarts.apache.org/zh/index.html)
- [ECharts配置手册](https://echarts.apache.org/zh/option.html)
- [图表组件在项目中的应用 ReportPlus数据报表](https://www.ucharts.cn/v2/#/layout/info?id=1)
\ No newline at end of file
MIT License
Copyright (c) 2022 zebra-ui
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
<p align="center">
<img alt="logo" src="https://assets-1256020106.cos.ap-beijing.myqcloud.com/zebra-swiper/logo.png" width="220" style="margin-bottom: 10px;">
</p>
<h1 align="center">ZebraSwiper</h1>
<p align="center">基于uniapp,全面对标swiper,并实现全端兼容。</p>
<p align="center">
🔥 <a href="https://swiper.zebraui.com/">文档网站</a>
&nbsp;
&nbsp;
🚀 <a href="https://zebraui.com/" target="_blank">zebraUI组件库</a>
</p>
## 介绍
[zebra-swiper](https://github.com/zebra-ui/zebra-uniapp-swiper) 是基于uniapp开发的一款移动端轮播组件,已实现swiper组件90%的功能。
[uniapp](https://uniapp.dcloud.io/README)[swiper](https://uniapp.dcloud.io/component/swiper)组件存在很大的局限性,无法完成一些复杂的轮播效果。
而zebra-swiper不仅可以实现一些3D轮播效果,还可以通过参数来定义你想要的效果。
## 特性
- 全面对标swiper,并实现全端兼容
- 兼容多端,小程序也可以实现3D轮播效果
- 可自定义3D效果
- 多种示例,总有一种适合你
## 安装
### npm方式
```bash
npm i @zebra-ui/swiper
```
```js
// pages.json
{
"easycom": {
"^z-(.*)": "@zebra-ui/swiper/components/z-$1/z-$1.vue"
},
"pages": [...],
"globalStyle": {...}
}
```
### uni_modules方式
[插件市场](https://ext.dcloud.net.cn/plugin?id=7273)直接导入即可
## 手机预览
<div>
<img alt="wx" src="https://assets-1256020106.cos.ap-beijing.myqcloud.com/zebra-swiper/wx.jpg" width="200" />
<img alt="ali" src="https://assets-1256020106.cos.ap-beijing.myqcloud.com/zebra-swiper/ali.jpg" width="200" />
<img alt="h5" src="https://assets-1256020106.cos.ap-beijing.myqcloud.com/zebra-swiper/h5.png" width="200" />
</div>
## 预览
<div style="display:flex;flex-wrap:wrap;margin-top:30px;">
<img alt="gif" src="https://assets-1256020106.cos.ap-beijing.myqcloud.com/zebra-swiper/gif/gif1.gif" width="300" style="margin:20px;" />
<img alt="gif" src="https://assets-1256020106.cos.ap-beijing.myqcloud.com/zebra-swiper/gif/gif2.gif" width="300" style="margin:20px;" />
<img alt="gif" src="https://assets-1256020106.cos.ap-beijing.myqcloud.com/zebra-swiper/gif/gif3.gif" width="300" style="margin:20px;" />
<img alt="gif" src="https://assets-1256020106.cos.ap-beijing.myqcloud.com/zebra-swiper/gif/gif4.gif" width="300" style="margin:20px;" />
<img alt="gif" src="https://assets-1256020106.cos.ap-beijing.myqcloud.com/zebra-swiper/gif/gif5.gif" width="300" style="margin:20px;" />
<img alt="gif" src="https://assets-1256020106.cos.ap-beijing.myqcloud.com/zebra-swiper/gif/gif6.gif" width="300" style="margin:20px;" />
</div>
## 群
QQ群:947159437
![image](https://assets-1256020106.cos.ap-beijing.myqcloud.com/zebra-swiper/zebra-swiper-group-code.png)
\ No newline at end of file
## 2.2.6(2023-02-20)
`2023-02-20`
**Feat**
- `panorama`全景切换效果新增`stretch`参数,用于控制slide之间的距离。
**Fix**
- 修复字节小程序3D样式失效的问题。
- 修复`panorama`切换效果参数无效的问题。
- 修复`autoHeight`高度自适应使用报错的问题。(`autoHeight`选项可以正常使用,且在大多数场景下可以正确获取高度)
## 2.2.5(2022-11-10)
`2022-11-10`
**Feat**
- `cards`卡片切换效果新增`perSlideRotate``perSlideOffset`参数用于控制卡片的偏移距离及旋转角度。
- 微信小程序中默认使用虚拟节点渲染,即`virtualHost`: `true`
**Fix**
- 修复`pagination`选项开启后,动态控制`swiper`禁用或启用报错的问题。
- 修复支付宝小程序3D样式失效的问题。
## 2.2.4(2022-09-23)
`2022-09-23`
**Feat**
- 新增`noSwiping`参数控制是否禁止触摸。当禁止触摸开启时,不可通过滑动切换。可通过自动切换,`slideTo`等方法切换。
**Fix**
- 修复`vue3``app`触摸无效的问题。
- 新增触摸事件`touchcancel`
## 2.2.3(2022-07-26)
`2022-07-26`
**Feat**
- 卡片切换效果`cards`新增`rotate`参数,用于控制卡片切换时是否发生旋转。
**Fix**
- 修复微信小程序使用`zebra-swiper`时,页面无法滚动。
- 修复`app`报错`toJSON`的问题。
- 修复`swiper``vue3`中无法自动播放的问题。
## 2.2.2(2022-07-01)
`2022-07-01`
**Feat**
- 兼容`PC`浏览器端。
- 初步兼容`VUE3`
**Fix**
- 修复使用`zebra-swiper`时,页面无法滚动。(`zebra-swiper`将不再默认阻止事件冒泡)。
## 2.2.1(2022-03-31)
`2022-03-31`
**Feat**
- 新增`changeDirection`方法,该方法用于动态改变swiper方向。
- `z-swiper-item`新增`swiperItemWidth` `swiperItemHeight` 属性,用于在swiper无法正确获取宽高的情况下设置swiper的宽高(如快手小程序)。
**Fix**
- 消除快手小程序itemPropWxs的警告。
## 2.2.0(2022-03-21)
`2022-03-21`
**本次更新调整了组件的整体架构及组件入口逻辑。主要为性能优化,不涉及新功能。**
不兼容性更新:
- `z-swiper``customStyle` 由字符串类型更改为Object类型(与`z-swiper-item`保持一致)。
- `z-swiper-item` 删除了加载的效果。
**Fix**
- 修复因数据改变而无法正确触发更新的问题。
- 修复方法 `disable` `enable` 提示未定义的问题。
**Perf**
- 组件首次渲染速度优化。
- loop模式处理数据后才开始加载swiper,确保数据的一致性。
- 部分同步方法更改为异步,体验更流畅。
## 2.1.4(2022-03-05)
`2022-03-05`
**Feat**
- 高级案例加入开屏页。[点击预览](https://swiper.zebraui.com/h5/pages/demos/paper/index)
**Fix**
- 修复百度小程序高度计算错误的问题。
## 2.1.3(2022-03-03)
`2022-03-03`
**Feat**
- 新增高级案例模块。
- 高级案例加入环游地球。[点击预览](https://swiper.zebraui.com/h5/pages/demos/travel-slider/index)
- 微信小程序,qq小程序使用wxs赋值样式。
## 2.1.2(2022-03-02)
`2022-03-02`
本次改版涉及所有开启loop的功能。请更新后删除手动拼接的数据。
**Feat**
- loop无限循环模式无需再手动拼接数据。
## 2.1.1(2022-03-01)
`2022-03-01`
**Fix**
- 修复字节小程序轮播内容不显示的问题。
- 修复字节小程序获取位置信息错误的问题。
**Docs**
- [文档新增事件。](https://swiper.zebraui.com/basic/events/)
## 2.1.0(2022-02-27)
`2022-02-27`
更新须知
使用组件时,需在z-swiper标签上以`v-model`的形式传入list数据,也就是要循环的列表数据,该属性为强制性,不加会导致意外错误。例:
之前的方式:
```vue
<z-swiper>
<z-swiper-item v-for="(item,index) in list" :key="index">
<image class="image" :src="item" mode="aspectFill">
</image>
</z-swiper-item>
</z-swiper>
```
现在的方式:
```vue
<z-swiper v-model="list"> //这里传入的需和下方循环的保持一致
<z-swiper-item v-for="(item,index) in list" :key="index">
<image class="image" :src="item" mode="aspectFill">
</image>
</z-swiper-item>
</z-swiper>
```
这个操作也为swiper接管数据操作铺垫,对后续很多新功能非常有用,也为loop无限循环的痛点提供了解决方案。
**Fix**
- 修复数据为空时报错。
- 修复请求数据时swiper提前初始化的问题。
**Feat**
- 新增滚动条功能。
## 2.0.1(2022-02-25)
`2022-02-25`
**Fix**
- 修复插槽内容class样式不生效问题。
**Feat**
- 新增缩略图功能。
## 2.0.0(2022-02-24)
`2022-02-24`
**Feat**
- 该版本为破坏性改版,无法兼容1.0。
- 代码重构,使用模块化将功能分割,大幅提升性能,方便后续维护。
- 全面对标swiper组件,并实现全端兼容。小程序也可实现炫酷的轮播效果。
- 所有切换效果全部支持loop无限循环。
- 新增全景切换效果。
- 新增轮播块功能,可自定义显示数量。
- 新增进度条指示器。
## 1.0.7(2022-01-25)
`2022-01-25`
**Feat**
- 新增轮播切换器功能,可使用默认切换或自定义切换。
- 示例项目新增切换器的使用及自定义切换器。
## 1.0.6(2022-01-24)
`2022-01-24`
**Chore**
- 示例项目新增指示器的使用及自定义指示器。
## 1.0.5(2022-01-21)
`2022-01-21`
**Docs**
- README.md新增手机预览,包含微信,支付宝小程序码,H5二维码。
## 1.0.4(2022-01-20)
`2022-01-20`
**Style**
- 示例项目首页px统一修改为rpx。
## 1.0.3(2022-01-19)
`2022-01-19`
**Fix**
- 修复轮播设置为纵向时,高度错误的问题。
- 修复在百度小程序中样式错乱的问题。
## 1.0.2(2022-01-18)
`2022-01-18`
**Docs**
- README.md新增gif预览图
- 修复因未知原因引起的uni_modules组件上传错误的问题。
`2022-01-14`
### [v1.0.1](https://github.com/zebra-ui/zebra-uniapp-swiper)
**Feature**
- 新增zebra-swiper,zebra-swiper-item组件。
- 新增多种3D切换效果。包括渐变,方块,3D流,翻转,卡片,创意性等多种切换效果。
- 新增[示例项目](https://swiper.zebraui.com),包含多种切换效果示例。
<template>
<!-- #ifndef MP-WEIXIN || MP-QQ -->
<view :class="['swiper-slide',slideClass]" :style="[itemStyle,customStyle]" @click.stop="onClickSlide">
<!-- #endif -->
<!-- #ifdef MP-WEIXIN || MP-QQ -->
<view :class="['swiper-slide',slideClass]" :style="[itemStyle,customStyle]" @click.stop="onClickSlide"
:swiperItemTransform="wxsItemTransform" :change:swiperItemTransform="zSwiperWxs.wxsItemTransformObserver">
<!-- #endif -->
<slot></slot>
</view>
</template>
<!-- #ifdef MP-WEIXIN || MP-QQ -->
<script src="../../wxs/z-swiper-wxs.wxs" module="zSwiperWxs" lang="wxs"></script>
<!-- #endif -->
<script>
import {
ChildrenMixin
} from '../../libs/mixins/relation.js';
import {
getRect
} from '../../libs/utils/utils.js';
export default {
name: "z-swipe-item",
// #ifdef MP-WEIXIN
options: {
virtualHost: true
},
// #endif
mixins: [ChildrenMixin('zSwipe')],
props: {
customStyle: {
type: Object,
default: () => {
return {};
}
},
swiperItemWidth: {
type: [String, Number],
default: 0
},
swiperItemHeight: {
type: [String, Number],
default: 0
},
},
data() {
return {
wxsItemTransform: "",
itemStyle: {},
offsetLeft: 0,
offsetTop: 0,
itemClass: [],
width: 0,
height: 0,
};
},
mounted() {
this.getSize();
},
computed: {
slideClass() {
return this.itemClass.join(" ");
}
},
watch: {
swiperItemWidth: {
handler(val) {
if (val) {
this.$set(this.itemStyle, 'width', this.unitFormat(val, "rpx"))
}
},
immediate: true
},
swiperItemHeight: {
handler(val) {
if (val) {
this.$set(this.itemStyle, 'height', this.unitFormat(val, "rpx"))
}
},
immediate: true
}
},
methods: {
unitFormat(val, type) {
if (type == "rpx") {
if (val.includes("rpx") || val.includes("px")) {
return val;
} else {
return val + 'px';
}
}
if (type == "number") {
if (val.includes("rpx")) {
return uni.upx2px(parseInt(val.replace("rpx", "")))
} else if (!val.includes("rpx") && val.includes("px")) {
return parseInt(val.replace("px", ""))
} else {
return val;
}
}
},
onClickSlide(event) {
this.$emit("click", {
event,
index: this.index
});
this.parent.swiper.updateClickedSlide(this.index);
this.parent.swiper.emit("slideClick", this.index);
},
transform(value) {
// #ifndef MP-WEIXIN || MP-QQ
this.$set(this.itemStyle, 'transform', value)
// #endif
// #ifdef MP-WEIXIN || MP-QQ
this.wxsItemTransform = value
// #endif
},
transition(value) {
// #ifdef MP-BAIDU
this.$set(this.itemStyle, 'transitionDuration', `${value}ms`)
// #endif
// #ifndef MP-BAIDU
this.$set(this.itemStyle, 'transition-duration', `${value}ms`)
// #endif
},
willChange(value) {
this.$set(this.itemStyle, 'will-change', value)
},
css(value) {
Object.keys(value).forEach((item) => {
this.$set(this.itemStyle, item, value[item])
})
},
transitionEnd(callback, duration) {
setTimeout(callback, duration)
},
getSize() {
const query = uni.createSelectorQuery().in(this);
return new Promise((resolve, reject) => {
query.select('.swiper-slide').boundingClientRect(data => {
if (this.swiperItemWidth) {
this.width = this.unitFormat(this.swiperItemWidth, "number");
this.height = data.height;
}
if (this.swiperItemHeight) {
this.width = data.width;
this.height = this.unitFormat(this.swiperItemHeight, "number");
}
if (!this.swiperItemWidth && !this.swiperItemHeight) {
this.width = data.width;
this.height = data.height;
}
resolve({
width: this.width,
height: this.height
})
}).exec();
})
},
addClass(value) {
this.itemClass = Array.from(new Set([...this.itemClass, ...value.split(" ")]));
},
removeClass(value) {
this.itemClass = this.itemClass.filter(item => !value.split(" ").includes(item));
},
hasClass(value) {
return this.itemClass.includes(value);
},
nextAll() {
return this.parent.children.filter((item) => {
return item.index > this.index
})
},
prevAll() {
return this.parent.children.filter((item) => {
return item.index < this.index
}).reverse()
},
}
}
</script>
<style scoped lang="scss">
@import '../../libs/core.scss';
</style>
<!-- uni_modules发布插件时,components中必须有一个和父级名称一致的组件,否则提示指定目录不存在,这样做的具体原因未知。故此文件为无用文件,仅做为上传插件时消除错误使用。 -->
<template>
</template>
<script>
</script>
<style>
</style>
import Swiper from "./libs/core.js";
import Autoplay from './modules/autoplay/autoplay.js';
import FreeMode from './modules/free-mode/free-mode.js';
import EffectFade from './modules/effect-fade/effect-fade.js';
import EffectCube from './modules/effect-cube/effect-cube.js';
import EffectCoverflow from './modules/effect-coverflow/effect-coverflow.js';
import EffectFlip from './modules/effect-flip/effect-flip.js';
import EffectCards from './modules/effect-cards/effect-cards.js';
import EffectCreative from './modules/effect-creative/effect-creative.js';
import EffectPanorama from './modules/effect-panorama/effect-panorama.js';
import EffectCarousel from './modules/effect-carousel/effect-carousel.js';
import Navigation from './modules/navigation/navigation.js';
import Pagination from './modules/pagination/pagination.js';
import Thumbs from './modules/thumbs/thumbs.js';
import Scrollbar from './modules/scrollbar/scrollbar.js';
import Virtual from './modules/virtual/virtual.js';
import WillChange from './modules/will-change/will-change.js';
export {
default as Swiper,
default
}
from './libs/core.js';
const modules = [Autoplay, FreeMode, EffectFade, EffectCube, EffectCoverflow, EffectFlip, EffectCards, EffectCreative,
EffectPanorama, EffectCarousel, Navigation, Pagination, Thumbs, Scrollbar, WillChange, Virtual
];
Swiper.use(modules);
function checkOverflow() {
const swiper = this;
const {
isLocked: wasLocked,
params
} = swiper;
const {
slidesOffsetBefore
} = params;
if (slidesOffsetBefore) {
const lastSlideIndex = swiper.slides.length - 1;
const lastSlideRightEdge = swiper.slidesGrid[lastSlideIndex] + swiper.slidesSizesGrid[lastSlideIndex] +
slidesOffsetBefore * 2;
swiper.isLocked = swiper.size > lastSlideRightEdge;
} else {
swiper.isLocked = swiper.snapGrid.length === 1;
}
if (params.allowSlideNext === true) {
swiper.allowSlideNext = !swiper.isLocked;
}
if (params.allowSlidePrev === true) {
swiper.allowSlidePrev = !swiper.isLocked;
}
if (wasLocked && wasLocked !== swiper.isLocked) {
swiper.isEnd = false;
}
if (wasLocked !== swiper.isLocked) {
swiper.emit(swiper.isLocked ? 'lock' : 'unlock');
}
}
export default {
checkOverflow
};
function prepareClasses(entries, prefix) {
const resultClasses = [];
entries.forEach(item => {
if (typeof item === 'object') {
Object.keys(item).forEach(classNames => {
if (item[classNames]) {
resultClasses.push(prefix + classNames);
}
});
} else if (typeof item === 'string') {
resultClasses.push(prefix + item);
}
});
return resultClasses;
}
export default function addClasses() {
const swiper = this;
const {
classNames,
params,
rtl,
$el,
device,
support
} = swiper; // prettier-ignore
const suffixes = prepareClasses(['initialized', params.direction, {
'pointer-events': !support.touch
}, {
'free-mode': swiper.params.freeMode && params.freeMode.enabled
}, {
'autoheight': params.autoHeight
}, {
'rtl': rtl
}, {
'grid': params.grid && params.grid.rows > 1
}, {
'grid-column': params.grid && params.grid.rows > 1 && params.grid.fill === 'column'
}, {
'android': device.android
}, {
'ios': device.ios
}, {
'css-mode': params.cssMode
}, {
'centered': params.cssMode && params.centeredSlides
}], params.containerModifierClass);
classNames.push(...suffixes);
$el.addClass([...classNames].join(' '));
swiper.emitContainerClasses();
}
\ No newline at end of file
import addClasses from './addClasses.js';
import removeClasses from './removeClasses.js';
export default {
addClasses,
removeClasses
};
\ No newline at end of file
export default function removeClasses() {
const swiper = this;
const {
$el,
classNames
} = swiper;
$el.removeClass(classNames.join(' '));
swiper.emitContainerClasses();
}
\ No newline at end of file
$themeColor: #007aff !default;
:root {
--swiper-theme-color: #{$themeColor};
}
.swiper {
margin-left: auto;
margin-right: auto;
position: relative;
overflow: hidden;
list-style: none;
padding: 0;
/* Fix of Webkit flickering */
z-index: 1;
}
.swiper-vertical > .swiper-wrapper {
flex-direction: column;
}
.swiper-wrapper {
position: relative;
width: 100%;
height: 100%;
z-index: 1;
display: flex;
transition-property: transform;
box-sizing: content-box;
}
.swiper-android .swiper-slide,
.swiper-wrapper {
transform: translate3d(0px, 0, 0);
}
.swiper-pointer-events {
touch-action: pan-y;
&.swiper-vertical {
touch-action: pan-x;
}
}
.swiper-slide {
flex-shrink: 0;
width: 100%;
height: 100%;
position: relative;
transition-property: transform;
}
.swiper-slide-invisible-blank {
visibility: hidden;
}
/* Auto Height */
.swiper-autoheight {
&,
.swiper-slide {
height: auto;
}
.swiper-wrapper {
align-items: flex-start;
transition-property: transform, height;
}
}
.swiper-slide-3d{
transform-style: preserve-3d;
}
/* 3D Effects */
.swiper-3d {
&,
&.swiper-css-mode .swiper-wrapper {
perspective: 1200px;
}
.swiper-wrapper,
.swiper-slide,
.swiper-slide-shadow,
.swiper-slide-shadow-left,
.swiper-slide-shadow-right,
.swiper-slide-shadow-top,
.swiper-slide-shadow-bottom,
.swiper-cube-shadow {
transform-style: preserve-3d;
}
.swiper-slide-shadow,
.swiper-slide-shadow-left,
.swiper-slide-shadow-right,
.swiper-slide-shadow-top,
.swiper-slide-shadow-bottom {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
pointer-events: none;
z-index: 10;
}
.swiper-slide-shadow {
background: rgba(0, 0, 0, 0.15);
}
.swiper-slide-shadow-left {
background-image: linear-gradient(to left, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0));
}
.swiper-slide-shadow-right {
background-image: linear-gradient(to right, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0));
}
.swiper-slide-shadow-top {
background-image: linear-gradient(to top, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0));
}
.swiper-slide-shadow-bottom {
background-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0));
}
}
/* CSS Mode */
.swiper-css-mode {
> .swiper-wrapper {
overflow: auto;
scrollbar-width: none; /* For Firefox */
-ms-overflow-style: none; /* For Internet Explorer and Edge */
&::-webkit-scrollbar {
display: none;
}
}
> .swiper-wrapper > .swiper-slide {
scroll-snap-align: start start;
}
}
.swiper-horizontal.swiper-css-mode {
> .swiper-wrapper {
scroll-snap-type: x mandatory;
}
}
.swiper-vertical.swiper-css-mode {
> .swiper-wrapper {
scroll-snap-type: y mandatory;
}
}
.swiper-centered {
> .swiper-wrapper::before {
content: '';
flex-shrink: 0;
order: 9999;
}
&.swiper-horizontal {
> .swiper-wrapper > .swiper-slide:first-child {
margin-inline-start: var(--swiper-centered-offset-before);
}
> .swiper-wrapper::before {
height: 100%;
width: var(--swiper-centered-offset-after);
}
}
&.swiper-vertical {
> .swiper-wrapper > .swiper-slide:first-child {
margin-block-start: var(--swiper-centered-offset-before);
}
> .swiper-wrapper::before {
width: 100%;
height: var(--swiper-centered-offset-after);
}
}
> .swiper-wrapper > .swiper-slide {
scroll-snap-align: center center;
}
}
@import "../modules/effect-fade/effect-fade.scss";
@import "../modules/effect-cube/effect-cube.scss";
@import "../modules/effect-coverflow/effect-coverflow.scss";
@import "../modules/effect-flip/effect-flip.scss";
@import "../modules/effect-cards/effect-cards.scss";
@import "../modules/effect-creative/effect-creative.scss";
@import "../modules/effect-panorama/effect-panorama.scss";
@import "../modules/effect-carousel/effect-carousel.scss";
@import "../modules/navigation/navigation.scss";
@import "../modules/pagination/pagination.scss";
@import "../modules/thumbs/thumbs.scss";
@import "../modules/scrollbar/scrollbar.scss";
\ No newline at end of file
export default {
init: true,
direction: 'horizontal',
touchEventsTarget: 'wrapper',
initialSlide: 0,
speed: 300,
cssMode: false,
updateOnWindowResize: true,
resizeObserver: true,
nested: false,
createElements: false,
enabled: true,
focusableElements: 'input, select, option, textarea, button, video, label',
// Overrides
width: null,
height: null,
//
preventInteractionOnTransition: false,
// ssr
userAgent: null,
url: null,
// To support iOS's swipe-to-go-back gesture (when being used in-app).
edgeSwipeDetection: false,
edgeSwipeThreshold: 20,
// Autoheight
autoHeight: false,
// Set wrapper width
setWrapperSize: false,
// Virtual Translate
virtualTranslate: false,
virtualList: [],
virtualIndexList: [],
// Effects
effect: 'slide',
// 'slide' or 'fade' or 'cube' or 'coverflow' or 'flip'
// Breakpoints
breakpoints: undefined,
breakpointsBase: 'window',
// Slides grid
spaceBetween: 0,
slidesPerView: 1,
slidesPerGroup: 1,
slidesPerGroupSkip: 0,
slidesPerGroupAuto: false,
centeredSlides: false,
centeredSlidesBounds: false,
slidesOffsetBefore: 0,
// in px
slidesOffsetAfter: 0,
// in px
normalizeSlideIndex: true,
centerInsufficientSlides: false,
// Disable swiper and hide navigation when container not overflow
watchOverflow: true,
// Round length
roundLengths: false,
// Touches
touchRatio: 1,
touchAngle: 45,
simulateTouch: true,
shortSwipes: true,
longSwipes: true,
longSwipesRatio: 0.5,
longSwipesMs: 300,
followFinger: true,
allowTouchMove: true,
threshold: 0,
touchMoveStopPropagation: false,
touchStartPreventDefault: true,
touchStartForcePreventDefault: false,
touchReleaseOnEdges: false,
// Unique Navigation Elements
uniqueNavElements: true,
// Resistance
resistance: true,
resistanceRatio: 0.85,
// Progress
watchSlidesProgress: false,
// Cursor
grabCursor: false,
// Clicks
preventClicks: true,
preventClicksPropagation: true,
slideToClickedSlide: false,
// Images
preloadImages: true,
updateOnImagesReady: true,
// loop
loop: false,
loopAdditionalSlides: 0,
loopedSlides: null,
loopFillGroupWithBlank: false,
loopPreventsSlide: true,
// rewind
rewind: false,
// Swiping/no swiping
allowSlidePrev: true,
allowSlideNext: true,
swipeHandler: null,
// '.swipe-handler',
noSwiping: false,
noSwipingClass: 'swiper-no-swiping',
noSwipingSelector: null,
// Passive Listeners
passiveListeners: true,
// NS
containerModifierClass: 'swiper-',
// NEW
slideClass: 'swiper-slide',
slideBlankClass: 'swiper-slide-invisible-blank',
slideActiveClass: 'swiper-slide-active',
slideDuplicateActiveClass: 'swiper-slide-duplicate-active',
slideVisibleClass: 'swiper-slide-visible',
slideDuplicateClass: 'swiper-slide-duplicate',
slideNextClass: 'swiper-slide-next',
slideDuplicateNextClass: 'swiper-slide-duplicate-next',
slidePrevClass: 'swiper-slide-prev',
slideDuplicatePrevClass: 'swiper-slide-duplicate-prev',
wrapperClass: 'swiper-wrapper',
slideThumbsClass: 'swiper-slide-thumb',
// Callbacks
runCallbacksOnInit: true,
// Internals
_emitClasses: false,
willChange: false
};
/* eslint-disable no-underscore-dangle */
export default {
on(events, handler, priority) {
const self = this;
if (typeof handler !== 'function') return self;
const method = priority ? 'unshift' : 'push';
events.split(' ').forEach(event => {
if (!self.eventsListeners[event]) self.eventsListeners[event] = [];
self.eventsListeners[event][method](handler);
});
return self;
},
once(events, handler, priority) {
const self = this;
if (typeof handler !== 'function') return self;
function onceHandler(...args) {
self.off(events, onceHandler);
if (onceHandler.__emitterProxy) {
delete onceHandler.__emitterProxy;
}
handler.apply(self, args);
}
onceHandler.__emitterProxy = handler;
return self.on(events, onceHandler, priority);
},
onAny(handler, priority) {
const self = this;
if (typeof handler !== 'function') return self;
const method = priority ? 'unshift' : 'push';
if (self.eventsAnyListeners.indexOf(handler) < 0) {
self.eventsAnyListeners[method](handler);
}
return self;
},
offAny(handler) {
const self = this;
if (!self.eventsAnyListeners) return self;
const index = self.eventsAnyListeners.indexOf(handler);
if (index >= 0) {
self.eventsAnyListeners.splice(index, 1);
}
return self;
},
off(events, handler) {
const self = this;
if (!self.eventsListeners) return self;
events.split(' ').forEach(event => {
// self.native.off(event, handler);
if (typeof handler === 'undefined') {
self.eventsListeners[event] = [];
} else if (self.eventsListeners[event]) {
self.eventsListeners[event].forEach((eventHandler, index) => {
if (eventHandler === handler || eventHandler.__emitterProxy && eventHandler
.__emitterProxy === handler) {
self.eventsListeners[event].splice(index, 1);
}
});
}
});
return self;
},
emit(...args) {
const self = this;
if (!self.eventsListeners) return self;
let events;
let data;
let context;
if (typeof args[0] === 'string' || Array.isArray(args[0])) {
events = args[0];
data = args.slice(1, args.length);
context = self;
} else {
events = args[0].events;
data = args[0].data;
context = args[0].context || self;
}
data.unshift(context);
const eventsArray = Array.isArray(events) ? events : events.split(' ');
eventsArray.forEach(event => {
// console.log(event)
if (self.eventsAnyListeners && self.eventsAnyListeners.length) {
self.eventsAnyListeners.forEach(eventHandler => {
eventHandler.apply(context, [event, ...data]);
});
}
if (self.eventsListeners && self.eventsListeners[event]) {
self.eventsListeners[event].forEach(eventHandler => {
eventHandler.apply(context, data);
});
}
});
return self;
}
};
import onTouchStart from './onTouchStart.js';
import onTouchMove from './onTouchMove.js';
import onTouchEnd from './onTouchEnd.js';
import onResize from './onResize.js';
import onClick from './onClick.js';
import onScroll from './onScroll.js';
let dummyEventAttached = false;
function dummyEventListener() {}
const events = (swiper, method) => {
const {
params,
touchEvents,
wrapperEl,
device,
support
} = swiper;
let el = swiper.native;
const capture = !!params.nested;
const domMethod = method === 'on' ? 'on' : 'off';
const swiperMethod = method;
if (!support.touch) {
let desktopMethod = method === 'on' ? 'addEventListener' : 'removeEventListener';
if (document.querySelector(`#${swiper.$el.swiperElId}`)) {
document.querySelector(`#${swiper.$el.swiperElId}`)[desktopMethod](touchEvents.start, swiper
.onTouchStart,
false);
}
document[desktopMethod](touchEvents.move, swiper.onTouchMove, capture);
document[desktopMethod](touchEvents.end, swiper.onTouchEnd, false);
} else {
const passiveListener = touchEvents.start === 'touchstart' && support.passiveListener && params
.passiveListeners ? {
passive: true,
capture: false
} : false;
}
};
function attachEvents() {
const swiper = this;
const {
params,
support
} = swiper;
swiper.onTouchStart = onTouchStart.bind(swiper);
swiper.onTouchMove = onTouchMove.bind(swiper);
swiper.onTouchEnd = onTouchEnd.bind(swiper);
if (params.cssMode) {
swiper.onScroll = onScroll.bind(swiper);
}
swiper.onClick = onClick.bind(swiper);
events(swiper, 'on');
}
function detachEvents() {
const swiper = this;
events(swiper, 'off');
}
export default {
attachEvents,
detachEvents
};
export default function onClick(e) {
const swiper = this;
if (!swiper.enabled) return;
if (!swiper.allowClick) {
if (swiper.params.preventClicks) e.preventDefault();
if (swiper.params.preventClicksPropagation && swiper.animating) {
e.stopPropagation();
e.stopImmediatePropagation();
}
}
}
\ No newline at end of file
export default function onResize() {
const swiper = this;
const {
params,
el
} = swiper;
if (el && el.offsetWidth === 0) return;
if (params.breakpoints) {
swiper.setBreakpoint();
}
const {
allowSlideNext,
allowSlidePrev,
snapGrid
} = swiper;
swiper.allowSlideNext = true;
swiper.allowSlidePrev = true;
swiper.updateSize();
swiper.updateSlides();
swiper.updateSlidesClasses();
if ((params.slidesPerView === 'auto' || params.slidesPerView > 1) && swiper.isEnd && !swiper.isBeginning && !swiper.params.centeredSlides) {
swiper.slideTo(swiper.slides.length - 1, 0, false, true);
} else {
swiper.slideTo(swiper.activeIndex, 0, false, true);
}
if (swiper.autoplay && swiper.autoplay.running && swiper.autoplay.paused) {
swiper.autoplay.run();
}
swiper.allowSlidePrev = allowSlidePrev;
swiper.allowSlideNext = allowSlideNext;
if (swiper.params.watchOverflow && snapGrid !== swiper.snapGrid) {
swiper.checkOverflow();
}
}
\ No newline at end of file
export default function onScroll() {
const swiper = this;
const {
wrapperEl,
rtlTranslate,
enabled
} = swiper;
if (!enabled) return;
swiper.previousTranslate = swiper.translate;
if (swiper.isHorizontal()) {
swiper.translate = -wrapperEl.scrollLeft;
} else {
swiper.translate = -wrapperEl.scrollTop;
} // eslint-disable-next-line
if (swiper.translate === -0) swiper.translate = 0;
swiper.updateActiveIndex();
swiper.updateSlidesClasses();
let newProgress;
const translatesDiff = swiper.maxTranslate() - swiper.minTranslate();
if (translatesDiff === 0) {
newProgress = 0;
} else {
newProgress = (swiper.translate - swiper.minTranslate()) / translatesDiff;
}
if (newProgress !== swiper.progress) {
swiper.updateProgress(rtlTranslate ? -swiper.translate : swiper.translate);
}
swiper.emit('setTranslate', swiper.translate, false);
}
\ No newline at end of file
import {
now,
nextTick
} from '../../shared/utils.js';
export default function onTouchEnd(event) {
const swiper = this;
const data = swiper.touchEventsData;
const {
params,
touches,
rtlTranslate: rtl,
slidesGrid,
enabled
} = swiper;
if (!enabled) return;
let e = event;
if (e.originalEvent) e = e.originalEvent;
if (data.allowTouchCallbacks) {
swiper.emit('touch-end', e);
}
data.allowTouchCallbacks = false;
if (!data.isTouched) {
if (data.isMoved && params.grabCursor) {
swiper.setGrabCursor(false);
}
data.isMoved = false;
data.startMoving = false;
return;
}
if (params.grabCursor && data.isMoved && data.isTouched && (swiper.allowSlideNext === true || swiper
.allowSlidePrev === true)) {
swiper.setGrabCursor(false);
}
const touchEndTime = now();
const timeDiff = touchEndTime - data.touchStartTime; // Tap, doubleTap, Click
if (swiper.allowClick) {
const pathTree = e.path || e.composedPath && e.composedPath();
// swiper.updateClickedSlide(pathTree && pathTree[0] || e.target);
swiper.emit('tap click', e);
if (timeDiff < 300 && touchEndTime - data.lastClickTime < 300) {
swiper.emit('doubleTap doubleClick', e);
}
}
data.lastClickTime = now();
nextTick(() => {
if (!swiper.destroyed) swiper.allowClick = true;
});
if (!data.isTouched || !data.isMoved || !swiper.swipeDirection || touches.diff === 0 || data.currentTranslate ===
data.startTranslate) {
data.isTouched = false;
data.isMoved = false;
data.startMoving = false;
return;
}
data.isTouched = false;
data.isMoved = false;
data.startMoving = false;
let currentPos;
if (params.followFinger) {
currentPos = rtl ? swiper.translate : -swiper.translate;
} else {
currentPos = -data.currentTranslate;
}
if (params.cssMode) {
return;
}
if (swiper.params.freeMode && params.freeMode.enabled) {
swiper.freeMode.onTouchEnd({
currentPos
});
return;
}
let stopIndex = 0;
let groupSize = swiper.slidesSizesGrid[0];
for (let i = 0; i < slidesGrid.length; i += i < params.slidesPerGroupSkip ? 1 : params.slidesPerGroup) {
const increment = i < params.slidesPerGroupSkip - 1 ? 1 : params.slidesPerGroup;
if (typeof slidesGrid[i + increment] !== 'undefined') {
if (currentPos >= slidesGrid[i] && currentPos < slidesGrid[i + increment]) {
stopIndex = i;
groupSize = slidesGrid[i + increment] - slidesGrid[i];
}
} else if (currentPos >= slidesGrid[i]) {
stopIndex = i;
groupSize = slidesGrid[slidesGrid.length - 1] - slidesGrid[slidesGrid.length - 2];
}
}
const ratio = (currentPos - slidesGrid[stopIndex]) / groupSize;
const increment = stopIndex < params.slidesPerGroupSkip - 1 ? 1 : params.slidesPerGroup;
if (timeDiff > params.longSwipesMs) {
if (!params.longSwipes) {
swiper.slideTo(swiper.activeIndex);
return;
}
if (swiper.swipeDirection === 'next') {
if (ratio >= params.longSwipesRatio) swiper.slideTo(stopIndex + increment);
else swiper.slideTo(stopIndex);
}
if (swiper.swipeDirection === 'prev') {
if (ratio > 1 - params.longSwipesRatio) swiper.slideTo(stopIndex + increment);
else swiper.slideTo(stopIndex);
}
} else {
if (!params.shortSwipes) {
swiper.slideTo(swiper.activeIndex);
return;
}
const isNavButtonTarget = swiper.navigation && (e.target === swiper.navigation.nextEl || e.target === swiper
.navigation.prevEl);
if (!isNavButtonTarget) {
if (swiper.swipeDirection === 'next') {
swiper.slideTo(stopIndex + increment);
}
if (swiper.swipeDirection === 'prev') {
swiper.slideTo(stopIndex);
}
} else if (e.target === swiper.navigation.nextEl) {
swiper.slideTo(stopIndex + increment);
} else {
swiper.slideTo(stopIndex);
}
}
}
import {
now
} from '../../shared/utils.js';
export default function onTouchMove(event) {
const swiper = this;
const data = swiper.touchEventsData;
const {
params,
touches,
rtlTranslate: rtl,
enabled
} = swiper;
if (!enabled) return;
let e = event;
if (e.originalEvent) e = e.originalEvent;
if (!data.isTouched) {
if (data.startMoving && data.isScrolling) {
swiper.emit('touchMoveOpposite', e);
}
return;
}
if (data.isTouchEvent && e.type !== 'touchmove' && e.type !== 'touchMove' && e.type !== 'onTouchmove') return;
const targetTouch = (e.type === 'touchmove' || e.type === 'touchMove' || e.type === 'onTouchmove') && e.touches && (
e.touches[0] || e
.changedTouches[0]);
const pageX = (e.type === 'touchmove' || e.type === 'touchMove' || e.type === 'onTouchmove') ? targetTouch.pageX : e
.pageX;
const pageY = (e.type === 'touchmove' || e.type === 'touchMove' || e.type === 'onTouchmove') ? targetTouch.pageY : e
.pageY;
if (e.preventedByNestedSwiper) {
touches.startX = pageX;
touches.startY = pageY;
return;
}
if (!swiper.allowTouchMove) {
swiper.allowClick = false;
if (data.isTouched) {
Object.assign(touches, {
startX: pageX,
startY: pageY,
currentX: pageX,
currentY: pageY
});
data.touchStartTime = now();
}
return;
}
if (data.isTouchEvent && params.touchReleaseOnEdges && !params.loop) {
if (swiper.isVertical()) {
if (pageY < touches.startY && swiper.translate <= swiper.maxTranslate() || pageY > touches.startY && swiper
.translate >= swiper.minTranslate()) {
data.isTouched = false;
data.isMoved = false;
return;
}
} else if (pageX < touches.startX && swiper.translate <= swiper.maxTranslate() || pageX > touches.startX &&
swiper.translate >= swiper.minTranslate()) {
return;
}
}
// if (data.isTouchEvent && document.activeElement) {
// if (e.target === document.activeElement && $(e.target).is(data.focusableElements)) {
// data.isMoved = true;
// swiper.allowClick = false;
// return;
// }
// }
if (data.allowTouchCallbacks) {
swiper.emit('touch-move', e);
}
if (e.touches && e.touches.length > 1) return;
touches.currentX = pageX;
touches.currentY = pageY;
const diffX = touches.currentX - touches.startX;
const diffY = touches.currentY - touches.startY;
if (swiper.params.threshold && Math.sqrt(diffX ** 2 + diffY ** 2) < swiper.params.threshold) return;
if (typeof data.isScrolling === 'undefined') {
let touchAngle;
if (swiper.isHorizontal() && touches.currentY === touches.startY || swiper.isVertical() && touches.currentX ===
touches.startX) {
data.isScrolling = false;
} else {
if (diffX * diffX + diffY * diffY >= 25) {
touchAngle = Math.atan2(Math.abs(diffY), Math.abs(diffX)) * 180 / Math.PI;
data.isScrolling = swiper.isHorizontal() ? touchAngle > params.touchAngle : 90 - touchAngle > params
.touchAngle;
}
}
}
if (data.isScrolling) {
swiper.emit('touchMoveOpposite', e);
}
if (typeof data.startMoving === 'undefined') {
if (touches.currentX !== touches.startX || touches.currentY !== touches.startY) {
data.startMoving = true;
}
}
if (data.isScrolling) {
data.isTouched = false;
return;
}
if (!data.startMoving) {
return;
}
swiper.allowClick = false;
if (!params.cssMode && e.cancelable) {
e.preventDefault();
}
if (params.touchMoveStopPropagation && !params.nested) {
e.stopPropagation();
}
if (!data.isMoved) {
if (params.loop && !params.cssMode) {
swiper.loopFix();
}
data.startTranslate = swiper.getTranslate();
swiper.setTransition(0);
if (swiper.animating) {
swiper.$wrapperEl.emit('transitionend', [swiper]);
}
data.allowMomentumBounce = false;
if (params.grabCursor && (swiper.allowSlideNext === true || swiper.allowSlidePrev === true)) {
swiper.setGrabCursor(true);
}
swiper.emit('sliderFirstMove', e);
}
swiper.emit('sliderMove', e);
data.isMoved = true;
let diff = swiper.isHorizontal() ? diffX : diffY;
touches.diff = diff;
diff *= params.touchRatio;
if (rtl) diff = -diff;
swiper.swipeDirection = diff > 0 ? 'prev' : 'next';
data.currentTranslate = diff + data.startTranslate;
let disableParentSwiper = true;
let resistanceRatio = params.resistanceRatio;
if (params.touchReleaseOnEdges) {
resistanceRatio = 0;
}
if (diff > 0 && data.currentTranslate > swiper.minTranslate()) {
disableParentSwiper = false;
if (params.resistance) data.currentTranslate = swiper.minTranslate() - 1 + (-swiper.minTranslate() + data
.startTranslate + diff) ** resistanceRatio;
} else if (diff < 0 && data.currentTranslate < swiper.maxTranslate()) {
disableParentSwiper = false;
if (params.resistance) data.currentTranslate = swiper.maxTranslate() + 1 - (swiper.maxTranslate() - data
.startTranslate - diff) ** resistanceRatio;
}
if (disableParentSwiper) {
e.preventedByNestedSwiper = true;
}
if (!swiper.allowSlideNext && swiper.swipeDirection === 'next' && data.currentTranslate < data.startTranslate) {
data.currentTranslate = data.startTranslate;
}
if (!swiper.allowSlidePrev && swiper.swipeDirection === 'prev' && data.currentTranslate > data.startTranslate) {
data.currentTranslate = data.startTranslate;
}
if (!swiper.allowSlidePrev && !swiper.allowSlideNext) {
data.currentTranslate = data.startTranslate;
}
if (params.threshold > 0) {
if (Math.abs(diff) > params.threshold || data.allowThresholdMove) {
if (!data.allowThresholdMove) {
data.allowThresholdMove = true;
touches.startX = touches.currentX;
touches.startY = touches.currentY;
data.currentTranslate = data.startTranslate;
touches.diff = swiper.isHorizontal() ? touches.currentX - touches.startX : touches.currentY - touches
.startY;
return;
}
} else {
data.currentTranslate = data.startTranslate;
return;
}
}
if (!params.followFinger || params.cssMode) return;
if (params.freeMode && params.freeMode.enabled && swiper.freeMode || params.watchSlidesProgress) {
swiper.updateActiveIndex();
swiper.updateSlidesClasses();
}
if (swiper.params.freeMode && params.freeMode.enabled && swiper.freeMode) {
swiper.freeMode.onTouchMove();
}
swiper.updateProgress(data.currentTranslate);
swiper.setTranslate(data.currentTranslate);
}
import {
now
} from '../../shared/utils.js';
export default function onTouchStart(event) {
const swiper = this;
const data = swiper.touchEventsData;
const {
params,
touches,
enabled
} = swiper;
if (!enabled) return;
if (swiper.animating && params.preventInteractionOnTransition) {
return;
}
if (!swiper.animating && params.cssMode && params.loop) {
swiper.loopFix();
}
let e = event;
if (e.originalEvent) e = e.originalEvent;
data.isTouchEvent = e.type === 'touchstart' || e.type === 'touchStart' || e.type === 'onTouchstart';
if (!data.isTouchEvent && 'which' in e && e.which === 3) return;
if (!data.isTouchEvent && 'button' in e && e.button > 0) return;
if (data.isTouched && data.isMoved) return; // change target el for shadow root component
const swipingClassHasValue = !!params.noSwipingClass && params.noSwipingClass !== '';
const noSwipingSelector = params.noSwipingSelector ? params.noSwipingSelector : `.${params.noSwipingClass}`;
const isTargetShadow = !!(e.target && e.target
.shadowRoot
);
if (params.noSwiping) {
swiper.allowClick = true;
return;
}
if (params.swipeHandler) {
if (!$targetEl.closest(params.swipeHandler)[0]) return;
}
touches.currentX = (e.type === 'touchstart' || e.type === 'touchStart' || e.type === 'onTouchstart') ? e.touches[0]
.pageX : e.pageX;
touches.currentY = (e.type === 'touchstart' || e.type === 'touchStart' || e.type === 'onTouchstart') ? e.touches[0]
.pageY : e.pageY;
const startX = touches.currentX;
const startY = touches
.currentY;
const edgeSwipeDetection = params.edgeSwipeDetection || params.iOSEdgeSwipeDetection;
const edgeSwipeThreshold = params.edgeSwipeThreshold || params.iOSEdgeSwipeThreshold;
Object.assign(data, {
isTouched: true,
isMoved: false,
allowTouchCallbacks: true,
isScrolling: undefined,
startMoving: undefined
});
touches.startX = startX;
touches.startY = startY;
data.touchStartTime = now();
swiper.allowClick = true;
swiper.updateSize();
swiper.swipeDirection = undefined;
if (params.threshold > 0) data.allowThresholdMove = false;
// if (e.type !== 'touchstart' && e.type !== 'touchStart') {
// let preventDefault = true;
// if ($targetEl.is(data.focusableElements)) preventDefault = false;
// const shouldPreventDefault = preventDefault && swiper.allowTouchMove && params.touchStartPreventDefault;
// if ((params.touchStartForcePreventDefault || shouldPreventDefault) && !$targetEl[0].isContentEditable) {
// e.preventDefault();
// }
// }
swiper.emit('touch-start', e);
}
import setGrabCursor from './setGrabCursor.js';
import unsetGrabCursor from './unsetGrabCursor.js';
export default {
setGrabCursor,
unsetGrabCursor
};
\ No newline at end of file
export default function setGrabCursor(moving) {
const swiper = this;
if (swiper.support.touch || !swiper.params.simulateTouch || swiper.params.watchOverflow && swiper.isLocked || swiper
.params.cssMode) return;
const el = swiper.params.touchEventsTarget === 'container' ? swiper.$el : swiper.$wrapperEl;
el.setCss({
cursor: 'move',
cursor: moving ? '-webkit-grabbing' : '-webkit-grab',
cursor: moving ? '-moz-grabbin' : '-moz-grab',
cursor: moving ? 'grabbing' : 'grab',
})
}
export default function unsetGrabCursor() {
const swiper = this;
if (swiper.support.touch || swiper.params.watchOverflow && swiper.isLocked || swiper.params.cssMode) {
return;
}
swiper[swiper.params.touchEventsTarget === 'container' ? '$el' : '$wrapperEl'].setCss({
cursor: ''
});
}
import loopCreate from './loopCreate.js';
import loopFix from './loopFix.js';
import loopDestroy from './loopDestroy.js';
export default {
loopCreate,
loopFix,
loopDestroy
};
\ No newline at end of file
export default function loopCreate() {
const swiper = this;
const {
params,
$wrapperEl,
native
} = swiper; // Remove duplicated slides
const $selector = $wrapperEl;
let slides = native.children;
if (params.loopFillGroupWithBlank) {
const blankSlidesNum = params.slidesPerGroup - slides.length % params.slidesPerGroup;
if (blankSlidesNum !== params.slidesPerGroup) {
native.loopBlankShow = true;
native.loopBlankNumber = blankSlidesNum;
}
}
if (params.slidesPerView === 'auto' && !params.loopedSlides) params.loopedSlides = slides.length;
swiper.loopedSlides = Math.ceil(parseFloat(params.loopedSlides || params.slidesPerView, 10));
swiper.loopedSlides += params.loopAdditionalSlides;
if (swiper.loopedSlides > slides.length) {
swiper.loopedSlides = slides.length;
}
const prependSlides = [];
const appendSlides = [];
slides.forEach((el, index) => {
const slide = el;
if (index < slides.length && index >= slides.length - swiper.loopedSlides) {
prependSlides.push(el);
}
if (index < swiper.loopedSlides) {
appendSlides.push(el);
}
});
let list = [...swiper.native.value];
let newList = [...list];
swiper.originalDataList = [...swiper.native.value];
for (let i = 0; i < appendSlides.length; i += 1) {
newList.push(list[appendSlides[i].index]);
}
for (let i = prependSlides.length - 1; i >= 0; i -= 1) {
newList.unshift(list[prependSlides[i].index]);
}
swiper.native.$emit("input", newList)
return true;
}
export default function loopDestroy() {
const swiper = this;
const {
$wrapperEl,
params,
slides
} = swiper;
}
export default function loopFix() {
const swiper = this;
swiper.emit('beforeLoopFix');
const {
activeIndex,
slides,
loopedSlides,
allowSlidePrev,
allowSlideNext,
snapGrid,
rtlTranslate: rtl
} = swiper;
let newIndex;
swiper.allowSlidePrev = true;
swiper.allowSlideNext = true;
const snapTranslate = -snapGrid[activeIndex];
const diff = snapTranslate - swiper.getTranslate();
if (activeIndex < loopedSlides) {
newIndex = slides.length - loopedSlides * 3 + activeIndex;
newIndex += loopedSlides;
const slideChanged = swiper.slideTo(newIndex, 0, false, true);
if (slideChanged && diff !== 0) {
swiper.setTranslate((rtl ? -swiper.translate : swiper.translate) - diff);
}
} else if (activeIndex >= slides.length - loopedSlides) {
newIndex = -slides.length + activeIndex + loopedSlides;
newIndex += loopedSlides;
const slideChanged = swiper.slideTo(newIndex, 0, false, true);
if (slideChanged && diff !== 0) {
swiper.setTranslate((rtl ? -swiper.translate : swiper.translate) - diff);
}
}
swiper.allowSlidePrev = allowSlidePrev;
swiper.allowSlideNext = allowSlideNext;
swiper.emit('loopFix');
}
export function ChildrenMixin(parent, options = {}) {
const indexKey = options.indexKey || 'index';
return {
inject: {
[parent]: {
default: null,
},
},
mounted() {
this.parent = this[parent];
this.bindRelation();
},
// #ifdef VUE2
beforeDestroy() {
if (this.parent) {
this.parent.children = this.parent.children.filter(
(item) => item !== this
);
uni.$emit("childrenReady" + this.parent._uid, this);
}
},
// #endif
// #ifdef VUE3
beforeUnmount() {
if (this.parent) {
this.parent.children = this.parent.children.filter(
(item) => item !== this
);
uni.$emit("childrenReady" + this.parent._uid, this);
}
},
// #endif
methods: {
bindRelation() {
if (!this.parent || this.parent.children.indexOf(this) !== -1) {
return;
}
const children = [...this.parent.children, this];
this.parent.children = children;
this.index = this.parent.children.indexOf(this);
uni.$emit("childrenReady" + this.parent._uid, this);
},
},
};
}
export function ParentMixin(parent) {
return {
provide() {
return {
[parent]: this,
};
},
created() {
this.children = [];
},
// #ifdef VUE2
beforeDestroy() {
uni.$off("childrenReady" + this._uid)
},
// #endif
// #ifdef VUE3
beforeUnmount() {
uni.$off("childrenReady" + this._uid)
},
// #endif
};
}
import {
extend
} from '../shared/utils.js';
export default function moduleExtendParams(params, allModulesParams) {
return function extendParams(obj = {}) {
const moduleParamName = Object.keys(obj)[0];
const moduleParams = obj[moduleParamName];
if (typeof moduleParams !== 'object' || moduleParams === null) {
extend(allModulesParams, obj);
return;
}
if (['navigation', 'pagination', 'scrollbar'].indexOf(moduleParamName) >= 0 && params[moduleParamName] ===
true) {
params[moduleParamName] = {
auto: true
};
}
if (!(moduleParamName in params && 'enabled' in moduleParams)) {
extend(allModulesParams, obj);
return;
}
if (params[moduleParamName] === true) {
params[moduleParamName] = {
enabled: true
};
}
if (typeof params[moduleParamName] === 'object' && !('enabled' in params[moduleParamName])) {
params[moduleParamName].enabled = true;
}
if (!params[moduleParamName]) params[moduleParamName] = {
enabled: false
};
extend(allModulesParams, obj);
};
}
import slideTo from './slideTo.js';
import slideToLoop from './slideToLoop.js';
import slideNext from './slideNext.js';
import slidePrev from './slidePrev.js';
import slideReset from './slideReset.js';
import slideToClosest from './slideToClosest.js';
import slideToClickedSlide from './slideToClickedSlide.js';
export default {
slideTo,
slideToLoop,
slideNext,
slidePrev,
slideReset,
slideToClosest,
slideToClickedSlide
};
export default function slideNext(speed = this.params.speed, runCallbacks = true, internal) {
const swiper = this;
const {
animating,
enabled,
params
} = swiper;
if (!enabled) return swiper;
let perGroup = params.slidesPerGroup;
if (params.slidesPerView === 'auto' && params.slidesPerGroup === 1 && params.slidesPerGroupAuto) {
perGroup = Math.max(swiper.slidesPerViewDynamic('current', true), 1);
}
const increment = swiper.activeIndex < params.slidesPerGroupSkip ? 1 : perGroup;
if (params.loop) {
if (animating && params.loopPreventsSlide) return false;
swiper.loopFix();
}
if (params.rewind && swiper.isEnd) {
return swiper.slideTo(0, speed, runCallbacks, internal);
}
setTimeout(() => {
swiper.slideTo(swiper.activeIndex + increment, speed, runCallbacks, internal)
}, 0)
return true;
}
export default function slidePrev(speed = this.params.speed, runCallbacks = true, internal) {
const swiper = this;
const {
params,
animating,
snapGrid,
slidesGrid,
rtlTranslate,
enabled
} = swiper;
if (!enabled) return swiper;
if (params.loop) {
if (animating && params.loopPreventsSlide) return false;
swiper.loopFix();
}
const translate = rtlTranslate ? swiper.translate : -swiper.translate;
function normalize(val) {
if (val < 0) return -Math.floor(Math.abs(val));
return Math.floor(val);
}
const normalizedTranslate = normalize(translate);
const normalizedSnapGrid = snapGrid.map(val => normalize(val));
let prevSnap = snapGrid[normalizedSnapGrid.indexOf(normalizedTranslate) - 1];
if (typeof prevSnap === 'undefined' && params.cssMode) {
let prevSnapIndex;
snapGrid.forEach((snap, snapIndex) => {
if (normalizedTranslate >= snap) {
prevSnapIndex = snapIndex;
}
});
if (typeof prevSnapIndex !== 'undefined') {
prevSnap = snapGrid[prevSnapIndex > 0 ? prevSnapIndex - 1 : prevSnapIndex];
}
}
let prevIndex = 0;
if (typeof prevSnap !== 'undefined') {
prevIndex = slidesGrid.indexOf(prevSnap);
if (prevIndex < 0) prevIndex = swiper.activeIndex - 1;
if (params.slidesPerView === 'auto' && params.slidesPerGroup === 1 && params.slidesPerGroupAuto) {
prevIndex = prevIndex - swiper.slidesPerViewDynamic('previous', true) + 1;
prevIndex = Math.max(prevIndex, 0);
}
}
if (params.rewind && swiper.isBeginning) {
return swiper.slideTo(swiper.slides.length - 1, speed, runCallbacks, internal);
}
setTimeout(() => {
swiper.slideTo(prevIndex, speed, runCallbacks, internal)
}, 30)
return true;
}
export default function slideReset(speed = this.params.speed, runCallbacks = true, internal) {
const swiper = this;
return swiper.slideTo(swiper.activeIndex, speed, runCallbacks, internal);
}
\ No newline at end of file
import {
animateCSSModeScroll
} from '../../shared/utils.js';
export default function slideTo(index = 0, speed = this.params.speed, runCallbacks = true, internal, initial) {
if (typeof index !== 'number' && typeof index !== 'string') {
throw new Error(
`The 'index' argument cannot have type other than 'number' or 'string'. [${typeof index}] given.`);
}
if (typeof index === 'string') {
/**
* The `index` argument converted from `string` to `number`.
* @type {number}
*/
const indexAsNumber = parseInt(index, 10);
/**
* Determines whether the `index` argument is a valid `number`
* after being converted from the `string` type.
* @type {boolean}
*/
const isValidNumber = isFinite(indexAsNumber);
if (!isValidNumber) {
throw new Error(`The passed-in 'index' (string) couldn't be converted to 'number'. [${index}] given.`);
} // Knowing that the converted `index` is a valid number,
// we can update the original argument's value.
index = indexAsNumber;
}
const swiper = this;
let slideIndex = index;
let timer;
if (slideIndex < 0) slideIndex = 0;
const {
params,
snapGrid,
slidesGrid,
previousIndex,
activeIndex,
rtlTranslate: rtl,
wrapperEl,
enabled
} = swiper;
if (swiper.animating && params.preventInteractionOnTransition || !enabled && !internal && !initial) {
return false;
}
const skip = Math.min(swiper.params.slidesPerGroupSkip, slideIndex);
let snapIndex = skip + Math.floor((slideIndex - skip) / swiper.params.slidesPerGroup);
if (snapIndex >= snapGrid.length) snapIndex = snapGrid.length - 1;
if ((activeIndex || params.initialSlide || 0) === (previousIndex || 0) && runCallbacks) {
swiper.emit('beforeSlideChangeStart');
}
const translate = -snapGrid[snapIndex]; // Update progress
swiper.updateProgress(translate); // Normalize slideIndex
if (params.normalizeSlideIndex) {
for (let i = 0; i < slidesGrid.length; i += 1) {
const normalizedTranslate = -Math.floor(translate * 100);
const normalizedGrid = Math.floor(slidesGrid[i] * 100);
const normalizedGridNext = Math.floor(slidesGrid[i + 1] * 100);
if (typeof slidesGrid[i + 1] !== 'undefined') {
if (normalizedTranslate >= normalizedGrid && normalizedTranslate < normalizedGridNext - (
normalizedGridNext - normalizedGrid) / 2) {
slideIndex = i;
} else if (normalizedTranslate >= normalizedGrid && normalizedTranslate < normalizedGridNext) {
slideIndex = i + 1;
}
} else if (normalizedTranslate >= normalizedGrid) {
slideIndex = i;
}
}
} // Directions locks
if (swiper.initialized && slideIndex !== activeIndex) {
if (!swiper.allowSlideNext && translate < swiper.translate && translate < swiper.minTranslate()) {
return false;
}
if (!swiper.allowSlidePrev && translate > swiper.translate && translate > swiper.maxTranslate()) {
if ((activeIndex || 0) !== slideIndex) return false;
}
}
let direction;
if (slideIndex > activeIndex) direction = 'next';
else if (slideIndex < activeIndex) direction = 'prev';
else direction = 'reset'; // Update Index
if (rtl && -translate === swiper.translate || !rtl && translate === swiper.translate) {
swiper.updateActiveIndex(slideIndex); // Update Height
if (params.autoHeight) {
setTimeout(() => {
swiper.updateAutoHeight();
}, 0)
}
swiper.updateSlidesClasses();
if (params.effect !== 'slide') {
swiper.setTranslate(translate);
}
if (direction !== 'reset') {
swiper.transitionStart(runCallbacks, direction);
swiper.transitionEnd(runCallbacks, direction);
}
return false;
}
if (params.cssMode) {
const isH = swiper.isHorizontal();
const t = rtl ? translate : -translate;
if (speed === 0) {
const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
if (isVirtual) {
swiper.wrapperEl.style.scrollSnapType = 'none';
swiper._immediateVirtual = true;
}
wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = t;
if (isVirtual) {
requestAnimationFrame(() => {
swiper.wrapperEl.style.scrollSnapType = '';
swiper._swiperImmediateVirtual = false;
});
}
} else {
if (!swiper.support.smoothScroll) {
animateCSSModeScroll({
swiper,
targetPosition: t,
side: isH ? 'left' : 'top'
});
return true;
}
wrapperEl.scrollTo({
[isH ? 'left' : 'top']: t,
behavior: 'smooth'
});
}
return true;
}
swiper.setTransition(speed);
swiper.setTranslate(translate);
swiper.updateActiveIndex(slideIndex);
swiper.updateSlidesClasses();
swiper.emit('beforeTransitionStart', speed, internal);
swiper.transitionStart(runCallbacks, direction);
if (speed === 0) {
swiper.transitionEnd(runCallbacks, direction);
} else if (!swiper.animating) {
swiper.animating = true;
if (!swiper.onSlideToWrapperTransitionEnd) {
swiper.onSlideToWrapperTransitionEnd = function transitionEnd(e) {
if (!swiper || swiper.destroyed) return;
clearTimeout(timer)
swiper.onSlideToWrapperTransitionEnd = null;
delete swiper.onSlideToWrapperTransitionEnd;
swiper.transitionEnd(runCallbacks, direction);
};
}
timer = setTimeout(() => {
if (swiper.onSlideToWrapperTransitionEnd) {
swiper.onSlideToWrapperTransitionEnd();
}
}, speed)
}
return true;
}
import {
nextTick
} from '../../shared/utils.js';
export default function slideToClickedSlide() {
const swiper = this;
const {
params,
$wrapperEl
} = swiper;
const slidesPerView = params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : params.slidesPerView;
let slideToIndex = swiper.clickedIndex;
let realIndex;
if (params.loop) {
if (swiper.animating) return;
// realIndex = parseInt($(swiper.clickedSlide).attr('data-swiper-slide-index'), 10);
realIndex = parseInt(swiper.activeIndex, 10);
if (params.centeredSlides) {
if (slideToIndex < swiper.loopedSlides - slidesPerView / 2 || slideToIndex > swiper.slides.length - swiper
.loopedSlides + slidesPerView / 2) {
swiper.loopFix();
slideToIndex = $wrapperEl.children(
`.${params.slideClass}[data-swiper-slide-index="${realIndex}"]:not(.${params.slideDuplicateClass})`
).eq(0).index();
nextTick(() => {
swiper.slideTo(slideToIndex);
});
} else {
swiper.slideTo(slideToIndex);
}
} else if (slideToIndex > swiper.slides.length - slidesPerView) {
swiper.loopFix();
slideToIndex = $wrapperEl.children(
`.${params.slideClass}[data-swiper-slide-index="${realIndex}"]:not(.${params.slideDuplicateClass})`)
.eq(0).index();
nextTick(() => {
swiper.slideTo(slideToIndex);
});
} else {
swiper.slideTo(slideToIndex);
}
} else {
swiper.slideTo(slideToIndex);
}
}
/* eslint no-unused-vars: "off" */
export default function slideToClosest(speed = this.params.speed, runCallbacks = true, internal, threshold = 0.5) {
const swiper = this;
let index = swiper.activeIndex;
const skip = Math.min(swiper.params.slidesPerGroupSkip, index);
const snapIndex = skip + Math.floor((index - skip) / swiper.params.slidesPerGroup);
const translate = swiper.rtlTranslate ? swiper.translate : -swiper.translate;
if (translate >= swiper.snapGrid[snapIndex]) {
const currentSnap = swiper.snapGrid[snapIndex];
const nextSnap = swiper.snapGrid[snapIndex + 1];
if (translate - currentSnap > (nextSnap - currentSnap) * threshold) {
index += swiper.params.slidesPerGroup;
}
} else {
const prevSnap = swiper.snapGrid[snapIndex - 1];
const currentSnap = swiper.snapGrid[snapIndex];
if (translate - prevSnap <= (currentSnap - prevSnap) * threshold) {
index -= swiper.params.slidesPerGroup;
}
}
index = Math.max(index, 0);
index = Math.min(index, swiper.slidesGrid.length - 1);
return swiper.slideTo(index, speed, runCallbacks, internal);
}
\ No newline at end of file
export default function slideToLoop(index = 0, speed = this.params.speed, runCallbacks = true, internal) {
const swiper = this;
let newIndex = index;
if (swiper.params.loop) {
newIndex += swiper.loopedSlides;
}
return swiper.slideTo(newIndex, speed, runCallbacks, internal);
}
\ No newline at end of file
import setTransition from './setTransition.js';
import transitionStart from './transitionStart.js';
import transitionEnd from './transitionEnd.js';
export default {
setTransition,
transitionStart,
transitionEnd
};
export default function setTransition(duration, byController) {
const swiper = this;
if (!swiper.$wrapperEl) return
if (!swiper.params.cssMode) {
swiper.$wrapperEl.transition(duration);
}
swiper.emit('setTransition', duration, byController);
}
export default function transitionEmit({
swiper,
runCallbacks,
direction,
step
}) {
const {
activeIndex,
previousIndex
} = swiper;
let dir = direction;
if (!dir) {
if (activeIndex > previousIndex) dir = 'next';
else if (activeIndex < previousIndex) dir = 'prev';
else dir = 'reset';
}
swiper.emit(`transition${step}`);
if (runCallbacks && activeIndex !== previousIndex) {
if (dir === 'reset') {
swiper.emit(`slideResetTransition${step}`);
return;
}
swiper.emit(`slideChangeTransition${step}`);
if (dir === 'next') {
swiper.emit(`slideNextTransition${step}`);
} else {
swiper.emit(`slidePrevTransition${step}`);
}
}
}
import transitionEmit from './transitionEmit.js';
export default function transitionEnd(runCallbacks = true, direction) {
const swiper = this;
const {
params
} = swiper;
swiper.animating = false;
if (params.cssMode) return;
swiper.setTransition(0);
transitionEmit({
swiper,
runCallbacks,
direction,
step: 'End'
});
}
import transitionEmit from './transitionEmit.js';
export default function transitionStart(runCallbacks = true, direction) {
const swiper = this;
const {
params
} = swiper;
if (params.cssMode) return;
if (params.autoHeight) {
swiper.updateAutoHeight();
}
transitionEmit({
swiper,
runCallbacks,
direction,
step: 'Start'
});
}
import {
getTranslate
} from '../../shared/utils.js';
export default function getSwiperTranslate(axis = this.isHorizontal() ? 'x' : 'y') {
const swiper = this;
const {
params,
rtlTranslate: rtl,
translate,
$wrapperEl
} = swiper;
if (params.virtualTranslate) {
return rtl ? -translate : translate;
}
if (params.cssMode) {
return translate;
}
let currentTranslate = getTranslate(swiper, axis);
if (rtl) currentTranslate = -currentTranslate;
return currentTranslate || 0;
}
import getTranslate from './getTranslate.js';
import setTranslate from './setTranslate.js';
import minTranslate from './minTranslate.js';
import maxTranslate from './maxTranslate.js';
import translateTo from './translateTo.js';
export default {
getTranslate,
setTranslate,
minTranslate,
maxTranslate,
translateTo
};
\ No newline at end of file
export default function maxTranslate() {
return -this.snapGrid[this.snapGrid.length - 1];
}
\ No newline at end of file
export default function minTranslate() {
return -this.snapGrid[0];
}
\ No newline at end of file
export default function setTranslate(translate, byController) {
const swiper = this;
const {
rtlTranslate: rtl,
params,
$wrapperEl,
wrapperEl,
progress
} = swiper;
let x = 0;
let y = 0;
const z = 0;
if (isNaN(translate)) {
return
}
if (!$wrapperEl) return
if (swiper.isHorizontal()) {
x = rtl ? -translate : translate;
} else {
y = translate;
}
if (params.roundLengths) {
x = Math.floor(x);
y = Math.floor(y);
}
if (params.cssMode) {
wrapperEl[swiper.isHorizontal() ? 'scrollLeft' : 'scrollTop'] = swiper.isHorizontal() ? -x : -y;
} else if (!params.virtualTranslate) {
$wrapperEl.transform(`translate3d(${x}px, ${y}px, ${z}px)`);
}
swiper.previousTranslate = swiper.translate;
swiper.translate = swiper.isHorizontal() ? x : y; // Check if we need to update progress
let newProgress;
const translatesDiff = swiper.maxTranslate() - swiper.minTranslate();
if (translatesDiff === 0) {
newProgress = 0;
} else {
newProgress = (translate - swiper.minTranslate()) / translatesDiff;
}
if (newProgress !== progress) {
swiper.updateProgress(translate);
}
swiper.emit('setTranslate', swiper.translate, byController);
}
import {
animateCSSModeScroll
} from '../../shared/utils.js';
export default function translateTo(translate = 0, speed = this.params.speed, runCallbacks = true, translateBounds =
true, internal) {
const swiper = this;
let timer;
const {
params,
wrapperEl
} = swiper;
if (swiper.animating && params.preventInteractionOnTransition) {
return false;
}
const minTranslate = swiper.minTranslate();
const maxTranslate = swiper.maxTranslate();
let newTranslate;
if (translateBounds && translate > minTranslate) newTranslate = minTranslate;
else if (translateBounds && translate < maxTranslate) newTranslate = maxTranslate;
else newTranslate = translate; // Update progress
swiper.updateProgress(newTranslate);
if (params.cssMode) {
const isH = swiper.isHorizontal();
if (speed === 0) {
wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = -newTranslate;
} else {
if (!swiper.support.smoothScroll) {
animateCSSModeScroll({
swiper,
targetPosition: -newTranslate,
side: isH ? 'left' : 'top'
});
return true;
}
wrapperEl.scrollTo({
[isH ? 'left' : 'top']: -newTranslate,
behavior: 'smooth'
});
}
return true;
}
if (speed === 0) {
swiper.setTransition(0);
swiper.setTranslate(newTranslate);
if (runCallbacks) {
swiper.emit('beforeTransitionStart', speed, internal);
swiper.emit('transitionEnd');
}
} else {
swiper.setTransition(speed);
swiper.setTranslate(newTranslate);
if (runCallbacks) {
swiper.emit('beforeTransitionStart', speed, internal);
swiper.emit('transitionStart');
}
if (!swiper.animating) {
swiper.animating = true;
if (!swiper.onTranslateToWrapperTransitionEnd) {
swiper.onTranslateToWrapperTransitionEnd = function transitionEnd(e) {
if (!swiper || swiper.destroyed) return;
if (e.target !== this) return;
clearTimeout(timer)
swiper.onTranslateToWrapperTransitionEnd = null;
delete swiper.onTranslateToWrapperTransitionEnd;
if (runCallbacks) {
swiper.emit('transitionEnd');
}
};
}
timer = setTimeout(() => {
swiper.onTranslateToWrapperTransitionEnd();
}, speed)
}
}
return true;
}
import updateSize from './updateSize.js';
import updateSlides from './updateSlides.js';
import updateAutoHeight from './updateAutoHeight.js';
import updateSlidesOffset from './updateSlidesOffset.js';
import updateSlidesProgress from './updateSlidesProgress.js';
import updateProgress from './updateProgress.js';
import updateSlidesClasses from './updateSlidesClasses.js';
import updateActiveIndex from './updateActiveIndex.js';
import updateClickedSlide from './updateClickedSlide.js';
export default {
updateSize,
updateSlides,
updateAutoHeight,
updateSlidesOffset,
updateSlidesProgress,
updateProgress,
updateSlidesClasses,
updateActiveIndex,
updateClickedSlide
};
export default function updateActiveIndex(newActiveIndex) {
const swiper = this;
const translate = swiper.rtlTranslate ? swiper.translate : -swiper.translate;
const {
slidesGrid,
snapGrid,
params,
activeIndex: previousIndex,
realIndex: previousRealIndex,
snapIndex: previousSnapIndex
} = swiper;
let activeIndex = newActiveIndex;
let snapIndex;
if (typeof activeIndex === 'undefined') {
for (let i = 0; i < slidesGrid.length; i += 1) {
if (typeof slidesGrid[i + 1] !== 'undefined') {
if (translate >= slidesGrid[i] && translate < slidesGrid[i + 1] - (slidesGrid[i + 1] - slidesGrid[i]) /
2) {
activeIndex = i;
} else if (translate >= slidesGrid[i] && translate < slidesGrid[i + 1]) {
activeIndex = i + 1;
}
} else if (translate >= slidesGrid[i]) {
activeIndex = i;
}
} // Normalize slideIndex
if (params.normalizeSlideIndex) {
if (activeIndex < 0 || typeof activeIndex === 'undefined') activeIndex = 0;
}
}
if (snapGrid.indexOf(translate) >= 0) {
snapIndex = snapGrid.indexOf(translate);
} else {
const skip = Math.min(params.slidesPerGroupSkip, activeIndex);
snapIndex = skip + Math.floor((activeIndex - skip) / params.slidesPerGroup);
}
if (snapIndex >= snapGrid.length) snapIndex = snapGrid.length - 1;
if (swiper.loopedSlides) {
swiper.slides.filter((item) => item.index >= swiper.loopedSlides && item.index < swiper.slides.length - swiper
.loopedSlides).forEach((item, index) => {
item.dataSwiperSlideIndex = item.index - swiper.loopedSlides;
})
swiper.slides.filter((item) => item.index < swiper.loopedSlides).forEach((item, index) => {
if (swiper.slides[swiper.slides.length - swiper.loopedSlides * 3 + index]) {
item.dataSwiperSlideIndex = swiper.slides[swiper.slides.length - swiper.loopedSlides * 3 +
index]
.index;
}
})
swiper.slides.filter((item) => item.index >= swiper.slides.length - swiper
.loopedSlides).forEach((item, index) => {
item.dataSwiperSlideIndex = swiper.slides[index].index;
})
}
if (activeIndex === previousIndex) {
if (snapIndex !== previousSnapIndex) {
swiper.snapIndex = snapIndex;
swiper.emit('snapIndexChange');
}
return;
} // Get real index
let realIndex;
if (swiper.virtual && params.virtual.enabled) {
realIndex = activeIndex;
} else {
if (swiper.slides[activeIndex].dataSwiperSlideIndex == undefined || swiper.slides[activeIndex]
.dataSwiperSlideIndex == null) {
realIndex = activeIndex;
} else {
realIndex = swiper.slides[activeIndex].dataSwiperSlideIndex;
}
}
Object.assign(swiper, {
snapIndex,
realIndex,
previousIndex,
activeIndex
});
swiper.emit('activeIndexChange');
swiper.emit('snapIndexChange');
if (previousRealIndex !== realIndex) {
swiper.emit('realIndexChange');
}
if (swiper.initialized || swiper.params.runCallbacksOnInit) {
swiper.emit('slideChange', activeIndex);
}
}
export default async function updateAutoHeight(speed) {
const swiper = this;
const activeSlides = [];
const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
let newHeight = 0;
let i;
if (typeof speed === 'number') {
swiper.setTransition(speed);
} else if (speed === true) {
swiper.setTransition(swiper.params.speed);
}
const getSlideByIndex = index => {
if (isVirtual) {
return swiper.slides.filter(el => parseInt(el.getAttribute('data-swiper-slide-index'), 10) ===
index)[
0];
}
return swiper.slides[index];
}; // Find slides currently in view
if (swiper.params.slidesPerView !== 'auto' && swiper.params.slidesPerView > 1) {
if (swiper.params.centeredSlides) {
swiper.visibleSlides.each(slide => {
activeSlides.push(slide);
});
} else {
for (i = 0; i < Math.ceil(swiper.params.slidesPerView); i += 1) {
const index = swiper.activeIndex + i;
if (index > swiper.slides.length && !isVirtual) break;
activeSlides.push(getSlideByIndex(index));
}
}
} else {
activeSlides.push(getSlideByIndex(swiper.activeIndex));
} // Find new height from highest slide in view
for (i = 0; i < activeSlides.length; i += 1) {
if (typeof activeSlides[i] !== 'undefined') {
const size = await activeSlides[i].getSize();
const height = size.height;
newHeight = height > newHeight ? height : newHeight;
}
} // Update Height
if (newHeight || newHeight === 0) swiper.$wrapperEl.css({
height: `${newHeight?newHeight:''}px`
});
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!