![]() var imageLeft = document.querySelector('.left'), Therefore, no extra performance will be consumed. The library will automatically add the new instances in the same process loop of current instances. If you wish to apply different settings on various images, don't hesitate to initialize several instances of simpleParallax. You can choose among these orientations - up - right - down - left - up left - up right - down left - down right. ![]() It will result in the image translating from bottom to top when scrolling down, and from top to bottom when scrolling up. You can also choose to apply the parallax on multiple images, something like: var images = document.querySelectorAll(img) īy default, if you do not specify any parameters, simpleParallax will use the up orientation. ![]() Simply add the following JavaScript code: var image = document.getElementsB圜lassName('thumbnail') To add the parallax effect, you can target any images you want. Once you have installed it via a package manager, you can import it as follows: import simpleParallax from 'simple-parallax-js' Initialization Parallax js install#Or choose to install it via npm/yarn: #npm You can choose to include the script directly into your HTML: The implementation is quite straightforward and the animation is smooth and natural. You can also choose to apply the parallax on picture tags/srcset images. ![]() Basically, you can add parallax effects on a production website without breaking its layout. The parallax effect is added directly on image tags, there is no need to use background-image like most of the other parallax libraries do. SimpleParallax is a very simple and tiny JavaScript library which adds parallax animations on any images. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |