Giter Club home page Giter Club logo

simpleparallax.js's People

Contributors

dependabot[bot] avatar devsigner-xyz avatar eioo avatar geosigno avatar himajpatil avatar jb-cbd avatar justintaddei avatar qnp avatar timgates42 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

simpleparallax.js's Issues

Bootstrap Carousel

Not sure if I am missing something, but for whatever reason, the first image of a bootstrap carousel is working on scroll, but the rest of them don't.

JS:

const images = document.querySelectorAll('.parallax');
new simpleParallax(images);

HTML:

<div id="carousel" class="carousel slide carousel-fade" data-ride="carousel">
   <ol class="carousel-indicators">
      <!-- Start Carousel Indicator Loop -->
      <li data-target="#carousel" data-slide-to="0" class=""></li>
      <li data-target="#carousel" data-slide-to="1" class="active"></li>
   </ol>
   <div class="carousel-inner far-banner-carousel-inner">
      <div class="carousel-item">
         <div class="simpleParallax" style="overflow: hidden;">
			<img width="1920" height="560" src="image1.jpg" class="parallax wp-post-image" alt="">
		 </div>
         <div class="carousel-caption text-left">
            <div class="container">
               <h3 class="h1">Slide One</h3>
               <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean tincidunt nisl vitae nisl tempor, vel rhoncus dolor cursus. In metus sem, fermentum ac dignissim at, ultricies sit amet est. Aenean tellus risus, feugiat a cursus ut, imperdiet vel lacus. Phasellus pulvinar semper iaculis. Donec faucibus condimentum elit vitae cursus. Nunc ultrices in arcu quis varius.</p>
               <p></p>
            </div>
         </div>
      </div>
      <div class="carousel-item active">
         <div class="simpleParallax" style="overflow: hidden;">
			<img width="1920" height="560" src="image2.jpg" class="parallax wp-post-image" alt="">
		 </div>
         <div class="carousel-caption text-left">
            <div class="container">
               <h3 class="h1">Slide Two</h3>
               <p>Etiam a est in elit mollis rutrum. Praesent ultricies urna at diam vulputate scelerisque ac quis tortor. Interdum et malesuada fames ac ante ipsum primis in faucibus. Fusce tincidunt mi et leo consectetur, a ullamcorper elit aliquet. Donec aliquam risus eu vestibulum sollicitudin.</p>
               <p></p>
            </div>
         </div>
      </div>
   </div>
   <a class="carousel-control-prev" href="#carousel" role="button" data-slide="prev">
   		<span class="carousel-control-prev-icon" aria-hidden="true"></span>
   		<span class="sr-only">Previous</span>
   </a>
   <a class="carousel-control-next" href="#carousel" role="button" data-slide="next">
   		<span class="carousel-control-next-icon" aria-hidden="true"></span>
   		<span class="sr-only">Next</span>
   </a>
</div>

I am using latest Bootstrap v4.5.0

Any idea what I can do to fix this?

PS: Awesome work on this wonderful script! ๐Ÿ‘

Delay effect

Not seeing the delay function have any effect. If i have the same image side by side and add a delay value (of e.g. '0.9') to one image and the other with a delay of 0 then I cannot see any difference between them when I scroll.

[Edit: It seems it's v2.3 that downloads. Will download 2.4 manually] Thanks ๐Ÿ‘

Problem with dynamic page loading

Hi, I really like this library but I've ran into an issue where it works perfectly on the initial load, but when I move between from one page, to the next and back again, the animations aren't working.

I'm using Barba.js for the dynamic page loading, but what I am finding is that everything is running as it should, transform, transition and will-change all get added to the element, but when I scroll nothing happens.

I don't think this is an issue with Barba for this reason. I wonder if you have any idea what could be stopping the animation?

Responsive images with simpleParallax

I'm using picturefill to load different images in conjunction with simpleParallax and it's working great on Chrome/Safari, but the images don't load on Firefox. I'm guessing the issue is that a div wrapping the img tag inside the picture element is not OK with Firefox. I'm not sure if there's a workaround. Thanks

This is how I have everything set up:

<section class="joy-divider">
    <picture>
      <source data-srcset="desktop-img.jpg 2x" media="(min-width: 600px)">
      <source data-srcset="mobile-img.jpg 2x">
      <img class="lazyload" src="" data-src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" alt="">
    </picture>
</section>
var parallaxImages = $('.joy-divider img');
new simpleParallax(parallaxImages, {
  delay: 0.75,
  scale: 1.3,
  transition: 'cubic-bezier(0,0,0,1)'
});

Using a speed instead of scale.

Right now scale factor is being used as speed of transformation as-well right?

I am in a situation where i donot want any scaling on the image and just wants its parallax movement (translate X / Y).
Is there any way to achieve this ?

Parallax effect is shaking/not smooth on MS Edge

On MS Edge parallax effect is jerky/not smooth. You can easily reproduce it on the official page with examples.

OS: Windows 10 Home x64
Browser: MS Edge 44.17763.1.0

It is super fine on FireFox and Chrome.

Reinitialization

Hello,
is there any way to reinitialize simpleParallax?

I've got collapsible element (using bootstrap) in my page and some parallax images under this element. If i show content of collapsible element, parallax stopped working for these elements.

So I thought i will destroy simpleParallax and create new instance but withnout effect.

Is there any way?

Feature: make it also work with videos

It would be great if we could use this library also for applying a parallax effect on <video /> tags.
In addition maybe it would also be possible to use it for youtube videos?

SimpleParallax.destory() unreachable?

I'm building a SPA with your module and need to clear the instance when the route changes to avoid a memory leak. However, the destory method is not reachable from the users code.

const parallax = new SimpleParallax(img)

console.log(parallax)
// `{ }`

parallax.destroy()
// Uncaught TypeError: parallax.destory is not a function

I believe the issue is due to handle returning undefined

// simpleParallax.js:71
function handle(element, options) {
    if (element.length) {
        for (var i = 0; i < element.length; i++) { 
            new SimpleParallax(element[i], options);
        }
    } else {
        new SimpleParallax(element, options);
    }
}

I am more than happy to create a PR for this issue.

Use with Vue

The library seems to wrap the images in its own "wrapper", but that doesn't work when using frameworks such as Vue (since they use virtual DOM).
The solution is to allow the library to optionally specify the wrapper element, rather than the library creating the wrapper itself.

Thank you!

Not applying to content that is hidden

I am trying to apply this on images that are in tabbed content where the parent selector is set to display:none until the tab is activated and the content is revealed.

The parallax effect does not seem to be applied to this content that is set to display:none when simpleParallax is executed but display:block when the parent selector is activated.

Is this a known issue? Is there a workaround that would be possible?

Apply transition after setting it to the right position (translate3d and scale)

Hi, First of all I want to say that your javascript with images works pretty neat. It's the first proper code I find for parallax scrolling with images which are not set on the background with CSS :)

I got the following issue, when I open a page with parallax you see the image transitioning to the right position with translate3d and scale. Which feels kinda buggy. Is there a way to set the translate3d and scale without applying a transition but adding the transition when the image is already set to the right position and you start scrolling? Would love to hear, this transition on load is some kind of deal breaker when you apply parallax to a header at the top of a page.

Custom scroll container option

Hi, and thanks for such a great parallax plugin!

My site template requires an HTML structure that tracks user scrolling by a wrapper div and not the window.

Is it possible to set a custom scroll container for simpleParallax? Thanks again!

Not working with jquery lazyload

I am using jQuery lazy plugin for delayed loading of images. But the parallax effect doesn't work with it. How can I delay uploading images?

Custom container

Hey,

When I set custom container I get error:

Uncaught TypeError: this.settings.customContainer.getBoundingClientRect is not a function at t.value (simpleParallax.min.js:7) at t.value (simpleParallax.min.js:7) at simpleParallax.min.js:7

Uncaught TypeError: simpleParallax is not a constructor

Hello,
When I try to use the last version (5.0.0), I get this error message:

Uncaught TypeError: simpleParallax is not a constructor

But when I use an older version (4.2.1), everything works as expected.

Is there something special to do to make the last version work?

Thanks

When multiple images initialized only works when first one is in viewport

Hello, i have tried your plugin and there is no way i could set it up to work with multiple images...

Structure goes like this

text
1) image

text
2) image

text
3) image

text
4) image

text
5) image

Next thing is, i have included your script for parallax and i have elements that have id's with this structure id="_1", id="_2", id="_3", id="_4", id="_5"

so, i don't want to initialize 5 times so i did it with for loop.

let parallaxElemes = document.getElementsByClassName("parallax-thumbnail").length;
for(let i = 1; i <= parallaxElemes; i++){
        // console.log(jQuery("#_" + i)); // Working as it should be
        jQuery("#_" + i).simpleParallax({
            'orientation': 'down'
        });
}

It works on every image but only when first image is in viewport..

Is there quick solution for problem or i just didn't use script as it should be used?

Thanks in advance

Dynamic Page Height Issue

Hi,

Details
When the page height is changing dynamically after initialized simpleParallax the calculations are wrong.

Reproduce

  • Create a div above a sinmpleParallax img tag: <div class="space" style="height: 100px;"></div>
  • Initialize simpleParallax on the image tag
  • Change the div height to 500px
  • See the results

Solution
If you can add a Refresh function that recalculate the positions anyone can call it when he detect a change at this website.

IE 11 support

I love this plugin,
but look like doesn't support IE11.

I think is because the "closest" function only work in a modern browser

Thanks

README.md Update

This following from the readme no longer works.

var instance = new simpleParallax(images[0]);
instance.destroy();

This is because new simpleParallax(element | element[]) always returns an array as of commit 2ace14c

translateValueY jump on pageload

Hi,

When the page loads my paralax element 'jumps' because it gets

transform: translate3d(0px, 39px, 0px);

applied in stead of:

transform: translate3d(0px, 0, 0px);

My config is:

var shapes = document.querySelectorAll('.project-hero-shape svg');
new simpleParallax(shapes, {
    orientation: 'up',
    delay: .1,
    overflow: true,
    transition: 'cubic-bezier(0,0,0,1)'
});

Is there a way around this?

Thanks!

Parallax Without Scale

Hi,

I really like simpleParallax solution for using Parallax but I really like to get the same effect without Scaling the image.

I sow that when using the overflow: true property the Parallax is working but the image us bot displayed as scaled, so I try to use it and I added overflow: false CSS to the image parent to prevent the image overlap with your content, its works but there is a bug with the calculations and the image go out from its container a little.

If there is any fix for that issue it will be perfect!

1756922ae61b7430b5de547f9e8b1e8f

Typo on website

Settings section on simpleParallax website is incorrect.

orientation	string	up	top - right - bottom - left

Should be:

orientation | up | choose the parallax orientation effect - up, right, down or left

Reference Error: Window not defined

Hi, great plugin! I installed via NPM and followed the setup guide but am getting the below error, any ideas?

ReferenceError: window is not defined at Object.<anonymous> (/node_modules/simple-parallax-js/dist/simpleParallax.min.js:7:227) at Module._compile (internal/modules/cjs/loader.js:689:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10) at Module.load (internal/modules/cjs/loader.js:599:32) at tryModuleLoad (internal/modules/cjs/loader.js:538:12) at Function.Module._load (internal/modules/cjs/loader.js:530:3) at Module.require (internal/modules/cjs/loader.js:637:17) at require (internal/modules/cjs/helpers.js:20:18) at Object.<anonymous> (/gulpfile.js:41:24) at Module._compile (internal/modules/cjs/loader.js:689:30) 192-168-1-8:$ gulp /node_modules/simple-parallax-js/dist/simpleParallax.min.js:7 !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("simpleParallax",[],e):"object"==typeof exports?exports.simpleParallax=e():t.simpleParallax=e()}(window,(function(){return function(t){var e={};function n(i){if(e[i])return e[i].exports;var s=e[i]={i:i,l:!1,exports:{}};return t[i].call(s.exports,s,s.exports,n),s.l=!0,s.exports}return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var s in t

Remove generated DIV

Hello!

Is it possible to remove the div that nests the image? It gives problems if you want to maintain the aspect ratio of the image.

Thank you

How to use in a picture tag for responsive images.

It works on regular images, buy I'm unable to get it to work with

<picture>
                    <?php $image2xretina = wp_get_attachment_image_src(get_sub_field('imagen_de_fondo'), 'orginal'); ?>
                    <?php $image1xretina = wp_get_attachment_image_src(get_sub_field('imagen_de_fondo'), 'orginal'); ?>
                      <source srcset="<?php echo $image2xretina[0]; ?>" media="(min-width: 1600px)">
                      <source srcset="<?php echo $image1xretina[0]; ?> 1x, <?php echo $image2xretina[0]; ?> 2x">
                      <img class="thumbnail img-fluid imagen-fondo" srcset="<?php echo $image2xretina[0]; ?>" alt="<?php the_title(); ?>">
                   </picture>

Use on figure element

hi ,
Would it be possible to use this library for applying a parallax effect on <figure> element
So the parallax could work on the <img> and <figcaption> tag at the same time ?
Here is an exemple for the markup

 
<figure>
 <img src="bubbles-work.jpeg">
 <figcaption>Bubbles at work</figcaption>
</figure>

Thanks

The parallax effect stops across breakpoints

When I set a breakpoint (ex. 1024) and I reduce the window the effect correctly ends. When I enlarge the window the effect doesn't restarts.

It may be useful that, with overflow:true, orientation:down and scale:1 the "sliding effects" is maintained and that it starts at "0" point transform: translate3d(0px, 0px, 0px);

Overflow not working

Hi ! im Lucien โœ‹

i open this issue because i have test this library but with Overflow this not work.

whith other it's ok ! ๐Ÿ‘

Link for test: https://spjs-issue.netlify.app/

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    html, body {
      width: 100vw;
      height: 200vh;
      margin: 0;
      padding: 0;
      position: relative;
    }
  </style>
  <body>
    <img class="toto" src="https://creativetacos.com/wp-content/uploads/2018/11/Free-iPhone-Xr-Mockup-696x464.jpg" alt="" srcset="">
    <!-- Java script  -->
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/simpleParallax.min.js"></script>
    <script>
      var image = document.querySelector('.toto');
      new simpleParallax(image,{
        overflow: true
      });
    </script>
  </body>
</html>

Adding information about supported browsers

Please, let users know on the README page, that IE browsers are not supported. It used Element.closest() and Intersection Observer API. It needs a polyfill. A polyfilled version would be the best :)

Thank you!

Works intermittently on Chrome

Works fine in Firefox but sometimes in Chrome it initialises fine but nothing happens when you scroll.

If I inspect element I can see that the translate3d doesn't change on scroll.

I am not getting any errors in the console.

I am using the most simple code:

 let images = document.getElementsByClassName('js-parallax');
new simpleParallax(images);

SimpleParallax version: 5.4.0
Chrome version: 81.0.4044.122

Not scrolling

The plugin indeed put all inline style but scroll doesn't change anything... Any guess?

horribly laggy on iOS Safari

Tested on iOS 13.3.1/13.4 iPhone 6/SE/7/8

Dude I think a parallax lib is a bit unnecessary but why not. I guess it's primarily for Webdesigners. Whatever it's very laggy on mobile safari as mentioned on Reddit. Have a look on it ๐Ÿ˜‰

instance.destroy()

I'm using this in an Angular 7 project. initializing seems to be working fine, but when i try to remove the effect from the image (by calling this.parallaxInstance.destroy();) the image is being completely removed from the page.

Is this the intended behavior? I do not want to remove the image from the DOM, just remove the effect from the image.

Not working in MS Edge

The parallax effect is working on Firefox and Chrome. However, it is not working in MS Edge. When opening my website with MS Edge, I get the following error:
image

The code that I am using to run the parallax is the following:

jQuery(function($){
    //Add paralax to home page featured image
    var image = document.querySelectorAll('.attachment-post-thumbnail');
    new simpleParallax(image, {
	    scale: 1.5
    });
});

remove/adapt the handle function with ES6 standart

On develop branch, webpack has been set instead of gulp/express/browserify. This is working as before.

Now we need to use full potential of es6 class and import ( for example polyfills should be imported and not been added directly into simpleParallax main class ).

Also, now that webpack is set in UMD library we don't need to have the function(root, factory) at the top of simpleParallax class. We should only have the class at top level.

This induces that handle function should be optimized. I'm not sure of the best approach to do it.

Any volunteers most welcome.

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.