mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
feat(list): reordering scrolls page, reordering performance better
Fixes #521. Reordering now uses webkitTransform instead of element.style.left. Additionally, as you drag the drag-element to the top or bottom of the scroll-area, it will scroll it up or down as allowed. Refactors necessary: Common code from `<content>` and `<scroll>` moved into js/ext/angular/controllers/ionicScrollController. Then `<content>` and `<scroll>` expose the controller, and `<list>` can require it. `<list>` then uses the controller (if exists) to pass the scrollView and scrollEl to ReorderDrag, and ReorderDrag uses that to scroll. Additionally, js/ext/angular/test/controller/ionicScrollController tests much functionality that was untested before.
This commit is contained in:
44
js/ext/angular/src/controller/ionicScrollController.js
vendored
Normal file
44
js/ext/angular/src/controller/ionicScrollController.js
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
angular.module('ionic.ui.scroll')
|
||||
|
||||
.controller('$ionicScroll', ['$scope', 'scrollViewOptions', '$timeout',
|
||||
function($scope, scrollViewOptions, $timeout) {
|
||||
|
||||
scrollViewOptions.bouncing = angular.isDefined(scrollViewOptions.bouncing) ?
|
||||
scrollViewOptions.bouncing :
|
||||
!ionic.Platform.isAndroid();
|
||||
|
||||
var element = this.element = scrollViewOptions.el;
|
||||
var refresher = this.refresher = element.querySelector('.scroll-refresher');
|
||||
var scrollView = this.scrollView = new ionic.views.Scroll(scrollViewOptions);
|
||||
|
||||
this.$element = angular.element(element);
|
||||
|
||||
//Attach self to element as a controller so other directives can require this controller
|
||||
//through `require: '$ionicScroll'
|
||||
this.$element.data('$$ionicScrollController', this);
|
||||
|
||||
$timeout(function() {
|
||||
scrollView.run();
|
||||
|
||||
// Activate pull-to-refresh
|
||||
if(refresher) {
|
||||
var refresherHeight = refresher.clientHeight || 0;
|
||||
scrollView.activatePullToRefresh(refresherHeight, function() {
|
||||
refresher.classList.add('active');
|
||||
}, function() {
|
||||
refresher.classList.remove('refreshing');
|
||||
refresher.classList.remove('active');
|
||||
}, function() {
|
||||
refresher.classList.add('refreshing');
|
||||
$scope.onRefresh && $scope.onRefresh();
|
||||
$scope.$parent.$broadcast('scroll.onRefresh');
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}]);
|
||||
|
||||
})();
|
||||
Reference in New Issue
Block a user