get scrolling to work better

This commit is contained in:
Colin Frei 2013-08-13 18:23:01 +02:00
parent 6f0478bb25
commit d9229bbd18
3 changed files with 29 additions and 12 deletions

View file

@ -169,7 +169,7 @@ body, .normalFont {
float: right; float: right;
} }
#queueList, #scroller { #queueList, #scroller, #feedList {
height: 100%; height: 100%;
} }

View file

@ -1,5 +1,5 @@
angular.module('podcast.directives', []) angular.module('podcast.directives', [])
.directive('pullToRefresh', function() { .directive('pullToRefresh', ['$timeout', function($timeout) {
return function(scope, element, attrs, feedItems) { return function(scope, element, attrs, feedItems) {
var myScroll, var myScroll,
pullDownEl, pullDownOffset, pullDownEl, pullDownOffset,
@ -54,11 +54,15 @@ angular.module('podcast.directives', [])
scope.$watch( scope.$watch(
function() { return scope.queue; }, function() { return scope.queue; },
function() { myScroll.refresh(); }, function() {
$timeout(function() {
myScroll.refresh();
}, 5);
},
true true
); );
} }
}) }])
.directive('hold', ['$timeout', function($timeout) { .directive('hold', ['$timeout', function($timeout) {
return function(scope, element, attrs) { return function(scope, element, attrs) {
var startTime, moved, holdTimer = false; var startTime, moved, holdTimer = false;
@ -84,8 +88,19 @@ angular.module('podcast.directives', [])
} }
}]) }])
.directive('scroll', function() { .directive('scroll', function() {
return function(scope, element, attrs, feedItems) { return {
var scroll = new iScroll(element[0], {vScrollbar: false}); priority: -1000,
compile: function compile(tElement, tAttrs) {
return function postLink(scope, element, attrs, feedItems) {
//TODO: this should probably work somehow without setting a timeout
// - need to be able to set the order of watchers?
setTimeout(function() {
console.log('bla');
console.log(element[0]);
var scroll = new iScroll(element[0], {vScrollbar: false});
}, 500);
}
}
}; };
}) })
.directive('blob', function() { .directive('blob', function() {

View file

@ -1,9 +1,11 @@
<div> <div id="feedList" scroll>
<form ng-submit="addFeed()"> <div>
<input type="text" class="newFeedField" ng-model="newFeedUrl" placeholder="Add Feed" ng-blur="removePrefillIfNecessary()" ng-focus="preFillField()" /><input type="submit" value="Add" /> <form ng-submit="addFeed()">
</form> <input type="text" class="newFeedField" ng-model="newFeedUrl" placeholder="Add Feed" ng-blur="removePrefillIfNecessary()" ng-focus="preFillField()" /><input type="submit" value="Add" />
</form>
<div ng-repeat="feed in feeds | orderBy:'title'" class="listItem" ng-click="goToFeed(feed.id)"> <div ng-repeat="feed in feeds | orderBy:'title'" class="listItem" ng-click="goToFeed(feed.id)">
<img blob="feed.image" class="feedImageThumbnail" /> <span class="listItemTitle">{{feed.title}}</span> <img blob="feed.image" class="feedImageThumbnail" /> <span class="listItemTitle">{{ feed.title }}</span>
</div>
</div> </div>
</div> </div>