|
1 | 1 | <template>
|
2 | 2 | <div class="swipeout"
|
3 |
| - :class="{'swipeout--transitioning' : isTransitioning}"> |
| 3 | + :class="{'swipeout--transitioning' : isTransitioning, 'swipeout--disabled': disabled}"> |
4 | 4 | <div v-if="hasLeft" class="swipeout-left" ref="left">
|
5 | 5 | <slot name="left"></slot>
|
6 | 6 | </div>
|
|
48 | 48 | threshold: {
|
49 | 49 | type: Number,
|
50 | 50 | default: 45,
|
51 |
| - }, |
| 51 | + }, |
| 52 | + disabled: { |
| 53 | + type: Boolean, |
| 54 | + default: false, |
| 55 | + } |
52 | 56 | },
|
53 | 57 | mounted() {
|
54 | 58 | if (!this.hasLeft && !this.hasRight)
|
|
87 | 91 | this.rightOpen = true;
|
88 | 92 | this._animateSlide(-this.rightActionsWidth, oldLeft);
|
89 | 93 | },
|
90 |
| - clickReveal() { |
91 |
| - if (!this.hasLeft && this.hasRight) |
92 |
| - if (this.rightOpen) |
93 |
| - this.closeActions(); |
94 |
| - else |
95 |
| - this.revealRight(); |
96 |
| - if (this.hasLeft && !this.hasRight) |
97 |
| - if (this.leftOpen) |
98 |
| - this.closeActions(); |
99 |
| - else |
100 |
| - this.revealLeft(); |
101 |
| - }, |
102 | 94 | // private
|
103 | 95 | _createHammer() {
|
104 | 96 | this.hammer = new Hammer.Manager(this.$el, {
|
105 | 97 | touchAction: 'pan-y',
|
| 98 | + cssProps: { |
| 99 | + userSelect: '', |
| 100 | + }, |
106 | 101 | });
|
107 | 102 |
|
108 | 103 | const doubelTab = new Hammer.Tap({ event: 'doubletap', taps: 2 });
|
|
131 | 126 | return contentRect.left - elementRect.left;
|
132 | 127 | },
|
133 | 128 | _startListener(event) {
|
| 129 | + if (this.disbaled) |
| 130 | + return null; |
| 131 | +
|
134 | 132 | this.isTransitioning = false;
|
135 | 133 | if (event.deltaY >= -5 && event.deltaY <= 5) {
|
136 | 134 | this.leftActionsWidth = this.$refs.left ? this.$refs.left.clientWidth : 0;
|
|
148 | 146 | this.closeActions();
|
149 | 147 | },
|
150 | 148 | _swipeListener(event) {
|
151 |
| - if (!this.isActive) |
| 149 | + if (!this.isActive || this.disabled) |
152 | 150 | return null;
|
153 | 151 |
|
154 | 152 | const newX = this.startLeft + event.deltaX;
|
|
180 | 178 | return this._animateSlide(newX);
|
181 | 179 | },
|
182 | 180 | _stopListener(event) {
|
183 |
| - if (!this.isActive) |
| 181 | + if (!this.isActive || this.disabled) |
184 | 182 | return null;
|
185 | 183 |
|
186 | 184 | const oldLeft = this.$refs.content.getBoundingClientRect().left;
|
|
260 | 258 | });
|
261 | 259 | },
|
262 | 260 | _singleTap(e) {
|
| 261 | + if (this.disabled) |
| 262 | + return; |
263 | 263 | this.$emit('swipeout:click', e);
|
264 | 264 | },
|
265 | 265 | _doubleTap(e) {
|
| 266 | + if (this.disabled) |
| 267 | + return; |
266 | 268 | this.$emit('swipeout:dobuleclick', e);
|
267 | 269 | },
|
268 | 270 | contentClick(e) {
|
| 271 | + if (this.disabled) |
| 272 | + return; |
269 | 273 | this.$emit('swipeout:contentclick', e);
|
270 | 274 | },
|
271 | 275 | },
|
|
279 | 283 | display: flex;
|
280 | 284 | }
|
281 | 285 |
|
| 286 | +.swipeout.swipeout--disabled { |
| 287 | + user-select: auto; |
| 288 | +} |
| 289 | +
|
282 | 290 | .swipeout .swipeout-left, .swipeout .swipeout-right {
|
283 | 291 | position: absolute;
|
284 | 292 | height: 100%;
|
|
0 commit comments