Skip to content
This repository has been archived by the owner on Sep 20, 2023. It is now read-only.

Commit

Permalink
fixed scroll issues
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarotero committed Jul 3, 2017
1 parent 3501032 commit c294231
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### Changed

* Do not filter the suggestions in ajaxSource, it's supossed to be filtered by the server.
* Do not filter the suggestions in ajaxSource, it's supossed to be filtered by the server.

### Fixed

Expand Down
8 changes: 8 additions & 0 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
color: blue;
font-weight: bold;
}
.block {
background: gray;
height: 100vh;
}
</style>

<body>
Expand Down Expand Up @@ -64,6 +68,10 @@
<button type="submit">Send</button>
</form>

<div class="block">

</div>

<script type="text/javascript" src="script.dist.js"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion src/Suggestion.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default class Suggestion {
this.element.classList.add('is-selected');

if (parentRect.top - rect.top > 0) {
this.element.scrollIntoView(true);
parent.scrollTop -= parentRect.top - rect.top;
} else if (parentRect.bottom < rect.bottom) {
this.element.scrollIntoView(false);
}
Expand Down
6 changes: 4 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,18 @@ export class Suggestions {

switch (code) {
case 'ArrowDown':
event.preventDefault();

if (!this.source.isClosed) {
this.source.selectNext();
event.preventDefault();
}
break;

case 'ArrowUp':
event.preventDefault();

if (!this.source.isClosed) {
this.source.selectPrevious();
event.preventDefault();
}
break;

Expand Down

0 comments on commit c294231

Please sign in to comment.