Skip to content

Commit ce60e97

Browse files
committed
Added a new parameter to separate the toggle trigger and the opened toggle width
1 parent b9906a5 commit ce60e97

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

lib/listviews/SwipeListItemView.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,12 @@ let getPageY = function getPageY(ev){
4646
* @param {ListView} options.parentList - Parent ListView, it's mandatory
4747
* @param {bool} [options.left] [true] - Support left swipe
4848
* @param {bool} [options.right] [true] - Support right swipe
49-
* @param {integer} [options.leftWidth] [100] - Size in pixels to activate the left action
50-
* @param {integer} [options.rightWidth] [100] - Size in pixels to activate the right action
49+
* @param {integer} [options.leftWidth] [64] - Size in pixels to activate the left action
50+
* @param {integer} [options.rightWidth] [64] - Size in pixels to activate the right action
5151
* @param {bool} [options.toggleLeft] [true] - If true the drawer remains opened after a swipe left
5252
* @param {bool} [options.toggleRight] [true] - If true the drawer remains opened after a swipe right
53+
* @param {integer} [options.toggleLeftWidth] [88] - Size in pixels of the left action, used when the drawer is open
54+
* @param {integer} [options.toggleRightWidth] [88] - Size in pixels of the right action, used when the drawer is open
5355
* @param {integer} [options.duration] [300] - Animation duration in ms
5456
* @param {bool} [options.friction] [true] - Adds a friction to the drawer
5557
* @param {integer} [options.frictionStartAt] [80] - The amount of swipe, in pixels, before friction start
@@ -112,10 +114,12 @@ export default class SwipeListItemView extends ListItemView {
112114
this.setDefaultsOptions(getContextOptions('SwipeListItemView'), {
113115
left: true,
114116
right: true,
115-
leftWidth: 100,
116-
rightWidth: 100,
117+
leftWidth: 64,
118+
rightWidth: 64,
117119
toggleLeft: true,
118120
toggleRight: true,
121+
toggleLeftWidth: 88,
122+
toggleRightWidth: 88,
119123
duration: 300,
120124
friction: true,
121125
frictionStartAt: 80,
@@ -189,9 +193,9 @@ export default class SwipeListItemView extends ListItemView {
189193
this.origianlStartY = this.startY;
190194

191195
if (this.status === STATUS_LEFT_ACTIVE) {
192-
this.startX -= this.options.leftWidth;
196+
this.startX -= this.options.toggleLeftWidth;
193197
} else if (this.status === STATUS_RIGHT_ACTIVE) {
194-
this.startX += this.options.rightWidth;
198+
this.startX += this.options.toggleRightWidth;
195199
}
196200

197201
this.deltaX = 0;
@@ -257,7 +261,7 @@ export default class SwipeListItemView extends ListItemView {
257261

258262
if (this.options.left && deltaX >= this.options.leftWidth) {
259263
if (this.options.toggleLeft) {
260-
endX = this.options.leftWidth;
264+
endX = this.options.toggleLeftWidth;
261265
endStatus = STATUS_LEFT_ACTIVE;
262266
this.addActiveClass();
263267
}
@@ -266,7 +270,7 @@ export default class SwipeListItemView extends ListItemView {
266270

267271
if (this.options.right && deltaX <= -this.options.rightWidth) {
268272
if (this.options.toggleRight) {
269-
endX = -this.options.rightWidth;
273+
endX = -this.options.toggleRightWidth;
270274
endStatus = STATUS_RIGHT_ACTIVE;
271275
this.addActiveClass();
272276
}
@@ -424,6 +428,7 @@ export default class SwipeListItemView extends ListItemView {
424428
* @version 2.1.0
425429
*/
426430
vibrate() {
431+
console.log('vibrate');
427432
if (this.options.vibrateCallback) {
428433
this.options.vibrateCallback();
429434
}

0 commit comments

Comments
 (0)