-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #165 from angular-ui/interpolation
Interpolation
- Loading branch information
Showing
16 changed files
with
181 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,30 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Different Item Heights</title> | ||
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.js"></script> | ||
<script src="../../src/ui-scroll.js"></script> | ||
<script src="differentItemHeights.js"></script> | ||
<link rel="stylesheet" href="../css/style.css" type="text/css"/> | ||
<meta charset="utf-8"> | ||
<title>Different Item Heights</title> | ||
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.1/angular.js"></script> | ||
<script src="../../dist/ui-scroll.js"></script> | ||
<script src="differentItemHeights.js"></script> | ||
<link rel="stylesheet" href="../css/style.css" type="text/css" /> | ||
</head> | ||
<body ng-app="application"> | ||
|
||
<div class="cont cont-global"> | ||
<div class="cont cont-global" ng-controller="MainCtrl"> | ||
|
||
<a class="back" href="../index.html">browse other examples</a> | ||
<a class="back" href="../index.html">browse other examples</a> | ||
|
||
<h1 class="page-header page-header-exapmle">Different Item Heights</h1> | ||
<h1 class="page-header page-header-exapmle">Different Item Heights (Interpolation)</h1> | ||
|
||
<div class="viewport-wrap"> | ||
<div class="viewport " ui-scroll-viewport style="width: 350px; height2: 300px;"> | ||
<div id="dhilt" style="height:0px; overflow: hidden">trololo</div> | ||
<div class="item" ui-scroll="item in datasource" style="height: {{item.height}}px">{{item.text}}</div> | ||
</div> | ||
</div> | ||
<div class="viewport-wrap"> | ||
<div class="viewport " ui-scroll-viewport> | ||
<div ui-scroll="item in datasource" buffer-size="10" adapter="adapter"> | ||
<div class="item" ng-style="{'height': item.height + 'px'}"> | ||
{{"content # " + item.index + ' ' + item.height}} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,44 @@ | ||
angular.module('application', ['ui.scroll']).factory('datasource', [ | ||
'$log', '$timeout', function(console, $timeout) { | ||
var get, max, min; | ||
min = -50; | ||
max = 100; | ||
angular.module('application', ['ui.scroll']) | ||
|
||
get = function(index, count, success) { | ||
$timeout(function() { | ||
.run(function($rootScope) { | ||
$rootScope.doReload = function () { | ||
$rootScope.$broadcast('DO_RELOAD'); | ||
}; | ||
}) | ||
|
||
.controller('MainCtrl', function($scope) { | ||
$scope.hello = 'Hello Main Controller!'; | ||
var counter = 0; | ||
|
||
var reloadListener = $scope.$on('DO_RELOAD', function() { | ||
if ($scope.adapter) { | ||
counter = 0; | ||
$scope.adapter.reload(); | ||
} | ||
}); | ||
|
||
$scope.$on("$destroy", function() { | ||
reloadListener(); | ||
}); | ||
|
||
var min = -1000, max = 1000, delay = 0; | ||
|
||
$scope.datasource = { | ||
get: function(index, count, success) { | ||
setTimeout(function() { | ||
var result = []; | ||
var start = Math.max(min, index); | ||
var end = Math.min(index + count - 1, max); | ||
if (start <= end) { | ||
for (var i = start; i <= end; i++) { | ||
var j = i > 0 ? i : (-1) * i; | ||
result.push({ | ||
text: "item #" + i, | ||
height: 20 + (j%2) * 10 | ||
}); | ||
height = 50 + (counter++ * 2); | ||
result.push({ index: i, height: height }); | ||
} | ||
} | ||
success(result); | ||
}, 50); | ||
}; | ||
console.log('Got ' + result.length + ' items [' + start + '..' + end + ']'); | ||
success(result); | ||
}, delay); | ||
} | ||
}; | ||
|
||
return { | ||
get: get | ||
}; | ||
} | ||
]); | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.