File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed
assets/js/phoenix_live_view Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -43,6 +43,7 @@ export const PHX_MAIN = "data-phx-main";
4343export const PHX_ROOT_ID = "data-phx-root-id" ;
4444export const PHX_VIEWPORT_TOP = "viewport-top" ;
4545export const PHX_VIEWPORT_BOTTOM = "viewport-bottom" ;
46+ export const PHX_VIEWPORT_OVERRUN_TARGET = "viewport-overrun-target" ;
4647export const PHX_TRIGGER_ACTION = "trigger-action" ;
4748export const PHX_HAS_FOCUSED = "phx-has-focused" ;
4849export const FOCUSABLE_INPUTS = [
Original file line number Diff line number Diff line change 33 PHX_LIVE_FILE_UPDATED ,
44 PHX_PREFLIGHTED_REFS ,
55 PHX_UPLOAD_REF ,
6+ PHX_VIEWPORT_OVERRUN_TARGET ,
67} from "./constants" ;
78
89import LiveUploader from "./live_uploader" ;
@@ -218,7 +219,8 @@ Hooks.InfiniteScroll = {
218219 scrollBefore = scrollNow ;
219220 return pendingOp ( ) ;
220221 }
221- const rect = this . el . getBoundingClientRect ( ) ;
222+
223+ const rect = this . findOverrunTarget ( ) ;
222224 const topEvent = this . el . getAttribute (
223225 this . liveSocket . binding ( "viewport-top" ) ,
224226 ) ;
@@ -293,5 +295,23 @@ Hooks.InfiniteScroll = {
293295 }
294296 } ;
295297 } ,
298+
299+ findOverrunTarget ( ) {
300+ let rect ;
301+ const overrunTarget = this . el . getAttribute (
302+ this . liveSocket . binding ( PHX_VIEWPORT_OVERRUN_TARGET ) ,
303+ ) ;
304+ if ( overrunTarget ) {
305+ const overrunEl = document . getElementById ( overrunTarget ) ;
306+ if ( overrunEl ) {
307+ rect = overrunEl . getBoundingClientRect ( ) ;
308+ } else {
309+ throw new Error ( "did not find element with id " + overrunTarget ) ;
310+ }
311+ } else {
312+ rect = this . el . getBoundingClientRect ( ) ;
313+ }
314+ return rect ;
315+ } ,
296316} ;
297317export default Hooks ;
You can’t perform that action at this time.
0 commit comments