Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: collection repeat still repeating the item #2804

Closed
hasainsab14 opened this issue Dec 23, 2014 · 5 comments
Closed

bug: collection repeat still repeating the item #2804

hasainsab14 opened this issue Dec 23, 2014 · 5 comments

Comments

@hasainsab14
Copy link

Type: bug

Platform: desktop browser

The issue is similar to below one only the difference is am using slidebox instead of delete-button and ion-option-button http://codepen.io/mhartington/pen/pnbiy

@panurge-ws
Copy link

Hi guys,

this happens probably because the directives inside of the ion-item ( like ionDeleteButton ) are requiring the ionList controller, but in collection-repeat the parent is not a ion-list (but another div) so the controller is not passed to the directive. When the item is added to the collection, e.g. after scrolling, the directive can't find the controller and so it doesn't know if it's showing the options button or delete button.
E.g.: directive ionDeleteButton
try to add a console.log of the listCtrl, you will receive always a null value:

  IonicModule
  .directive('ionDeleteButton', function() {
    return {
      restrict: 'E',
      require: ['^ionItem', '^?ionList'],
      //Run before anything else, so we can move it before other directives process
      //its location (eg ngIf relies on the location of the directive in the dom)
      priority: Number.MAX_VALUE,
      compile: function($element, $attr) {
        //Add the classes we need during the compile phase, so that they stay
        //even if something else like ngIf removes the element and re-addss it
        $attr.$set('class', ($attr['class'] || '') + ' button icon button-icon', true);
        return function($scope, $element, $attr, ctrls) {
          var itemCtrl = ctrls[0];
          var listCtrl = ctrls[1];
          var container = jqLite(ITEM_TPL_DELETE_BUTTON);
          container.append($element);
          itemCtrl.$element.append(container).addClass('item-left-editable');
          console.log(listCtrl);
          // listCtrl is always null so the lines below are never executed
          if (listCtrl && listCtrl.showDelete()) {
            container.addClass('visible active');
          }
        };
      }
    };
  });

@panurge-ws
Copy link

The issue on the codepen above seems to happen only on mousewheel event.
A workaround is to add a listener to the ionic.ListView

add:

    window.addEventListener('mousewheel', function(e) {
          _this._lastDragOp && _this._lastDragOp.clean();
      }); 

after:

    window.ionic.onGesture('drag', function(e) {
        _this._handleDrag(e);
      }, this.el);

@ajoslin ajoslin closed this as completed in 7fec848 Feb 5, 2015
@hasainsab14
Copy link
Author

This issue is not fixed for me. even the above codepen example issue exists still. don't know how come its closed.

I have created a exact example here http://codepen.io/anon/pen/LVOMEb if that helps to better understand the issue. any help would greatly help me.

@hasainsab14
Copy link
Author

To add more details to above example. Am using a slide box with 2 slide in a collection repeat.

The issue is if i make a slide 2 on any item active and scroll down, i would see the next items in list at the approx position of the item swiped would be come active.

@hasainsab14
Copy link
Author

could this issue be re-opened or should i create new one?

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Sep 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants