Skip to content
Snippets Groups Projects
Select Git revision
  • d94b20b5fc93034cced006571e15a5ca9d2f6ee8
  • dev default protected
  • renovate/cozy-realtime-5.x
  • renovate/devdependencies-(non-major)
  • renovate/copy-webpack-plugin-13.x
  • renovate/major-react-monorepo
  • renovate/couchdb-3.x
  • renovate/cozy-device-helper-3.x
  • renovate/cozy-flags-4.x
  • renovate/eslint-config-prettier-10.x
  • renovate/major-react-router-monorepo
  • renovate/major-typescript-eslint-monorepo
  • renovate/sass-loader-16.x
  • renovate/eslint-plugin-testing-library-7.x
  • renovate/cozy-scripts-8.x
  • renovate/cozy-harvest-lib-9.x
  • renovate/cozy-client-49.x
  • build-test protected
  • build-dev protected
  • lint/testing-libraby-plugin
  • build protected
  • v3.1.1
  • v3.1.0
  • v3.0.0
  • v2.8.0
  • v2.7.2
  • v2.7.1
  • v2.7.0
  • v2.6.0
  • v2.5.1
  • v2.5.0
  • v2.4.0
  • v2.3.1
  • v2.3.0
  • v2.2.2
  • v2.2.1
  • v2.2.0
  • v2.1.1
  • v2.1.0
  • v2.0.2
  • v2.0.1
41 results

app.config.environment.alpha.js

Blame
  • scroller.js 1.40 KiB
    export function scrollInit(divName) {
      let scroller = new Scroller(divName);
      return scroller;
    }
    
    class Scroller {
      constructor(divName) {
        this.elmnt = document.getElementById(divName);
        this.reachedMaxScroll = false;
    
        this.elmnt.scrollTop = 0;
        this.previousScrollTop = 0;
    
        this.scrollDiv();
        this.elmnt.addEventListener("mouseover", () => {
          if (this.autoScroll) this.pauseScroll();
        });
        this.elmnt.addEventListener("mouseout", () => {
          if (this.autoScroll) this.resumeScroll();
        });
        this.autoScroll = true;
      }
    
      scrollDiv() {
        if (!this.reachedMaxScroll) {
          this.elmnt.scrollBy({ top: 5, left: 0, behavior: "smooth" });
          this.reachedMaxScroll =
            this.elmnt.scrollTop >=
            this.elmnt.scrollHeight - this.elmnt.offsetHeight;
          this.scrollTimeout = setTimeout(() => {
            this.scrollDiv();
          }, 100);
        } else {
          this.reachedMaxScroll = this.elmnt.scrollTop == 0 ? false : true;
          this.elmnt.scrollBy({ top: -5, left: 0, behavior: "smooth" });
    
          this.scrollTimeout = setTimeout(() => {
            this.scrollDiv();
          }, 100);
        }
      }
    
      pauseScroll() {
        clearInterval(this.scrollTimeout);
      }
    
      resumeScroll() {
        this.scrollDiv();
      }
    
      switch() {
        if (this.autoScroll) {
          this.pauseScroll();
          this.autoScroll = false;
        } else {
          this.resumeScroll();
          this.autoScroll = true;
        }
      }
    }