Skip to content
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

remember scroll offset when returning to root in folder view #384

Merged
merged 7 commits into from
Mar 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 4 additions & 36 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,46 +1,14 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.
/node_modules

# compiled output
/dist
/release
/tmp
/out-tsc
/app-builds
main.js
main-extract.js
main-filenames.js
main-globals.js
main-rescan.js
main-support.js
utility.js
src/**/*.js
*.js.map

# TS to JS
/interfaces/*.js

# dependencies
/node_modules

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

# misc
npm-debug.log
*.js
*.js.map
*.log

# System Files
.DS_Store
Thumbs.db
3 changes: 1 addition & 2 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{
"recommendations": [
"angular.ng-template",
"Angular.ng-template",
"coenraads.bracket-pair-colorizer",
"editorconfig.editorconfig",
"ms-vscode.vscode-typescript-tslint-plugin",
"shinnn.stylelint",
]
}
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"files.exclude": {
"*.js": true,
"**/*.js": true,
"**/dist": true,
"**/node_modules": true,
"**/release": true,
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2019 Boris
Copyright (c) 2020 Boris

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
8 changes: 4 additions & 4 deletions README.br.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ As principais dependências utilizadas:

| Library | Version | Date | Comment |
| ------- | ------- | ---- | ------- |
| Angular | v8.2.3 | August 2019 | |
| Angular-CLI | v8.2.3 | August 2019 | |
| Electron | v6.0.6 | August 2019 | (internally uses Node v12.4.0 and Chromium 76) |
| Electron Builder | v21.2.0 | August 2019 | |
| Angular | v9.0.1 | February 2020 | |
| Angular-CLI | v9.0.2 | February 2020 | |
| Electron | v8.0.1 | February 2020 | (internally uses Node v12.13.0 and Chromium 80) |
| Electron Builder | v22.3.2 | February 2020 | |

O programa funcionar com as últimas versões do Node e NPM (Junho de 2019). Note que você vai precisar instalar o [Angular CLI](https://cli.angular.io) para rodar o projeto (`npm install -g @angular/cli`).

Expand Down
7 changes: 1 addition & 6 deletions electron-builder.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
{
"productName": "Video Hub App 2",
"appId": "com.videohubapp.videohubapp2",
"copyright": "Copyright © 2019 Boris Yakubchik",
"copyright": "Copyright © 2020 Boris Yakubchik",
"directories": {
"output": "release/"
},
"files": [
"**/*",
"!**/*.ts",
"!*.code-workspace",
"!LICENSE.md",
"!package.json",
"!package-lock.json",
"!src/",
"!e2e/",
"!hooks/",
"!angular.json",
"!_config.yml",
"!karma.conf.js",
"!tsconfig.json",
"!tslint.json"
],
Expand Down
8 changes: 4 additions & 4 deletions src/app/common/colors.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
export enum Colors {
autoFileTags = '#a8bffb',
autoFolderTags = '#fec02f',
manualTags = '#63ff61',
manualTags = '#f1ceb8', // same as `manual-tag-color` (see variables.scss)
// don't alphabetize below
// this is the order in which filters appear
folderUnion = '#FFD672',
folderIntersection = '#ffe5a5',
fileUnion = '#6e96ff',
fileUnion = '#97b3fc', // like `fileIntersection` but darker
fileIntersection = '#b1c6fd',
exclude = '#FF8888',
tagUnion = '#6e96ff',
tagIntersection = '#b1c6fd',
tagUnion = '#ecbb9d', // like `tagIntersection` but darker
tagIntersection = '#f1ceb8', // same as `manual-tag-color` (see variables.scss)
tagExclusion = '#FF8888',
}
2 changes: 1 addition & 1 deletion src/app/components/home.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@
class="breadcrumbs"
@breadcrumbsAppear
>
<app-icon class="breadcrumb-folder-icon" [icon]="'icon-folder-blank'" (click)="folderViewNavigationPath = ''"></app-icon>
<app-icon class="breadcrumb-folder-icon" [icon]="'icon-folder-blank'" (click)="breadcrumbHomeIconClick()"></app-icon>
<span
*ngFor="let item of folderViewNavigationPath.split('/'); index as idx"
(click)="handleBbreadcrumbClicked(idx)"
Expand Down
37 changes: 35 additions & 2 deletions src/app/components/home.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,9 @@ export class HomeComponent implements OnInit, AfterViewInit {

deletePipeHack: boolean = false; // to force deletePipe to update

// crappy hack to remember where to navigate to when in folder view and returning back to root
folderNavigationScrollOffset: number = 0;

// ========================================================================
// Please add new variables below if they don't fit into any other section
// ------------------------------------------------------------------------
Expand Down Expand Up @@ -1081,12 +1084,17 @@ export class HomeComponent implements OnInit, AfterViewInit {
}

/**
* Handle clicking on FOLDER in gallery, or the folder icon in breadcrumbs
* Handle clicking on FOLDER in gallery, or the folder icon in breadcrumbs, or the `UP` folder
* @param filter
*/
handleFolderIconClicked(filter: string): void {
if (this.folderNavigationScrollOffset === 0) {
this.folderNavigationScrollOffset = this.virtualScroller.viewPortInfo.scrollStartPosition;
}

this.folderViewNavigationPath = filter;
this.scrollToTop();

this.scrollAppropriately(filter);
}

/**
Expand All @@ -1098,6 +1106,31 @@ export class HomeComponent implements OnInit, AfterViewInit {
this.scrollToTop();
}

/**
* Scroll appropriately after navigating back to root folder
*
* Rather hacky thing, but works in the basic case
* Fails if user enters folder, changes some search or sort filter, and navigates back
*/
scrollAppropriately(filter: string) {
if (filter === '') {
// TODO -- change `1` to `0` once the bug is fixed:
// https://github.com/rintoj/ngx-virtual-scroller/issues/420
this.virtualScroller.scrollToPosition(this.folderNavigationScrollOffset, 1);
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will need to change this to 0 once the bug is fixed:
rintoj/ngx-virtual-scroller#420

this.folderNavigationScrollOffset = 0;
} else {
this.scrollToTop();
}
}

/**
* Go back to root and scroll to last-seen location
*/
breadcrumbHomeIconClick(): void {
this.folderViewNavigationPath = '';
this.scrollAppropriately('');
}

/**
* Open folder that contains the (current) clicked file
*/
Expand Down