Code Monkey home page Code Monkey logo

hongkong's Introduction

Hongkong - jQuery based plugin for parallax scrolling

Build Status Dependency Status devDependency Status

Install via npm

npm i --save hongkong

Usage

Please add bin/hongkong.js to your website. Make sure to include the dependency jQuery.

<script src="node_modules/jquery/dist/jquery.js"></script>
<script src="node_modules/hongkong/bin/hongkong.js"></script>

Just add the attribute data-parallax. For directions of the "floating" element please use data-parallax-top or data-parallax-bottom.

You can add a data-parallax-factor with a value which is an integer to change the factor of which the element should move. Default is 4.

Then call

$.hongkong();

somewhere within your JavaScript.

[ES6 | ES2015 | ES2016 | ES2017] modules

With ES6 you can use Hongkong as follows:

import $ from 'jquery';
import hongkong from 'hongkong';

hongkong($);
$.hongkong();

Options

You can pass options to Hongkong to customize it a bit:

  • factor: default factor to use for momentum if no other is set via a data-attribute; default: 4
  • mobile: support parallax effect on mobile; default: false
  • mediaQuery: Media query to match against when disabling parallax on mobile; default: (max-width: 42em)
  • selector: Selector to use to detect elements that should be scrolled; default [data-parallax]
  • threshold: Set threshold for showing and hiding elements; default 0

Data attributes

  • data-parallax-top
  • data-parallax-bottom
  • data-parallax-position-x
  • data-parallax-factor
  • data-parallax-remove-initial-offset
  • data-parallax-remove-general-offset

Development

Run npm i inside this folder. Start a development server with npm start.

License

The MIT License (MIT) Copyright (c) 2014 Hans Christian Reinl

hongkong's People

Contributors

anselmh avatar drublic avatar exdis avatar rodebert avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

hongkong's Issues

Try to use srcset but no luck

Hi,
Try to use srcset, but unfortunately I don't get it to work!
<div class="hero unit"> <div class="unit__inner" data-parallax data-parallax-bottom data-parallax-factor="3"> <h1 class="text-center">Hong Kong</h1> <p class="text-center">Pictures by <a href="http://cfremdt.de/">Christoph Fremdt</a></p> </div> <div class="background" data-parallax data-parallax-top> <img src="img/hongkong-1.jpg" srcset=" /img/hongkong-resp/hongkong-1_uclu5m_c_scale%2Cw_400.jpg 400w, /img/hongkong-resp/hongkong-1_uclu5m_c_scale%2Cw_948.jpg 948w, /img/hongkong-resp/hongkong-1_uclu5m_c_scale%2Cw_1343.jpg 1343w, /img/hongkong-resp/hongkong-1_uclu5m_c_scale%2Cw_1920.jpg 1920w"> </div> </div>
All suggestions to accomplish this are more then welcome!
Regards & Thanks,
David

(Mouse) Scrolling not smooth in Chrome

Hey there,

I stumbled over your nice little plugin, but noticed that the scrolling (mousewheel) in Chrome (Version 37.0.2062.120 (64-bit), Ubuntu) isn't smooth. I can't tell what's the problem yet, but maybe you can have a look at this, too :-) Tested this behavior as well as with your demo and also on a local test.

Cheers!

Choppy scrolling in Edge (lesser in Firefox)

on the demo page that the text (almost) stays fixed/optically stable when scrolling in Chrome (Windows). In Firefox and much more so in Edge the text seems a bit "jumpy" when scrolling. Both when using the scrollbar handle to scroll or a touch mouse.

Bump version number

Bumping the versionnumber by somthing minor would be nice.

That way the new changes are bower installable again

Collapse doesn't init resize

When collapsing an element above there is no height adjustment. I start scrolling, problem solved.

How can I fix it?

screen shot 2014-07-22 at 09 09 18

screen shot 2014-07-22 at 09 01 54

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.