Visualizzazione dei risultati da 1 a 5 su 5

Visualizzazione discussione

  1. #2
    Utente di HTML.it L'avatar di U235
    Registrato dal
    Mar 2006
    Messaggi
    1,539
    Ciao,
    usa IntersectionObserver al posto dello scroll:

    codice:
    var observer = new IntersectionObserver(onIntersection, {
                    root: null,
                    threshold: .75
                })
                function onIntersection(entries, opts) {
                    entries.forEach(entry => {
                        if (entry.isIntersecting === true) {
                            entry.target.children[0].classList.add('in');
                        }
                        else {
                            entry.target.children[0].classList.remove('in');
                        }
                    });
                }
                var arr = document.querySelectorAll('.box');
                arr.forEach(el => {
                    observer.observe(el);
                });
    css:
    codice:
           .box {
                visibility: hidden;
                height:100px;
            }
            .in {
                visibility: visible;
                position: absolute;
                top:inherit;
                -webkit-animation-name: run;
                -webkit-animation-duration: 5s;
            }
            @-webkit-keyframes run {
                0% {
                    left: 100%;
                }
                100% {
                    left: 0;
                }
            }
    html:
    codice:
    <div class="box">
                <img src="https://www.html.it/app/themes/htmlit/assets/logo/html_logo.svg" width=100 height=100>
            </div>
    Funziona anche con il ridimensionamento della finestra.
    Qui un esempio.

    EDIT:
    Ho letto bene dopo... questo funziona solo con browser moderni
    Ultima modifica di U235; 18-07-2022 a 19:55

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.