Skip to content

Commit

Permalink
chore: build
Browse files Browse the repository at this point in the history
  • Loading branch information
zhenyuWang committed Jan 17, 2025
1 parent d0d1dc0 commit 4126540
Show file tree
Hide file tree
Showing 6 changed files with 226 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@
{{ cancelText }}
</text>
</view>
<!-- #ifdef APP-ANDROID -->
<view :style="{height: `${bottomNavigationHeight}px`, backgroundColor: `${theme == 'dark' ? '#2C2C2B' : '#717171'}`}"></view>
<!-- #endif -->
<view :style="{height: `${bottomNavigationHeight}px`, backgroundColor: `${theme == 'dark' ? '#2C2C2B' : '#ffffff'}`}"></view>
<!-- #ifdef WEB -->
<view v-if='isWidescreen && Object.keys(popover).length > 0' :style='triangleStyle' class="uni-action-sheet_dialog__triangle" />
<!-- #endif -->
Expand Down Expand Up @@ -257,9 +255,7 @@
},
},
onReady() {
// #ifdef APP-ANDROID
this.bottomNavigationHeight = uni.getWindowInfo().safeAreaInsets.bottom
// #endif
setTimeout(() => {
this.show = true
}, 10)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { ShowActionSheet, ShowActionSheetOptions, ShowActionSheetSuccessImpl, ShowActionSheetFailImpl } from "../interface.uts";


export const showActionSheet: ShowActionSheet = (options: ShowActionSheetOptions) => {
const uuid = `${Date.now()}${Math.floor(Math.random() * 1e7)}`
const baseEventName = `uni_action_sheet_${uuid}`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<!-- #ifdef APP -->
<view :ref="elId" class="block" :style="{width:size+'px',height:size+'px'}"></view>
<view :ref="elId" class="uni-preview-image-block" :style="{width:size+'px',height:size+'px'}"></view>
<!-- #endif -->
<!-- #ifdef WEB -->
<svg :width="size" :height="size" viewBox="25 25 50 50" :style="{width:size+'px',height:size+'px'}" class="uni-load__img uni-load__img--android-H5">
Expand Down Expand Up @@ -132,7 +132,7 @@
</script>

<style scoped>
.block {
.uni-preview-image-block {
width: 50px;
height: 50px;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<template>
<view style="flex:1;background-color: black;">
<image ref="imageView" :mode="imageMode" class="item" :src="srcPath" @error="previewImageError" @load="onImageLoad"></image>
<view ref="mask" class="patch" @touchstart="onstart" @touchmove="onmove" @touchend="onend" @touchcancel="oncancel"></view>
<view class="loading" v-if="!loadingFinished">
<image ref="imageView" :mode="imageMode" class="uni-preview-image-item" :src="srcPath" @error="previewImageError" @load="onImageLoad"></image>
<view ref="mask" class="uni-preview-image-patch" @touchstart="onstart" @touchmove="onmove" @touchend="onend" @touchcancel="oncancel"></view>
<view class="uni-preview-image-loading" v-if="!loadingFinished">
<loadingCircle style="margin: auto;" :speed="16" :size="54" color="#d3d3d3"></loadingCircle>
</view>
</view>
Expand All @@ -29,7 +29,7 @@
y : number
}
export default {
components:{
components: {
loadingCircle
},
data() {
Expand Down Expand Up @@ -255,7 +255,7 @@
},
onend(e : UniTouchEvent) {
// 清空长按事件,避免连续点击时,仍然会触发长按事件
this.inScaleMode = false
// this.inScaleMode = false
this.needExecLongPress = false
clearTimeout(this.longPressActionTimeoutId)
var current = Date.now()
Expand Down Expand Up @@ -312,6 +312,17 @@
this.lastTouchEndTime = current
}
} else {
if (this.inScaleMode) {
if (this.scaleSize > 3) {
this.scaleSize = 3
this.updateStyle(e, NaN, NaN)
} else if (this.scaleSize < 1) {
this.scaleSize = 1
this.imageLeft = 0
this.updateStyle(e, NaN, NaN)
}
this.lastTouchEndTime = current
}
var xv = 1000 * (this.historyX[1] - this.historyX[0]) / (this.historyT[1] - this.historyT[0])
var yv = 1000 * (this.historyY[1] - this.historyY[0]) / (this.historyT[1] - this.historyT[0])
this._friction.setVelocity(xv, yv)
Expand All @@ -338,6 +349,9 @@
})
}
this.lastSlideTouch = null
// #ifdef APP-ANDROID
this.preventDefaultScall(e)
// #endif
},
oncancel(e : UniTouchEvent) {
this.onend(e)
Expand Down Expand Up @@ -373,8 +387,7 @@
var topMargin = (this.transformOrigin[1] - (this.imageMarginTop > 0 ? this.imageMarginTop : 0)) * this.scaleSize - this.transformOrigin[1]
var bottomMargin = ((this.imageHeight + (this.imageMarginTop > 0 ? this.imageMarginTop : 0) - this.transformOrigin[1]) * this.scaleSize) - (this.screenHeight - this.transformOrigin[1])
if (this.imageTop > topMargin) {
if (!this.inScaleMode)
this.imageTop = topMargin
this.imageTop = topMargin
} else if (this.imageTop < -bottomMargin) {
this.imageTop = -bottomMargin
} else {
Expand Down Expand Up @@ -405,7 +418,7 @@
uni.$emit("__UNIPREVIEWLONGPRESS", { type: "success", tapIndex: e.tapIndex!, index: this.index })
},
fail() {
uni.$emit("__UNIPREVIEWLONGPRESS", { type: "fail"})
uni.$emit("__UNIPREVIEWLONGPRESS", { type: "fail", tapIndex: -1, index: -1 })
}
})
}
Expand Down Expand Up @@ -434,7 +447,7 @@
if (this.imageHeight > 0) {
return
}
uni.createSelectorQuery().in(this).select('.item').boundingClientRect().exec((ret) => {
uni.createSelectorQuery().in(this).select('.uni-preview-image-item').boundingClientRect().exec((ret) => {
if (ret.length == 1) {
var rect = this.imageView!.getBoundingClientRect()
this.screenHeight = rect.height
Expand Down Expand Up @@ -478,21 +491,24 @@
var point2 = e.touches[1]
originalCenterX = (point1.clientX + point2.clientX) / 2
originalCenterY = (point1.clientY + point2.clientY) / 2
if (this.scaleSize * this.imageHeight < this.screenHeight) {
if ((this.scaleSize * this.imageHeight) < this.screenHeight) {
originalCenterY = this.screenHeight / 2
}
if (this.imageHeight > this.screenHeight && this.scaleSize >= 1) {
originalCenterY = originalCenterY - this.imageTop / this.scaleSize
}
this.imageLeft = this.imageLeft + (this.scaleSize - 1.0) * (originalCenterX - this.transformOrigin[0])
this.imageTop = this.imageTop + (this.scaleSize - 1.0) * (originalCenterY - this.transformOrigin[1])
var oldTransformOrigin = [this.transformOrigin[0], this.transformOrigin[1]]
this.transformOrigin = [originalCenterX, originalCenterY]
if (oldTransformOrigin[0] != 0 && oldTransformOrigin[1] != 1) {
this.imageLeft = this.imageLeft + (this.scaleSize - 1.0) * (originalCenterX - oldTransformOrigin[0])
this.imageTop = this.imageTop + (this.scaleSize - 1.0) * (originalCenterY - oldTransformOrigin[1])
}
} else if (e.type == "touchend") {
if (this.inDoubleTapMode && this.scaleSize == 2 && this.lastSlideTouch != null && this.lastSlideTouch!.length == 1) {
originalCenterX = this.lastSlideTouch![0].clientX
originalCenterY = this.lastSlideTouch![0].clientY
if (this.scaleSize * this.imageHeight < this.screenHeight) {
if ((this.scaleSize * this.imageHeight) < this.screenHeight) {
originalCenterY = this.screenHeight / 2
}
if (this.imageHeight > this.screenHeight) {
Expand All @@ -510,21 +526,21 @@
</script>
<style>
.item {
.uni-preview-image-item {
width: 100%;
height: 100%;
transition-property: transform;
transition-duration: 0ms;
}
.patch {
.uni-preview-image-patch {
width: 100%;
height: 100%;
background-color: transparent;
position: absolute;
}
.loading {
.uni-preview-image-loading {
position: absolute;
top: 0;
bottom: 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
<uniPreviewImageItem :index="index" :src="item" :longPressAction="longPressAction"></uniPreviewImageItem>
</swiper-item>
</swiper>
<view ref="numberIndicator" v-if="indicator == 'number'" class="number-indicator">
<text class="number-indicator-text">{{numberIndicator}}</text>
<view ref="numberIndicator" v-if="indicator == 'number'" class="uni-preview-image-number-indicator">
<text class="uni-preview-image-number-indicator-text">{{numberIndicator}}</text>
</view>
<view ref="defaultIndicator" class="default-indicator" v-if="indicator == 'default'" v-show="urls!=null">
<view v-for="i in urls!.length" class="indicator-style" :style="{backgroundColor:((current+1) == i) ? '#ffffff':'#AAAAAA'}">
<view ref="defaultIndicator" class="uni-preview-image-default-indicator" v-if="indicator == 'default'" v-show="urls!=null">
<view v-for="i in urls!.length" class="uni-preview-image-indicator-style" :style="{backgroundColor:((current+1) == i) ? '#ffffff':'#AAAAAA'}">
</view>
</view>
</template>
Expand Down Expand Up @@ -118,7 +118,7 @@
}
</script>
<style>
.indicator-style {
.uni-preview-image-indicator-style {
width: 9px;
height: 9px;
border-style: solid;
Expand All @@ -128,7 +128,7 @@
border-color: #AAAAAA;
}
.default-indicator {
.uni-preview-image-default-indicator {
flex-direction: row;
position: absolute;
bottom: 0px;
Expand All @@ -137,7 +137,7 @@
justify-content: center;
}
.number-indicator {
.uni-preview-image-number-indicator {
position: absolute;
color: white;
font-size: 16px;
Expand All @@ -146,7 +146,7 @@
right: 0;
}
.number-indicator-text {
.uni-preview-image-number-indicator-text {
color: white;
font-size: 16px;
margin: auto;
Expand Down
Loading

0 comments on commit 4126540

Please sign in to comment.