Skip to content

Commit

Permalink
fix: positioning and scrollbar in singe file share
Browse files Browse the repository at this point in the history
* Only hide the scrollbar when showing the modal.
* Inherit max width and height from element for the viewer.
* Replace element with viewer rather than inserting the viewer in it.

Signed-off-by: Max <[email protected]>
  • Loading branch information
max-nextcloud committed Jul 25, 2022
1 parent 3ce6892 commit 9b3bdc4
Show file tree
Hide file tree
Showing 4 changed files with 75,673 additions and 6 deletions.
75,668 changes: 75,665 additions & 3 deletions js/viewer-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/viewer-main.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/services/Viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export default class Viewer {
this._state = {}
this._state.file = ''
this._state.files = []
this._state.el = null
this._state.loadMore = () => ([])
this._state.onPrev = () => {}
this._state.onNext = () => {}
Expand Down
8 changes: 6 additions & 2 deletions src/views/Viewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,9 @@ export default {
if (element) {
const el = document.querySelector(element)
if (el) {
el.appendChild(viewerRoot)
viewerRoot.style.maxWidth = el.style.maxWidth
viewerRoot.style.maxHeight = el.style.maxHeight
el.replaceWith(viewerRoot)
} else {
logger.warn('Could not find element ', { element })
}
Expand Down Expand Up @@ -406,7 +408,9 @@ export default {
const [dirPath, fileName] = extractFilePaths(path)

// prevent scrolling while opened
document.body.style.overflow = 'hidden'
if (!this.el) {
document.body.style.overflow = 'hidden'
}

// swap title with original one
const title = document.getElementsByTagName('head')[0].getElementsByTagName('title')[0]
Expand Down

0 comments on commit 9b3bdc4

Please sign in to comment.