Git Product home page Git Product logo

nigelotoole / direction-reveal Goto Github PK

View Code? Open in Web Editor NEW
525.0 17.0 39.0 1.39 MB

Detects the direction a user enters or leaves an element allowing you to reveal or hide content based on this direction.

Home Page: http://nigelotoole.github.io/direction-reveal/

License: MIT License

JavaScript 15.28% HTML 32.24% SCSS 19.58% CSS 32.90%
javascript reveal hover hover-effects es6 gallery es6-modules sass vanilla-javascript vanilla-js

direction-reveal's People

Contributors

dependabot[bot] avatar nigelotoole 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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

direction-reveal's Issues

Direction calculation

The calculation for x/y (line 33, 34 in direction-reveal.js) is not correct. The right parenthesis for the normalization is set wrong. Correct calculation:
let x = (e.pageX - position.x - (w / 2)) * (w > h ? (h / w) : 1);
let y = (e.pageY - position.y - (h / 2)) * (h > w ? (w / h) : 1);
This causes a correct normalization for aspect ratios of the hovered element not equal 1, and subsequently the correct calculation of the direction.

Support Edge, IE11, IE10

for browser support (Edge, IE11, IE10)
add polyfill:

(function () {
    if ( typeof NodeList.prototype.forEach === "function" ) return false;
    NodeList.prototype.forEach = Array.prototype.forEach;

    if (!String.prototype.startsWith) {
      Object.defineProperty(String.prototype, 'startsWith', {
        enumerable: false,
        configurable: false,
        writable: false,
        value: function(searchString, position) {
          position = position || 0;
          return this.indexOf(searchString, position) === position;
        }
      });
    }
})();

PS. Maybe it will be useful to someone

Bug on mouse hover on right side of direction-reveal__card

Hey there, great plugin! I have installed this on my react app and seems to be working great! I have one issue: when I mouse over the right side of my images no matter where I exit, up or down, the animation it brings up is always swing--out-right or swing--in-right. See in the screenshots, I went from the top to the bottom of the two sandwiches on the left of the screen. Strangely though, if I do it on the left half of the images, they work just fine. Any help or insight would be greatly appreciated!

Thanks again for the useful script!

Atlante
screen shot 2018-02-15 at 4 00 11 am
screen shot 2018-02-15 at 3 59 56 am

main script missed parameters, but docs provide them

animationPostfixEnter and animationPostfixLeave are missed in the main script, but is mentioned in the docs/readme as well in /docs/script

When I use the usage script:

const directionRevealDefault = DirectionReveal({
  selector: '.direction-reveal',
  itemSelector: '.direction-reveal__card',
  animationName: 'swing',
  animationPostfixEnter: 'enter',
  animationPostfixLeave: 'leave',
  enableTouch: true,
  touchThreshold: 250
});

The animationPostfixEnter and animationPostfixLeave is not picked up. The generated classes are still outand leave and not enterand leave

It took me hours to find that out :-) , please be so kind and fix that to help others who stumble over this problem

PS: For libraries which uses static page generators (eg: React, Gatsby,...) documentand windoware not defined while build time, so a check for document in line around 23 makes it possible to use your script/library "out-of-the-box":

const containers = typeof document !== "undefined" ? document.querySelectorAll(selector) : []

Cannot get this to work

Imported styles, created my DirectionReveal() with no options and copied the demo markup exactly but nothing happens?

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.