Skip to content
This repository was archived by the owner on Jul 7, 2025. It is now read-only.

Commit 4210cc4

Browse files
committed
feat(movable): remove some underscores
1 parent 173b405 commit 4210cc4

File tree

1 file changed

+36
-36
lines changed

1 file changed

+36
-36
lines changed

packages/KMovable/KMovableView.vue

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ export default {
268268
},
269269
handleTouchStart(e) {
270270
this.touchTrack.onTouchEvent(e)
271-
if (this._isScaling || this.disabled) return
271+
if (this.isScaling || this.disabled) return
272272
273273
if (this.frictionAnimation) this.frictionAnimation = this.frictionAnimation.cancel()
274274
if (this.springAnimation) this.springAnimation = this.springAnimation.cancel()
@@ -278,60 +278,60 @@ export default {
278278
this.touchInfo.historyT = [0, 0]
279279
280280
if (this.xMove) {
281-
this._baseX = this.translateX
281+
this.baseX = this.translateX
282282
}
283283
if (this.yMove) {
284-
this._baseY = this.translateY
284+
this.baseY = this.translateY
285285
}
286286
this.$el.style.willChange = 'transform'
287-
this._checkCanMove = null
288-
this._firstMoveDirection = null
289-
this._isTouching = true
287+
this.checkCanMove = null
288+
this.firstMoveDirection = null
289+
this.isTouching = true
290290
},
291291
handleTouchMove(_e) {
292292
const e = this.touchTrack.onTouchEvent(_e)
293-
if (this._isScaling || this.disabled || !this._isTouching) return
293+
if (this.isScaling || this.disabled || !this.isTouching) return
294294
295295
let x = this.translateX
296296
let y = this.translateY
297297
298-
if (this._firstMoveDirection === null) {
299-
this._firstMoveDirection = Math.abs(e.touchDetail.dx / e.touchDetail.dy) > 1 ? 'htouchmove' : 'vtouchmove'
298+
if (this.firstMoveDirection === null) {
299+
this.firstMoveDirection = Math.abs(e.touchDetail.dx / e.touchDetail.dy) > 1 ? 'htouchmove' : 'vtouchmove'
300300
}
301301
302302
if (this.xMove) {
303-
x = e.touchDetail.dx + this._baseX
303+
x = e.touchDetail.dx + this.baseX
304304
305305
this.touchInfo.historyX.shift()
306306
this.touchInfo.historyX.push(x)
307307
308-
if (!this.yMove && this._checkCanMove === null) {
308+
if (!this.yMove && this.checkCanMove === null) {
309309
if (Math.abs(e.touchDetail.dx / e.touchDetail.dy) > 1) {
310-
this._checkCanMove = false
310+
this.checkCanMove = false
311311
} else {
312-
this._checkCanMove = true
312+
this.checkCanMove = true
313313
}
314314
}
315315
}
316316
if (this.yMove) {
317-
y = e.touchDetail.dy + this._baseY
317+
y = e.touchDetail.dy + this.baseY
318318
319319
this.touchInfo.historyY.shift()
320320
this.touchInfo.historyY.push(y)
321321
322-
if (!this.xMove && this._checkCanMove === null) {
322+
if (!this.xMove && this.checkCanMove === null) {
323323
if (Math.abs(e.touchDetail.dy / e.touchDetail.dx) > 1) {
324-
this._checkCanMove = false
324+
this.checkCanMove = false
325325
} else {
326-
this._checkCanMove = true
326+
this.checkCanMove = true
327327
}
328328
}
329329
}
330330
331331
this.touchInfo.historyT.shift()
332332
this.touchInfo.historyT.push(e.touchDetail.timeStamp)
333333
334-
if (!this._checkCanMove) {
334+
if (!this.checkCanMove) {
335335
e.preventDefault()
336336
337337
let source = 'touch'
@@ -371,19 +371,19 @@ export default {
371371
})
372372
}
373373
374-
const firstMoveDirection = this._firstMoveDirection
374+
const firstMoveDirection = this.firstMoveDirection
375375
const event = dispatchEvent(this.$el, firstMoveDirection, e)
376376
377377
if (event.defaultPrevented) e.stopPropagation()
378378
},
379379
handleTouchCancelOrEnd(_e) {
380380
this.touchTrack.onTouchEvent(_e)
381-
if (this._isScaling || this.disabled || !this._isTouching) return
381+
if (this.isScaling || this.disabled || !this.isTouching) return
382382
383383
this.$el.style.willChange = 'auto'
384-
this._isTouching = false
384+
this.isTouching = false
385385
386-
if (this._checkCanMove) return
386+
if (this.checkCanMove) return
387387
388388
if (this.revise('out-of-bounds')) return
389389
@@ -473,34 +473,34 @@ export default {
473473
474474
const rect = this.$el.getBoundingClientRect()
475475
476-
this._height = rect.height / this.scaling
477-
this._width = rect.width / this.scaling
476+
this.height = rect.height / this.scaling
477+
this.width = rect.width / this.scaling
478478
479-
const viewHeight = this._height * scale
480-
const viewWidth = this._width * scale
479+
const viewHeight = this.height * scale
480+
const viewWidth = this.width * scale
481481
482-
this.scaleOffset.x = (viewWidth - this._width) / 2
483-
this.scaleOffset.y = (viewHeight - this._height) / 2
482+
this.scaleOffset.x = (viewWidth - this.width) / 2
483+
this.scaleOffset.y = (viewHeight - this.height) / 2
484484
},
485485
486486
updateBoundary() {
487487
const x1 = 0 - this.offset.x + this.scaleOffset.x
488-
const x2 = this.areaWidth - this._width - this.offset.x - this.scaleOffset.x
488+
const x2 = this.areaWidth - this.width - this.offset.x - this.scaleOffset.x
489489
this.minX = Math.min(x1, x2)
490490
this.maxX = Math.max(x1, x2)
491491
492492
const y1 = 0 - this.offset.y + this.scaleOffset.y
493-
const y2 = this.areaHeight - this._height - this.offset.y - this.scaleOffset.y
493+
const y2 = this.areaHeight - this.height - this.offset.y - this.scaleOffset.y
494494
this.minY = Math.min(y1, y2)
495495
this.maxY = Math.max(y1, y2)
496496
},
497497
498-
_beginScale() {
499-
this._isScaling = true
498+
beginScale() {
499+
this.isScaling = true
500500
},
501501
502502
endScale() {
503-
this._isScaling = false
503+
this.isScaling = false
504504
505505
this.updateOldScale(this.scaling)
506506
},
@@ -510,20 +510,20 @@ export default {
510510
511511
scale *= this.oldScale
512512
513-
this._beginScale()
513+
this.beginScale()
514514
this.updateScale(scale)
515515
},
516516
517517
setTransformed(isTransformed) {
518-
this._isTransformed = isTransformed
518+
this.isTransformed = isTransformed
519519
},
520520
521521
updateScale(scale, needAnimation, cb) {
522522
if (!this.scale) return
523523
524524
scale = this.adjustScale(scale)
525525
526-
if (!this._isTransformed) {
526+
if (!this.isTransformed) {
527527
this.updateWidthAndHeight(scale)
528528
this.updateBoundary()
529529
}

0 commit comments

Comments
 (0)