-
Notifications
You must be signed in to change notification settings - Fork 0
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 #1908 from laws-africa/offcanvas
Offcanvas filters for document listing
- Loading branch information
Showing
7 changed files
with
132 additions
and
320 deletions.
There are no files selected for viewing
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
export default class DocumentFilterForm { | ||
public root: HTMLElement; | ||
public offCanvasUsed: boolean = false; | ||
|
||
constructor (root: HTMLElement) { | ||
this.root = root; | ||
|
||
// setup a resize observer to move the filters when the window is resized | ||
const observer = new ResizeObserver(() => this.moveFilters()); | ||
observer.observe(this.root); | ||
this.moveFilters(); | ||
} | ||
|
||
moveFilters () { | ||
// on small displays, move the filters into the offcanvas element | ||
if (window.innerWidth < 992) { | ||
this.moveFiltersToOffcanvas(); | ||
} else { | ||
this.moveFiltersToMainContent(); | ||
} | ||
} | ||
|
||
moveFiltersToOffcanvas () { | ||
if (!this.offCanvasUsed) { | ||
const offcanvas = this.root.querySelector('.offcanvas-body'); | ||
const content = this.root.querySelector('.document-list-facets'); | ||
if (offcanvas && content) { | ||
requestAnimationFrame(() => { | ||
offcanvas.appendChild(content); | ||
this.offCanvasUsed = true; | ||
}); | ||
} | ||
} | ||
} | ||
|
||
moveFiltersToMainContent () { | ||
if (this.offCanvasUsed) { | ||
const wrapper = this.root.querySelector('.document-list-facets-wrapper'); | ||
const content = this.root.querySelector('.document-list-facets'); | ||
if (wrapper && content) { | ||
requestAnimationFrame(() => { | ||
wrapper.appendChild(content); | ||
this.offCanvasUsed = false; | ||
}); | ||
} | ||
} | ||
} | ||
} |
This file was deleted.
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
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.