git ssb

10+

Matt McKegg / patchwork



Commit f51b630f45cbadef6273df197f1bbeecd968edb0

don't show preview if there is no room on screen

Matt McKegg committed on 10/17/2017, 1:06:36 AM
Parent: 19bf91406114f251a3218b5c45c4a69e95d11f84

Files changed

main-window.jschanged
main-window.jsView
@@ -149,19 +149,26 @@
149149 }
150150
151151 if (preview) {
152152 var rect = element.getBoundingClientRect()
153- var maxLeft = window.innerWidth - 510
153+ var width = 510
154+ var maxLeft = window.innerWidth - width
154155 var maxTop = window.innerHeight - 100
155156 var distanceFromRight = window.innerWidth - rect.right
156157 var shouldDisplayBeside = rect.bottom > maxTop || rect.left < 100 || distanceFromRight < 100
157158
158159 if (shouldDisplayBeside && rect.bottom > 50) {
159- preview.style.top = `${Math.min(rect.top, maxTop)}px`
160- if (rect.right > maxLeft) {
161- preview.style.left = `${rect.left - 510}px`
160+ if (rect.right > maxLeft && (rect.left - width) < 0) {
161+ // no room, just give up!
162+ previewElement.set(null)
163+ return
162164 } else {
163- preview.style.left = `${rect.right + 5}px`
165+ preview.style.top = `${Math.min(rect.top, maxTop)}px`
166+ if (rect.right > maxLeft) {
167+ preview.style.left = `${rect.left - width}px`
168+ } else {
169+ preview.style.left = `${rect.right + 5}px`
170+ }
164171 }
165172 } else {
166173 preview.style.top = `${rect.bottom + 5}px`
167174 preview.style.left = `${Math.min(rect.left, maxLeft)}px`

Built with git-ssb-web