0.0.1 • Published 5 years ago

mgn-smooth-scroll v0.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
5 years ago

mgn-smooth-scroll ( Don't Need jQuery )

Implement smooth scroll.

  • Target browser : IE9+

Install

npm i mgn-smooth-scroll -S

Or Download raw data

↓ download "mgn-smooth-scroll.js"


Import

import mgnSmoothScroll from 'mgn-smooth-scroll';

Constructor

new mgnSmoothScroll(element [, option]);
ArgumentData typeDefaultDescroption
elementString-(Required)Specify target element.ex) "a"
optionObject-ex)option = {speed: 1000,easing: "easeOutQuint",posFix: 50,ignore: ".btn,blank: true,customAnchor: "?anchor=",}
ArgumentData typeDefaultDescroption
speedNumber800Specify scroll speed.
easingString"linear"Specify easing from one of the following:"linear""easeInCubic""easeOutCubic""easeInOutCubic""easeInQuart""easeOutQuart""easeInOutQuart""easeInQuint""easeOutQuint""easeInOutQuint"
posFixNumber0Specify a minus value for header.
ignoreString-Specify element to be excluded from an event.
blankBooleanfalseAnchor link for page transition.
customAnchorString"#/"Specify effective "?anchor=", "?id=" etc. when blank: true is set.

Method

MethodArgumentDescroption
SmoothScroll( Number )-Scroll to the position specified in parameter.
ScrollEnd = function(){};-To be executed after scroll is complete.

Demo

https://frontend-isobar-jp.github.io/mgn-smooth-scroll/

import mgnSmoothScroll from 'mgn-smooth-scroll';

let scroll = new mgnSmoothScroll(
    "a",
    {
        easing: "easeOutQuint",
        ignore: ".ignore",
        posFix: 60,
        blank: true,
    }
);

scroll.ScrollEnd = function(){
    console.log("ScrollEnd")
};