Skip to content

Commit

Permalink
fix(ionItem): properly hide option buttons on scroll in collection-re…
Browse files Browse the repository at this point in the history
…peat

Closes #1811. Closes #2804.
  • Loading branch information
ajoslin committed Feb 5, 2015
1 parent 7557c58 commit 7fec848
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 19 deletions.
45 changes: 30 additions & 15 deletions js/angular/directive/item.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,39 @@ IonicModule
//Lame way of testing, but we have to know at compile what to do with the element
/ion-(delete|option|reorder)-button/i.test($element.html());

if (isComplexItem) {
var innerElement = jqLite(isAnchor ? ITEM_TPL_CONTENT_ANCHOR : ITEM_TPL_CONTENT);
innerElement.append($element.contents());
if (isComplexItem) {
var innerElement = jqLite(isAnchor ? ITEM_TPL_CONTENT_ANCHOR : ITEM_TPL_CONTENT);
innerElement.append($element.contents());

$element.append(innerElement);
$element.addClass('item item-complex');
} else {
$element.addClass('item');
}
$element.append(innerElement);
$element.addClass('item item-complex');
} else {
$element.addClass('item');
}

return function link($scope, $element, $attrs) {
$scope.$href = function() {
return $attrs.href || $attrs.ngHref;
};
$scope.$target = function() {
return $attrs.target || '_self';
};
return function link($scope, $element, $attrs) {
var listCtrl;
$scope.$href = function() {
return $attrs.href || $attrs.ngHref;
};
$scope.$target = function() {
return $attrs.target || '_self';
};

$scope.$on('$ionic.disconnectScope', cleanupDragOp);

function cleanupDragOp() {
// lazily fetch list parent controller
listCtrl || (listCtrl = $element.controller('ionList'));
if (!listCtrl || !listCtrl.listView) return;

if (listCtrl.listView._lastDragOp) {

This comment has been minimized.

Copy link
@ajoslin

ajoslin Feb 5, 2015

Author Contributor

This always hides option button when scrolling an item away.

Fixed this via e90477c

listCtrl.listView.clearDragEffects();
}

}
};

}
};
});
4 changes: 2 additions & 2 deletions js/angular/directive/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ function($timeout) {
controller: '$ionicList',
compile: function($element, $attr) {
var listEl = jqLite('<div class="list">')
.append( $element.contents() )
.addClass($attr.type);
.append( $element.contents() )
.addClass($attr.type);
$element.append(listEl);

return function($scope, $element, $attrs, ctrls) {
Expand Down
9 changes: 7 additions & 2 deletions js/views/listView.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
var SlideDrag = function(opts) {
this.dragThresholdX = opts.dragThresholdX || 10;
this.el = opts.el;
this.item = opts.item;
this.canSwipe = opts.canSwipe;
};

Expand Down Expand Up @@ -189,7 +190,7 @@
this.dragThresholdY = opts.dragThresholdY || 0;
this.onReorder = opts.onReorder;
this.listEl = opts.listEl;
this.el = opts.el;
this.el = this.item = opts.el;
this.scrollEl = opts.scrollEl;
this.scrollView = opts.scrollView;
// Get the True Top of the list el http://www.quirksmode.org/js/findpos.html
Expand Down Expand Up @@ -546,7 +547,11 @@
// Make sure this is an item with buttons
item = this._getItem(e.target);
if (item && item.querySelector('.item-options')) {
this._dragOp = new SlideDrag({ el: this.el, canSwipe: this.canSwipe });
this._dragOp = new SlideDrag({
el: this.el,
item: item,
canSwipe: this.canSwipe
});
this._dragOp.start(e);
e.preventDefault();
}
Expand Down

0 comments on commit 7fec848

Please sign in to comment.