Coder Social home page Coder Social logo

jackbdu / horizontical.js Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 9 KB

Horizontal HTML element movement triggered by vertical scrolling.

Home Page: https://jackbdu.com/horizontical.js/

License: MIT License

JavaScript 31.81% HTML 68.19%
javascript html

horizontical.js's Introduction

horizontical.js

Horizontal HTML element movement triggered by vertical scrolling.

Check out the demo or see its source code.

Setup

Download and include horizontical.js in your document.

<script src="/path/to/horizontical.js"></script>

Usage

HTML

<div class="h-wrapper">       <!-- the area of the page being vertically scrolled through under the hood -->
  <div class="h-viewport">    <!-- the visible area of the horizontically scrolled elements -->
    <div class="h-container"> <!-- the div containing the elements to be moved horizontically -->
      <!-- the elements to be moved horizontically -->
    </div>
  </div>
</div>

CSS

.h-wrapper {
  /* adjust the h-wrapper styles here */
  /* note: the h-wrapper height is dynamically adjusted by the library */
}
.h-viewport {
  /* adjust the h-viewport styles here */
  /* note: the h-viewport should not be bigger than the browser viewport */
}
.h-container {
  /* adjust the h-container styles here */
  /* note: the h-container width should be bigger than the viewport-width */
}

JavaScript

By default, the library is initialized on DOMContentLoaded. If your horizontical HTML elements are loaded (or added) after DOMContentLoaded, for instance, if you are using a client-side JavaScript template engine, you need to manually initialize the library after the horizontical HTML elements are loaded (or added).

setTimeout(function() {

  var hContainer = document.createElement('div');
  var hViewport = document.createElement('div');
  var hWrapper = document.createElement('div');

  hContainer.className = 'h-container';
  hViewport.className = 'h-viewport';
  hWrapper.className = 'h-wrapper';

  hViewport.appendChild(hContainer);
  hWrapper.appendChild(hViewport);
  document.body.appendChild(hWrapper);

  horizontical.init();  // You need to manually initialize the library here

}, 3000);

horizontical.js's People

Contributors

jackbdu avatar

Watchers

 avatar  avatar

horizontical.js's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.