mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
fix(ionItem): properly hide option buttons on scroll in collection-repeat
Closes #1811. Closes #2804.
This commit is contained in:
45
js/angular/directive/item.js
vendored
45
js/angular/directive/item.js
vendored
@@ -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) {
|
||||
listCtrl.listView.clearDragEffects();
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
4
js/angular/directive/list.js
vendored
4
js/angular/directive/list.js
vendored
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user