
Research
/Security News
11 Malicious Go Packages Distribute Obfuscated Remote Payloads
Socket uncovered 11 malicious Go packages using obfuscated loaders to fetch and execute second-stage payloads via C2 domains.
smooth-scrollr
Advanced tools
Simple smooth scrolling module based on fake scroll events (aka wheel and touch and keyPress...).
View Demos
·
Report Bug
·
Request Feature
Made as a prototype reveal based class, initialize the module to use it.
This is an example of how to list things you need to use the software and how to install them.
npm
npm i smooth-scrollr@latest
yarn
yarn add smooth-scrollr
git clone https://github.com/alexiscolin/smooth-scrollr.git
npm install
Basic usage :
<main class="" id="section">
<section class="" data-scroll-container>
<article class=""></article>
<article class=""></article>
<article class=""></article>
</section>
<section class="" data-scroll-container>
<article class=""></article>
<article class=""></article>
<article class=""></article>
</section>
...
</main>
Note: data-scroll-container are optional but recommended to improve long page performance.
import { SmoothScrollr } from "smooth-scrollr";
const opts = {
section: document.querySelector("#section"),
speed: 0.8,
fixedClass: "fixedClass",
};
const smoothscroll = new SmoothScrollr(opts);
Note: 'fixedClass' is optional and set the class you define to block real scroll to the right container. Inline styles are used if not definied
Get the smooth-scrollr.min.js
file inside the dist
folder. Then, use it in the html file :
<script src="smooth-scrollr.min.js"></script>
<script>
(function () {
const opts = {
/*opts here */
};
var scroll = new SmoothScrollr(opts);
})();
</script>
Option | Type | Default | Description | |
---|---|---|---|---|
section | object | body | DOM section that you want to make scrollable or data-scroll-containers parent if you want to use multi wrapper option (make sure the parent wrap all children in horizontal scroll case). | |
listened | object | config.section | DOM section that will be used as scroll listener. | |
direction | string | vertical | vertical | horizontal Scroll direction: If horizontal, avoid to set section width in any value other than auto in order to create a container that is bigger than the viewport. |
speed | number | 1 | Speed value on the range 0-1 that is slowing the smoothing effect. | |
delay | number | .1 | Easing value between 0 & 1 | |
fixedClass | string | The class you want to set in order to fix the viewport (at least you need overflow: hidden and height: 100% on the container and overscroll-behavior: none or overflow: hidden on the body). | ||
touch | boolean | false | Enable smooth scroll on touch event | |
touchSpeed | number | 1.5 | Scrolling speed on touch event | |
jump | number | 110 | Scrolling step on keyPress event | |
multFirefox | number | 15 | Scrolling speed on Firefox | |
preload | boolean | true | Enable preload media function in order to resize page after async | |
resize | boolean | true | Enable auto resize | |
initFuncs | array | Array of functions that must be fired after the instance has been initialised. If preload , init takes place after the event |
data-scroll-container
: create a scrollable container inside the section
. Splitting the page into smaller container is good to improve performance. Only the viewed container will move, so lighten containers will move one after the other. This is totaly optional.Methods | Description | Arguments |
---|---|---|
scrollTo | In order to force scroll to a location on the webpage. | dir : (number) - the position in px you want to go on the page- imediate : (boolean - default: false) - go with/without smooth effect |
scrollOf | In order to scroll from a specific number of pixel. | path : (number) - the distance in px you want the page go through. Return the scroll position- imediate : (boolean - default: false) with/without smooth effect |
getSize | In order to get the scroller container size. | |
on | In order to add a listener function on a specific scroll event. | event : (string) - the instance event you want to listen (see the list below)callback : (function) - the function you want to trigger when the event is dispatchedcontext : (object - default : section) the content you want to listen (you should avoid to use it unless you know what you do) |
off | In order to remove a listener function on a specific scroll event. | event : (string) - the instance event you want to remove a listener (see the list below)callback : (function) - the function you want to remove (use the same as you set to add the listener)context : (object - default : section) the content you want to listen (you should avoid to use it unless you know what you do) |
resize | In order to recalculate scroll container. | |
destroy | In order to destroy scroll container. | |
preventScroll | In order to freeze scrolling movement. | state : (boolean) - freeze or unfreeze scroll event |
smoothscroll.scrollTo(0, true); // go to the top without smoothing
smoothscroll.scrollFrom(200, false); // go 200px forward smoothly
const callback = () => {
console.log("yeah!!");
};
smoothscroll.on("scroll", callback); // 'yeah!!` appears in the console during the scroll.
// You can access scroll position as parameter in callbak function (scroll event only)
smoothscroll.off("scroll", callback); // use the same previous callback function
smoothscroll.destroy(); // all events are removed and the instance has been killed
Event | Description |
---|---|
scroll | trigger during scroll |
collisionTop | trigger when the scroll is at top of the page |
collisionBottom | trigger when the scroll is at bottom of the page |
collisionEnded | trigger once when the scroll stop to be blocked by the collision with page edges |
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are appreciated.
git checkout -b feature/AmazingFeature
)git commit -m 'Add some AmazingFeature'
)git push origin feature/AmazingFeature
)Distributed under the MIT License. See LICENCE FILE for more information.
Alexis Colin - linkedin - alexis@jaunebleu.co
Project Link: https://github.com/alexiscolin/smooth-scrollr
FAQs
🖱Simple smooth scrolling in JS
The npm package smooth-scrollr receives a total of 3 weekly downloads. As such, smooth-scrollr popularity was classified as not popular.
We found that smooth-scrollr demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
Socket uncovered 11 malicious Go packages using obfuscated loaders to fetch and execute second-stage payloads via C2 domains.
Security News
TC39 advances 11 JavaScript proposals, with two moving to Stage 4, bringing better math, binary APIs, and more features one step closer to the ECMAScript spec.
Research
/Security News
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).