-
Notifications
You must be signed in to change notification settings - Fork 107
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
Fixed row height optimization #221
Open
dhilt
wants to merge
20
commits into
angular-ui:fixed-height-optimization
Choose a base branch
from
priandsf:Added-static-row-height
base: fixed-height-optimization
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
61cb0cc
Added a row height parameter
priandsf bedd378
Made $digest optional in processUpdates() when the row height is fixed
priandsf 71c2f33
fixedRowHeight demo
dhilt 8f4bece
release processUpdates
dhilt 551bff3
Separated visbiility watch & row height. Added "allow-visibility-watc…
priandsf 43561dd
Looks like the source was not properly commited - changed ui-scroll
priandsf d183273
jquery load demo
dhilt 62c8bc6
v1.7.4 release
dhilt fdcca3d
v1.7.4 build
dhilt b1be940
Fix the outerHeight calculation in buffer when rowHeight is provided
priandsf 45a8387
Merge branch 'master' of github.com:angular-ui/ui-scroll into Added-s…
priandsf 95a6d4a
Reverted bad commit on demo/fixedRowHeight for test purposes
priandsf 359d905
fix lodash dependency vulnerability
dhilt b174ffc
gh-pages auto deploy
dhilt 0b62060
travis.iml updates
dhilt bbc1a74
Added unbindEvent() to reload.
priandsf dd3bdfc
Support for row-height
priandsf 3cff84e
Merge branch 'master' into Added-static-row-height
priandsf 07e7047
compiled files
priandsf 9c26d38
Latest code dealing with row height.
priandsf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<!doctype html> | ||
<html> | ||
|
||
<head> | ||
<meta charset="utf-8"> | ||
<title>Fixed Row Height</title> | ||
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.1/angular.js"></script> | ||
<script src="../../dist/ui-scroll.js"></script> | ||
<script src="fixedRowHeight.js"></script> | ||
<link rel="stylesheet" href="../css/style.css" type="text/css" /> | ||
</head> | ||
|
||
<body ng-app="application"> | ||
|
||
<div class="cont cont-global" ng-controller="MainCtrl"> | ||
|
||
<a class="back" href="../index.html">browse other examples</a> | ||
|
||
<h1 class="page-header page-header-exapmle">Fixed Row Height</h1> | ||
|
||
<div class="description"> | ||
<p> | ||
If the height of all the viewport rows is known and not going to be changed, | ||
it might be passed as "row-height" attribute. | ||
This reduces inner calculations and browser reflows, | ||
which leads to a performance increase. | ||
</p> | ||
</div> | ||
|
||
<div class="actions"> | ||
<input ng-model="perfSlowCount" size="4" /> performance decrease coefficient (0 - fastest) | ||
</div> | ||
|
||
<div class="viewport" ui-scroll-viewport> | ||
<div ui-scroll="item in datasource" buffer-size="10" row-height="25" allow-visibility-watch="false" adapter="adapter"> | ||
<div class="item" ng-style="{'height': '25px'}"> | ||
|
||
{{item.text}} | ||
<span ng-repeat="(key, value) in item.input track by $index"> | ||
<input ng-model="value.value" size="2" /> | ||
</span> | ||
{{getSum(item)}} | ||
{{getMul(item)}} | ||
{{getText(item)}} | ||
|
||
<span ng-repeat="(key, value) in perfSlowCountList track by $index"> | ||
<div style="height: 1px; width: 1px; overflow: hidden;"> | ||
{{item.text}} | ||
<span ng-repeat="(key, value) in item.input track by $index"> | ||
<input ng-model="value.value" size="2" /> | ||
</span> | ||
{{getSum(item)}} | ||
{{getMul(item)}} | ||
{{getText(item)}} | ||
</div> | ||
</span> | ||
|
||
</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 |
---|---|---|
@@ -0,0 +1,74 @@ | ||
angular.module('application', ['ui.scroll']) | ||
|
||
.controller('MainCtrl', ($scope) => { | ||
$scope.hello = 'Hello Main Controller!'; | ||
|
||
let min = -150, max = 200, delay = 0, inputs = 10; | ||
|
||
const getInput = index => { | ||
const result = []; | ||
for (let i = 0; i < inputs; i++) { | ||
result.push({ value: ((index % 2 === 0 ? -1 : 1) * (i + 1)).toString() }); | ||
} | ||
return result; | ||
} | ||
|
||
const data = []; | ||
for (let i = min; i <= max; i++) { | ||
height = 50 + (i + 1); | ||
data.push({ | ||
index: i, | ||
text: 'item #' + i, | ||
input: getInput(i) | ||
}); | ||
} | ||
|
||
$scope.datasource = { | ||
get: (index, count, success) => { | ||
console.log('Getting ' + count + ' items started from ' + index + '...'); | ||
setTimeout(() => { | ||
const result = []; | ||
const start = Math.max(min, index); | ||
const end = Math.min(index + count - 1, max); | ||
if (start <= end) { | ||
for (let i = start; i <= end; i++) { | ||
const _item = data.find(item => item.index === i); | ||
if (_item) { | ||
result.push(_item); | ||
} | ||
} | ||
} | ||
console.log('Got ' + result.length + ' items [' + start + '..' + end + ']'); | ||
success(result); | ||
}, delay); | ||
} | ||
}; | ||
|
||
$scope.getSum = item => | ||
item.input.reduce((a, i) => a + Number(i.value), 0); | ||
|
||
$scope.getMul = item => | ||
item.input.reduce((a, i) => a * Number(i.value), 1); | ||
|
||
$scope.getText = item => { | ||
const num = $scope.getMul(item).toString(); | ||
const result = []; | ||
for (let i = 0; i < item.text.length; i++) { | ||
result.push(item.text[i]); | ||
result.push(i < num.length ? num[i] : 'x'); | ||
} | ||
return result.join(''); | ||
} | ||
|
||
const perfSlowCountDefault = 2; | ||
$scope.perfSlowCount = perfSlowCountDefault; | ||
$scope.perfSlowCountList = []; | ||
$scope.$watch('perfSlowCount', () => { | ||
let size = Number($scope.perfSlowCount); | ||
if (isNaN(size)) { | ||
size = perfSlowCountDefault; | ||
} | ||
$scope.perfSlowCountList = (new Array(size)).fill(0); | ||
}) | ||
|
||
}); |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added demo, after
npm start
it is available ashttp://localhost:5005/fixedRowHeight/fixedRowHeight.html