props定义改为驼峰风格
parent
012a2c2002
commit
304826d3ed
|
@ -15,7 +15,7 @@ class Badge extends Component {
|
||||||
default: null
|
default: null
|
||||||
},
|
},
|
||||||
hidden: false,
|
hidden: false,
|
||||||
'is-dot': false
|
isDot: false
|
||||||
}
|
}
|
||||||
|
|
||||||
static styles = [
|
static styles = [
|
||||||
|
@ -85,7 +85,7 @@ class Badge extends Component {
|
||||||
return html`
|
return html`
|
||||||
<div class="badge" ref="bad">
|
<div class="badge" ref="bad">
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
${!this['is-dot'] && !this.hidden
|
${!this.isDot && !this.hidden
|
||||||
? html`<div class="num">
|
? html`<div class="num">
|
||||||
${this.max && this.value >= this.max
|
${this.max && this.value >= this.max
|
||||||
? this.max + '+'
|
? this.max + '+'
|
||||||
|
|
|
@ -23,7 +23,7 @@ class TextArea extends Component {
|
||||||
minheight: null,
|
minheight: null,
|
||||||
maxlength: null,
|
maxlength: null,
|
||||||
minlength: null,
|
minlength: null,
|
||||||
'show-limit': false,
|
showLimit: false,
|
||||||
lazy: 0 // 并发拦截时间, 单位毫秒
|
lazy: 0 // 并发拦截时间, 单位毫秒
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,7 +228,7 @@ class TextArea extends Component {
|
||||||
@keydown=${this.onKeydown}
|
@keydown=${this.onKeydown}
|
||||||
@change=${this.onChange}
|
@change=${this.onChange}
|
||||||
></textarea>
|
></textarea>
|
||||||
${this['show-limit']
|
${this.showLimit
|
||||||
? html`<div class="input-stat">
|
? html`<div class="input-stat">
|
||||||
${this.value.length}/${this.maxlength || '∞'}
|
${this.value.length}/${this.maxlength || '∞'}
|
||||||
</div>`
|
</div>`
|
||||||
|
|
|
@ -15,8 +15,8 @@ class ImagePreview extends Component {
|
||||||
attribute: false
|
attribute: false
|
||||||
},
|
},
|
||||||
visible: false,
|
visible: false,
|
||||||
'max-zoom': 3,
|
maxZoom: 3,
|
||||||
'min-zoom': 1 / 3
|
minZoom: 1 / 3
|
||||||
}
|
}
|
||||||
|
|
||||||
static styles = css`
|
static styles = css`
|
||||||
|
@ -138,8 +138,7 @@ class ImagePreview extends Component {
|
||||||
this.setZoom(this.#state.scale / 1.2)
|
this.setZoom(this.#state.scale / 1.2)
|
||||||
}
|
}
|
||||||
setZoom(val) {
|
setZoom(val) {
|
||||||
const maxZoom = this['max-zoom']
|
const { maxZoom, minZoom } = this
|
||||||
const minZoom = this['min-zoom']
|
|
||||||
val = Math.max(val, minZoom)
|
val = Math.max(val, minZoom)
|
||||||
val = Math.min(val, maxZoom)
|
val = Math.min(val, maxZoom)
|
||||||
val = val.toFixed(2)
|
val = val.toFixed(2)
|
||||||
|
|
|
@ -12,7 +12,7 @@ class Image extends Component {
|
||||||
src: '',
|
src: '',
|
||||||
fit: 'fill',
|
fit: 'fill',
|
||||||
lazy: false,
|
lazy: false,
|
||||||
'referrer-policy': null,
|
referrerPolicy: null,
|
||||||
alt: {
|
alt: {
|
||||||
type: String,
|
type: String,
|
||||||
default: null
|
default: null
|
||||||
|
@ -56,15 +56,7 @@ class Image extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
let {
|
let { lazy, src, status, fit, alt, referrerPolicy } = this
|
||||||
lazy,
|
|
||||||
src,
|
|
||||||
status,
|
|
||||||
fit,
|
|
||||||
alt,
|
|
||||||
'referrer-policy': referrerPolicy
|
|
||||||
} = this
|
|
||||||
|
|
||||||
let styles = styleMap({
|
let styles = styleMap({
|
||||||
'object-fit': fit
|
'object-fit': fit
|
||||||
})
|
})
|
||||||
|
|
|
@ -14,22 +14,22 @@ class Popconfirm extends Component {
|
||||||
default: '',
|
default: '',
|
||||||
attribute: false
|
attribute: false
|
||||||
},
|
},
|
||||||
'confirm-button-text': {
|
confirmButtonText: {
|
||||||
type: String,
|
type: String,
|
||||||
default: '确定',
|
default: '确定',
|
||||||
attribute: false
|
attribute: false
|
||||||
},
|
},
|
||||||
'cancel-button-text': {
|
cancelButtonText: {
|
||||||
type: String,
|
type: String,
|
||||||
default: '取消',
|
default: '取消',
|
||||||
attribute: false
|
attribute: false
|
||||||
},
|
},
|
||||||
'confirm-button-type': {
|
confirmButtonType: {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'primary',
|
default: 'primary',
|
||||||
attribute: false
|
attribute: false
|
||||||
},
|
},
|
||||||
'cancel-button-type': {
|
cancelButtonType: {
|
||||||
type: String,
|
type: String,
|
||||||
default: '',
|
default: '',
|
||||||
attribute: false
|
attribute: false
|
||||||
|
@ -39,15 +39,14 @@ class Popconfirm extends Component {
|
||||||
default: 'info',
|
default: 'info',
|
||||||
attribute: false
|
attribute: false
|
||||||
},
|
},
|
||||||
'icon-color': {
|
iconColor: {
|
||||||
type: String,
|
type: String,
|
||||||
default: '#ff9900',
|
default: '#ff9900',
|
||||||
attribute: false
|
attribute: false
|
||||||
},
|
},
|
||||||
'hide-icon': {
|
hideIcon: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false
|
||||||
attribute: false
|
|
||||||
},
|
},
|
||||||
|
|
||||||
show: {
|
show: {
|
||||||
|
@ -187,34 +186,34 @@ class Popconfirm extends Component {
|
||||||
ref="popover"
|
ref="popover"
|
||||||
>
|
>
|
||||||
<p class="content">
|
<p class="content">
|
||||||
${this['hide-icon']
|
${this.hideIcon
|
||||||
? ''
|
? ''
|
||||||
: html`<wc-icon
|
: html`<wc-icon
|
||||||
name=${this.icon}
|
name=${this.icon}
|
||||||
style=${`color:${this['icon-color']}`}
|
style=${`color:${this.iconColor}`}
|
||||||
></wc-icon>`}
|
></wc-icon>`}
|
||||||
${this.title}
|
${this.title}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="btns">
|
<div class="btns">
|
||||||
${!this['cancel-button-type']
|
${!this.cancelButtonType
|
||||||
? html`<span class="cancel" @click=${this.hide}
|
? html`<span class="cancel" @click=${this.hide}
|
||||||
>${this['cancel-button-text']}</span
|
>${this.cancelButtonText}</span
|
||||||
>`
|
>`
|
||||||
: html`<wc-button
|
: html`<wc-button
|
||||||
type=${this['cancel-button-type']}
|
type=${this[cancelButtonType]}
|
||||||
class="cancel"
|
class="cancel"
|
||||||
size="s"
|
size="s"
|
||||||
@click=${this.hide}
|
@click=${this.hide}
|
||||||
>${this['cancel-button-text']}</wc-button
|
>${this[cancelButtonText]}</wc-button
|
||||||
>`}
|
>`}
|
||||||
|
|
||||||
<wc-button
|
<wc-button
|
||||||
type=${this['confirm-button-type']}
|
type=${this.confirmButtonType}
|
||||||
size="s"
|
size="s"
|
||||||
solid
|
solid
|
||||||
@click=${this.hide}
|
@click=${this.hide}
|
||||||
>${this['confirm-button-text']}</wc-button
|
>${this.confirmButtonText}</wc-button
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -20,12 +20,12 @@ class Progress extends Component {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'line' // line/circle/dashboard
|
default: 'line' // line/circle/dashboard
|
||||||
},
|
},
|
||||||
'stroke-width': {
|
strokeWidth: {
|
||||||
type: Number,
|
type: Number,
|
||||||
default: 6,
|
default: 6,
|
||||||
attribute: false
|
attribute: false
|
||||||
},
|
},
|
||||||
'text-inside': {
|
textInside: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
attribute: true
|
attribute: true
|
||||||
|
@ -52,22 +52,22 @@ class Progress extends Component {
|
||||||
default: 126,
|
default: 126,
|
||||||
attribute: false
|
attribute: false
|
||||||
},
|
},
|
||||||
'show-text': {
|
showText: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
attribute: true
|
attribute: true
|
||||||
},
|
},
|
||||||
'back-color': {
|
backColor: {
|
||||||
type: String,
|
type: String,
|
||||||
default: '#ebeef5',
|
default: '#ebeef5',
|
||||||
attribute: false
|
attribute: false
|
||||||
},
|
},
|
||||||
'text-color': {
|
textColor: {
|
||||||
type: String,
|
type: String,
|
||||||
default: '#606266',
|
default: '#606266',
|
||||||
attribute: false
|
attribute: false
|
||||||
},
|
},
|
||||||
'stroke-linecap': {
|
strokeLinecap: {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'round', //butt/round/square
|
default: 'round', //butt/round/square
|
||||||
attribute: false
|
attribute: false
|
||||||
|
@ -125,7 +125,7 @@ class Progress extends Component {
|
||||||
#colors
|
#colors
|
||||||
|
|
||||||
get relativeStrokeWidth() {
|
get relativeStrokeWidth() {
|
||||||
return ((this['stroke-width'] / this.width) * 100).toFixed(1)
|
return ((this.strokeWidth / this.width) * 100).toFixed(1)
|
||||||
}
|
}
|
||||||
get radius() {
|
get radius() {
|
||||||
if (this.type === 'circle' || this.type === 'dashboard') {
|
if (this.type === 'circle' || this.type === 'dashboard') {
|
||||||
|
@ -199,7 +199,7 @@ class Progress extends Component {
|
||||||
get progressTextSize() {
|
get progressTextSize() {
|
||||||
let size =
|
let size =
|
||||||
this.type === 'line'
|
this.type === 'line'
|
||||||
? 12 + this['stroke-width'] * 0.4
|
? 12 + this.strokeWidth * 0.4
|
||||||
: this.width * 0.111111 + 2
|
: this.width * 0.111111 + 2
|
||||||
return size + 'px'
|
return size + 'px'
|
||||||
}
|
}
|
||||||
|
@ -230,7 +230,7 @@ class Progress extends Component {
|
||||||
<path
|
<path
|
||||||
role="circle__track"
|
role="circle__track"
|
||||||
d=${this.trackPath}
|
d=${this.trackPath}
|
||||||
stroke=${this['back-color']}
|
stroke=${this.backColor}
|
||||||
stroke-width=${this.relativeStrokeWidth}
|
stroke-width=${this.relativeStrokeWidth}
|
||||||
fill="none"
|
fill="none"
|
||||||
style=${this.trailPathStyle}
|
style=${this.trailPathStyle}
|
||||||
|
@ -240,7 +240,7 @@ class Progress extends Component {
|
||||||
d=${this.trackPath}
|
d=${this.trackPath}
|
||||||
stroke=${this.stroke}
|
stroke=${this.stroke}
|
||||||
fill="none"
|
fill="none"
|
||||||
stroke-linecap=${this['stroke-linecap']}
|
stroke-linecap=${this.strokeLinecap}
|
||||||
stroke-width=${this.value ? this.relativeStrokeWidth : 0}
|
stroke-width=${this.value ? this.relativeStrokeWidth : 0}
|
||||||
style=${this.circlePathStyle}
|
style=${this.circlePathStyle}
|
||||||
></path>
|
></path>
|
||||||
|
@ -250,13 +250,13 @@ class Progress extends Component {
|
||||||
}
|
}
|
||||||
renderLine() {
|
renderLine() {
|
||||||
let $barInnerText = ''
|
let $barInnerText = ''
|
||||||
if (this['text-inside'] && this['show-text']) {
|
if (this.textInside && this.showText) {
|
||||||
$barInnerText = html`
|
$barInnerText = html`
|
||||||
<div
|
<div
|
||||||
class="bar-innerText"
|
class="bar-innerText"
|
||||||
style=${styleMap({
|
style=${styleMap({
|
||||||
color: this['text-color'],
|
color: this.textColor,
|
||||||
'line-height': this['stroke-width'] + 'px'
|
'line-height': this.strokeWidth + 'px'
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
${this.value + '%'}
|
${this.value + '%'}
|
||||||
|
@ -269,8 +269,8 @@ class Progress extends Component {
|
||||||
<div
|
<div
|
||||||
class="bar-outer"
|
class="bar-outer"
|
||||||
:style=${styleMap({
|
:style=${styleMap({
|
||||||
height: this['stroke-width'] + 'px',
|
height: this.strokeWidth + 'px',
|
||||||
'background-color': this['back-color']
|
'background-color': this.backColor
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
<div class="bar-inner" style=${this.barStyle}>${$barInnerText}</div>
|
<div class="bar-inner" style=${this.barStyle}>${$barInnerText}</div>
|
||||||
|
@ -280,12 +280,12 @@ class Progress extends Component {
|
||||||
}
|
}
|
||||||
render() {
|
render() {
|
||||||
let $outSideText = ''
|
let $outSideText = ''
|
||||||
if (this['show-text'] && !this['text-inside']) {
|
if (this.showText && !this.textInside) {
|
||||||
$outSideText = html`
|
$outSideText = html`
|
||||||
<div
|
<div
|
||||||
class="progress-text"
|
class="progress-text"
|
||||||
style=${styleMap({
|
style=${styleMap({
|
||||||
color: this['text-color'],
|
color: this.textColor,
|
||||||
fontSize: this.progressTextSize
|
fontSize: this.progressTextSize
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
|
|
|
@ -14,7 +14,7 @@ class Result extends Component {
|
||||||
default: '',
|
default: '',
|
||||||
attribute: false
|
attribute: false
|
||||||
},
|
},
|
||||||
'sub-title': { type: String, default: '' },
|
subTitle: { type: String, default: '' },
|
||||||
type: {
|
type: {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'success'
|
default: 'success'
|
||||||
|
@ -117,7 +117,7 @@ class Result extends Component {
|
||||||
|
|
||||||
<div class="sub-title">
|
<div class="sub-title">
|
||||||
<slot name="sub-title">
|
<slot name="sub-title">
|
||||||
<span>${this['sub-title']}</span>
|
<span>${this.subTitle}</span>
|
||||||
</slot>
|
</slot>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
import { css, html, Component, nextTick, styleMap } from '@bd/core'
|
import { css, html, Component, nextTick, styleMap } from '@bd/core'
|
||||||
import '../icon/index.js'
|
import '../icon/index.js'
|
||||||
const CARD_SCALE = 0.83
|
const CARD_SCALE = 0.83
|
||||||
|
|
||||||
function createWatcher(object, key, effect) {
|
function createWatcher(object, key, effect) {
|
||||||
let value
|
let value
|
||||||
Object.defineProperty(object, key, {
|
Object.defineProperty(object, key, {
|
||||||
|
@ -19,9 +20,10 @@ function createWatcher(object, key, effect) {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
class Swipe extends Component {
|
class Swipe extends Component {
|
||||||
static props = {
|
static props = {
|
||||||
'initial-index': {
|
initialIndex: {
|
||||||
type: Number,
|
type: Number,
|
||||||
default: 0
|
default: 0
|
||||||
},
|
},
|
||||||
|
@ -68,11 +70,12 @@ class Swipe extends Component {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'horizontal' // horizontal or vertical
|
default: 'horizontal' // horizontal or vertical
|
||||||
},
|
},
|
||||||
'pause-on-hover': {
|
pauseOnHover: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true
|
default: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static styles = css`
|
static styles = css`
|
||||||
:host {
|
:host {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
@ -175,6 +178,7 @@ class Swipe extends Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
items = []
|
items = []
|
||||||
activeIndex = 0
|
activeIndex = 0
|
||||||
stamp = 0
|
stamp = 0
|
||||||
|
@ -222,16 +226,19 @@ class Swipe extends Component {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.stamp = now
|
this.stamp = now
|
||||||
|
|
||||||
if (typeof index === 'string') {
|
if (typeof index === 'string') {
|
||||||
const filteredItems = this.items.filter(item => item.name === index)
|
const filteredItems = this.items.filter(item => item.name === index)
|
||||||
if (filteredItems.length > 0) {
|
if (filteredItems.length > 0) {
|
||||||
index = this.items.indexOf(filteredItems[0])
|
index = this.items.indexOf(filteredItems[0])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
index = Number(index)
|
index = Number(index)
|
||||||
if (isNaN(index) || index !== Math.floor(index)) {
|
if (isNaN(index) || index !== Math.floor(index)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const length = this.items.length
|
const length = this.items.length
|
||||||
const oldIndex = this.activeIndex
|
const oldIndex = this.activeIndex
|
||||||
if (index < 0) {
|
if (index < 0) {
|
||||||
|
@ -244,6 +251,7 @@ class Swipe extends Component {
|
||||||
if (oldIndex !== this.activeIndex) {
|
if (oldIndex !== this.activeIndex) {
|
||||||
this.resetItemPosition(oldIndex)
|
this.resetItemPosition(oldIndex)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.resetTimer()
|
this.resetTimer()
|
||||||
nextTick(() => this.$requestUpdate())
|
nextTick(() => this.$requestUpdate())
|
||||||
}
|
}
|
||||||
|
@ -277,10 +285,11 @@ class Swipe extends Component {
|
||||||
this.updateItems()
|
this.updateItems()
|
||||||
this.resetItemPosition()
|
this.resetItemPosition()
|
||||||
}
|
}
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
this.updateItems()
|
this.updateItems()
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
let initialIndex = this['initial-index']
|
let initialIndex = this.initialIndex
|
||||||
if (initialIndex >= 0 && initialIndex < this.items.length) {
|
if (initialIndex >= 0 && initialIndex < this.items.length) {
|
||||||
this.activeIndex = initialIndex
|
this.activeIndex = initialIndex
|
||||||
}
|
}
|
||||||
|
@ -289,10 +298,11 @@ class Swipe extends Component {
|
||||||
this.startTimer()
|
this.startTimer()
|
||||||
})
|
})
|
||||||
|
|
||||||
if (this['pause-on-hover']) {
|
if (this.pauseOnHover) {
|
||||||
this.$on('mouseenter', () => this.pauseTimer())
|
this.$on('mouseenter', () => this.pauseTimer())
|
||||||
this.$on('mouseleave', () => this.startTimer())
|
this.$on('mouseleave', () => this.startTimer())
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.arrow === 'hover') {
|
if (this.arrow === 'hover') {
|
||||||
this.$on('mouseenter', () => this.showArrow())
|
this.$on('mouseenter', () => this.showArrow())
|
||||||
this.$on('mouseleave', () => this.hideArrow())
|
this.$on('mouseleave', () => this.hideArrow())
|
||||||
|
@ -300,15 +310,18 @@ class Swipe extends Component {
|
||||||
this.showArrow()
|
this.showArrow()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unmounted() {
|
unmounted() {
|
||||||
this.resizeObserve.disconnect()
|
this.resizeObserve.disconnect()
|
||||||
this.resizeObserve = null
|
this.resizeObserve = null
|
||||||
this.pauseTimer()
|
this.pauseTimer()
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
let styles = styleMap({
|
let styles = styleMap({
|
||||||
opacity: this.showArrowBtn ? 0.6 : 0
|
opacity: this.showArrowBtn ? 0.6 : 0
|
||||||
})
|
})
|
||||||
|
|
||||||
let toggleBtns =
|
let toggleBtns =
|
||||||
this.direction === 'horizontal'
|
this.direction === 'horizontal'
|
||||||
? html`
|
? html`
|
||||||
|
@ -345,10 +358,12 @@ class Swipe extends Component {
|
||||||
`
|
`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class SwipeItem extends Component {
|
class SwipeItem extends Component {
|
||||||
static props = {
|
static props = {
|
||||||
name: { String, attributes: false }
|
name: { String, attributes: false }
|
||||||
}
|
}
|
||||||
|
|
||||||
static styles = css`
|
static styles = css`
|
||||||
:host {
|
:host {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
@ -372,42 +387,51 @@ class SwipeItem extends Component {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
static watch = {
|
static watch = {
|
||||||
translate(val) {
|
translate(val) {
|
||||||
const translateType =
|
const translateType =
|
||||||
this.$parent.direction === 'horizontal' ? 'translateX' : 'translateY'
|
this.$parent.direction === 'horizontal' ? 'translateX' : 'translateY'
|
||||||
this.style.transform = `${translateType}(${val}px) scale(${this.scale})`
|
this.style.transform = `${translateType}(${val}px) scale(${this.scale})`
|
||||||
},
|
},
|
||||||
|
|
||||||
ready(val) {
|
ready(val) {
|
||||||
val ? this.setAttribute('ready', '') : this.removeAttribute('ready')
|
val ? this.setAttribute('ready', '') : this.removeAttribute('ready')
|
||||||
},
|
},
|
||||||
|
|
||||||
animating(val) {
|
animating(val) {
|
||||||
val
|
val
|
||||||
? this.setAttribute('animating', '')
|
? this.setAttribute('animating', '')
|
||||||
: this.removeAttribute('animating')
|
: this.removeAttribute('animating')
|
||||||
},
|
},
|
||||||
|
|
||||||
active(val) {
|
active(val) {
|
||||||
if (this.$parent.type !== 'card') {
|
if (this.$parent.type !== 'card') {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let style = {
|
|
||||||
|
const style = {
|
||||||
opacity: 1,
|
opacity: 1,
|
||||||
'z-index': 1,
|
'z-index': 1,
|
||||||
filter: 'brightness(0.8)'
|
filter: 'brightness(0.8)'
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.inStage) {
|
if (this.inStage) {
|
||||||
style['z-index'] = 1
|
style['z-index'] = 1
|
||||||
} else {
|
} else {
|
||||||
style['z-index'] = -1
|
style['z-index'] = -1
|
||||||
style.opacity = 0
|
style.opacity = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
if (val) {
|
if (val) {
|
||||||
style['z-index'] = 2
|
style['z-index'] = 2
|
||||||
style.filter = 'brightness(1)'
|
style.filter = 'brightness(1)'
|
||||||
}
|
}
|
||||||
|
|
||||||
Object.assign(this.style, style)
|
Object.assign(this.style, style)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
processIndex(index, activeIndex, length) {
|
processIndex(index, activeIndex, length) {
|
||||||
if (activeIndex === 0 && index === length - 1) {
|
if (activeIndex === 0 && index === length - 1) {
|
||||||
return -1
|
return -1
|
||||||
|
@ -420,6 +444,7 @@ class SwipeItem extends Component {
|
||||||
}
|
}
|
||||||
return index
|
return index
|
||||||
}
|
}
|
||||||
|
|
||||||
calcCardTranslate(index, activeIndex) {
|
calcCardTranslate(index, activeIndex) {
|
||||||
const parentWidth = this.$parent.offsetWidth
|
const parentWidth = this.$parent.offsetWidth
|
||||||
if (this.inStage) {
|
if (this.inStage) {
|
||||||
|
@ -430,6 +455,7 @@ class SwipeItem extends Component {
|
||||||
return ((3 + CARD_SCALE) * parentWidth) / 4
|
return ((3 + CARD_SCALE) * parentWidth) / 4
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
calcTranslate(index, activeIndex, isVertical) {
|
calcTranslate(index, activeIndex, isVertical) {
|
||||||
const distance = this.$parent[isVertical ? 'offsetHeight' : 'offsetWidth']
|
const distance = this.$parent[isVertical ? 'offsetHeight' : 'offsetWidth']
|
||||||
return distance * (index - activeIndex)
|
return distance * (index - activeIndex)
|
||||||
|
@ -439,18 +465,22 @@ class SwipeItem extends Component {
|
||||||
const parentType = this.$parent.type
|
const parentType = this.$parent.type
|
||||||
const parentDirection = this.$parent.direction
|
const parentDirection = this.$parent.direction
|
||||||
const length = this.$parent.items.length
|
const length = this.$parent.items.length
|
||||||
|
|
||||||
if (parentType !== 'card' && oldIndex !== undefined) {
|
if (parentType !== 'card' && oldIndex !== undefined) {
|
||||||
this.animating = index === activeIndex || index === oldIndex
|
this.animating = index === activeIndex || index === oldIndex
|
||||||
}
|
}
|
||||||
|
|
||||||
if (index !== activeIndex && length > 2 && this.$parent.loop) {
|
if (index !== activeIndex && length > 2 && this.$parent.loop) {
|
||||||
index = this.processIndex(index, activeIndex, length)
|
index = this.processIndex(index, activeIndex, length)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parentType === 'card') {
|
if (parentType === 'card') {
|
||||||
if (parentDirection === 'vertical') {
|
if (parentDirection === 'vertical') {
|
||||||
console.warn(
|
console.warn(
|
||||||
'[Warn][Carousel]vertical direction is not supported in card mode'
|
'[Warn][Carousel]vertical direction is not supported in card mode'
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.inStage = Math.round(Math.abs(index - activeIndex)) <= 1
|
this.inStage = Math.round(Math.abs(index - activeIndex)) <= 1
|
||||||
this.active = index === activeIndex
|
this.active = index === activeIndex
|
||||||
this.scale = this.active ? 1 : CARD_SCALE
|
this.scale = this.active ? 1 : CARD_SCALE
|
||||||
|
@ -462,14 +492,17 @@ class SwipeItem extends Component {
|
||||||
this.scale = 1
|
this.scale = 1
|
||||||
this.translate = this.calcTranslate(index, activeIndex, isVertical)
|
this.translate = this.calcTranslate(index, activeIndex, isVertical)
|
||||||
}
|
}
|
||||||
|
|
||||||
!this.ready && (this.ready = true)
|
!this.ready && (this.ready = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
created() {
|
created() {
|
||||||
const { watch } = this.constructor
|
const { watch } = this.constructor
|
||||||
for (const key in watch) {
|
for (const key in watch) {
|
||||||
createWatcher(this, key, watch[key])
|
createWatcher(this, key, watch[key])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
this.$parent = this.parentNode
|
this.$parent = this.parentNode
|
||||||
if (this.$parent.type === 'card') {
|
if (this.$parent.type === 'card') {
|
||||||
|
|
Loading…
Reference in New Issue