File tree Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -857,6 +857,52 @@ const Hooks = {
857857 // }
858858 // },
859859 } ,
860+ LoadFromHash : {
861+ mounted ( ) {
862+ const hash = window . location . hash . substring ( 1 ) ;
863+ if ( hash ) {
864+ try {
865+ const data = JSON . parse ( decodeURIComponent ( atob ( hash ) ) ) ;
866+ this . pushEvent ( "hash_load_success" , data ) ;
867+ } catch ( error ) {
868+ this . pushEvent ( "hash_load_failure" , { error : error . message } ) ;
869+ }
870+ }
871+
872+ this . handleEvent ( "close-window" , ( { delay } ) => {
873+ setTimeout ( ( ) => {
874+ window . close ( ) ;
875+ } , delay || 0 ) ;
876+ } ) ;
877+ } ,
878+ } ,
879+ LazyLoadImage : {
880+ mounted ( ) {
881+ const container = this . el ;
882+ const img = container . querySelector ( "img" ) ;
883+
884+ if ( ! img ) return ;
885+
886+ const dataSrc = img . getAttribute ( "data-src" ) ;
887+ if ( ! dataSrc ) return ;
888+
889+ // Find the parent link element to listen for hover
890+ const trigger = container . closest ( ".group" ) ;
891+ if ( ! trigger ) return ;
892+
893+ let hasLoaded = false ;
894+
895+ const loadImage = ( ) => {
896+ console . log ( "loading image" , dataSrc ) ;
897+ if ( hasLoaded ) return ;
898+ hasLoaded = true ;
899+ img . src = dataSrc ;
900+ img . classList . remove ( "invisible" ) ;
901+ } ;
902+
903+ trigger . addEventListener ( "mouseenter" , loadImage ) ;
904+ } ,
905+ } ,
860906} satisfies Record < string , Partial < ViewHook > & Record < string , unknown > > ;
861907
862908// Accessible focus handling
You can’t perform that action at this time.
0 commit comments