ionic-framework icon indicating copy to clipboard operation
ionic-framework copied to clipboard

bug: jQuery kills scroll momentum in collection-repeat

Open zapatek opened this issue 12 years ago • 14 comments

Type: bug

Platform: all

Adding jQuery kills the scroll momentum in collection-repeat. Can be observed on desktop, too:

http://codepen.io/zapatek/pen/hnatq

Here is the working version with only jQuery link removed: http://codepen.io/zapatek/pen/dxyLe

zapatek avatar Sep 26 '14 09:09 zapatek

+1. Same problem here. Removing the jQuery dependency makes the scroll work smoothly.

codeback avatar Sep 26 '14 16:09 codeback

I'm having this problem as well. I wonder if the people in issue #2265 are also including jQuery?

jbasinger avatar Sep 29 '14 15:09 jbasinger

I'm hitting this issue, and can confirm that I am including jQuery.

mikeacook avatar Sep 29 '14 17:09 mikeacook

Had the same exact issue. Was tearing my hair out.. I can get rid of jQuery, but would be nice to get this fixed.

tuomastanner avatar Oct 01 '14 13:10 tuomastanner

+1. When using jQuery this line in collectionRepeatdirective makes the issue appears.

scrollCtrl.$element.on('scroll.resize', rerenderOnResize);

rdelafuente avatar Oct 04 '14 21:10 rdelafuente

Well, it set our planning back for a good part of a week, but we removed all jQuery, upgraded to beta 13 and now everything (and I mean everything) is a whole lot faster.

crooy avatar Oct 09 '14 12:10 crooy

We're in the process of doing the same thing @crooy We were just using jQuery for animations mostly so we switched to using CSS transitions and everything seems an order of magnitude faster. I wonder, is jQuery overloading some common method in jqLite that is slowing it down universally?

jbasinger avatar Oct 09 '14 12:10 jbasinger

Me too. Using ng-repeat is ok. Lost inertia when using collection-repeat

haibtdt avatar Nov 06 '14 08:11 haibtdt

Note, this is only with jQuery 2.x, 1.x works fine. Looking in to it...

A note regarding performance and jQuery: It's not. It leaks memory quite a bit, and animations aren't performant. Still, it's a pretty universal library and we should fix this.

perrygovier avatar Nov 19 '14 16:11 perrygovier

@perrygovier Actually the problem is there from jQuery version 1.7.0 onwards. Please see the updated codepen:

http://codepen.io/zapatek/pen/hnatq

Unfortunately, as of beta-14 this is still not fixed. I guess it would be safe to caution other users that ionic framework still does not play well with jQuery.

zapatek avatar Dec 19 '14 08:12 zapatek

+1 on beta-14 with jQuery 1.11

rickyk586 avatar Dec 30 '14 01:12 rickyk586

@rdelafuente is right about it being that line:

scrollCtrl.$element.on('scroll.resize', rerenderOnResize);

jQuery sees that as "on every scroll event" but jqLite does not since its on() method does not support namespacing https://docs.angularjs.org/api/ng/function/angular.element

A fix is to change "scroll.resize" to "scroll-resize" on that line, and also add that event to the resize function in the $ionicScroll controller:

self.resize = function() {
    return $timeout(resize).then(function() {
      $element && $element.triggerHandler('scroll.resize scroll-resize');
    });
  };

The best solution going forward would most likely be removing all namespaced events in the Ionic Framework.

rickyk586 avatar Dec 30 '14 05:12 rickyk586

I'll be digging in to this one. Note that #2265 may be related to this issue.

perrygovier avatar Jan 02 '15 22:01 perrygovier

Working in nightly builds with the collection-repeat refactor: http://codepen.io/ionic/pen/YPvWBr

ajoslin avatar Feb 26 '15 18:02 ajoslin