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

Changed the JQuery detection #222

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/ui-scroll-grid.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 14 additions & 5 deletions dist/ui-scroll.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/ui-scroll.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/ui-scroll.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/ui-scroll.min.js.map

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions src/modules/adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ class Adapter {
}

generatePublicContext() {
this.hasPublicAttr = false;

// these methods will be accessible out of ui-scroll via user defined adapter
const publicMethods = ['reload', 'applyUpdates', 'append', 'prepend', 'isBOF', 'isEOF', 'isEmpty'];
for (let i = publicMethods.length - 1; i >= 0; i--) {
Expand All @@ -62,6 +64,7 @@ class Adapter {
}
}
});
if(attr) this.hasPublicAttr = true;
}

// non-read-only public property
Expand Down
11 changes: 9 additions & 2 deletions src/ui-scroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ angular.module('ui.scroll', [])

.constant('JQLiteExtras', JQLiteExtras)
.run(['JQLiteExtras', (JQLiteExtras) => {
!window.jQuery ? (new JQLiteExtras()).registerFor(angular.element) : null;
!(angular.element.fn && angular.element.fn.jquery) ? new JQLiteExtras().registerFor(angular.element) : null;
ElementRoutines.addCSSRules();
}])

Expand Down Expand Up @@ -95,6 +95,11 @@ angular.module('ui.scroll', [])
const viewport = new Viewport(elementRoutines, buffer, element, viewportController, $rootScope, padding);
const adapter = new Adapter($scope, $parse, $attr, viewport, buffer, doAdjust, reload);

// See https://github.com/angular-ui/ui-scroll/pull/221
// We need to run $digest on a scroll event to set the desired position properties, if desired by the user
// Note that the use of these properties is not advised, and a developer should prefer the adapter one
const forceDigestOnScroll = adapter.hasPublicAttr;

if (viewportController) {
viewportController.adapter = adapter;
}
Expand Down Expand Up @@ -492,7 +497,9 @@ angular.module('ui.scroll', [])
unbindEvents();
} else {
adapter.calculateProperties();
!$scope.$$phase && $scope.$digest();
if(forceDigestOnScroll) {
!$scope.$$phase && $scope.$digest();
}
}
}
}
Expand Down