Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vue3-smooth-scroll

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue3-smooth-scroll - npm Package Compare versions

Comparing version 0.5.0 to 0.6.0

2

dist/vue-smooth-scroll.min.js

@@ -1,1 +0,1 @@

!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.VueSmoothScroll=e():t.VueSmoothScroll=e()}(this,(function(){return function(t){var e={};function n(o){if(e[o])return e[o].exports;var r=e[o]={i:o,l:!1,exports:{}};return t[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=t,n.c=e,n.d=function(t,e,o){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},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 o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(o,r,function(e){return t[e]}.bind(null,r));return o},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)}([function(t,e,n){"use strict";function o(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function r(t){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var i;n.r(e);function u(){return{duration:500,offset:0,container:window,updateHistory:!0,easingFunction:null}}var c=Symbol("smoothScrollCtx");function a(t){var e=t.scrollTo,n=t.offset,o=t.duration,r=t.container,u=t.updateHistory,c=t.hash,a=t.easingFunction;i||(i=window.requestAnimationFrame||function(t){window.setTimeout(t,16)}),u&&window.history.pushState&&location.hash!==c&&window.history.pushState("","",c);var f,s,d=r.scrollTop||window.pageYOffset,p=(s=d,"HTML"===(f=e).nodeName?-s:f.getBoundingClientRect().top+s);p+=n;var y=Date.now();!function t(){var n=Date.now()-y,c=p;n<o?(c=d+(p-d)*("function"==typeof a&&a||l)(n/o),i(t)):u&&location.replace("#"+e.id),r===window?r.scrollTo(0,c):r.scrollTop=c}()}var f={install:function(t,e){var n,i=!t.version.startsWith("3");t.directive("smooth-scroll",(o(n={},i?"inserted":"mounted",(function(t,n,o){if("object"===("undefined"==typeof window?"undefined":r(window))&&void 0!==window.pageYOffset){var f=Object.assign({},u());e&&Object.assign(f,e);var l=n.value||{},s=l.duration,d=l.offset,p=l.container,y=l.updateHistory,b=l.easingFunction;s=s||f.duration,d=d||f.offset,p=p||f.container,y=void 0!==y?y:f.updateHistory,b=b||f.easingFunction,"string"==typeof p&&(p=document.querySelector(p));var m=function(t){t.preventDefault();var e=i?o.data.attrs.href:o.props.href,n=document.getElementById(e.substring(1));n&&a({scrollTo:n,offset:d,duration:s,container:p,updateHistory:y,hash:e,easingFunction:b})};t.addEventListener("click",m),t[c]={clickHandler:m}}})),o(n,i?"unbind":"unmounted",(function(t){t.removeEventListener("click",t[c].clickHandler),t[c]=null})),n)),(i?t.prototype:t.config.globalProperties).$smoothScroll=function(t){return a(Object.assign({},u(),e,t))}}};function l(t){return t<.5?4*t*t*t:(t-1)*(2*t-2)*(2*t-2)+1}e.default=f}])}));
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.VueSmoothScroll=t():e.VueSmoothScroll=t()}(this,(function(){return function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}n.r(t);var i=window.requestAnimationFrame||function(e){return window.setTimeout(e,16)},u=function(e){return e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1},c=function(){return{duration:500,offset:0,container:window,updateHistory:!0,easingFunction:null}},l=Symbol("smoothScrollCtx"),f=function(e){var t=e.scrollTo,n=e.offset,o=e.duration,r=e.container,c=e.updateHistory,l=e.hash,f=e.easingFunction;c&&window.history.pushState&&location.hash!==l&&window.history.pushState("","",l);var a,s,d=r.scrollTop||window.pageYOffset,p=(s=d,("HTML"===(a=t).nodeName?-s:a.getBoundingClientRect().top+s)+n),y="function"==typeof f?f:u,b=Date.now();!function e(){var n=Date.now()-b,u=n<o,l=u?d+(p-d)*y(n/o):p;u?i(e):c&&location.replace("#"+t.id),r===window?r.scrollTo(0,l):r.scrollTop=l}()},a={install:function(e,t){var n,i=!e.version.startsWith("3"),u=t?Object.assign(c(),t):c();e.directive("smooth-scroll",(o(n={},i?"inserted":"mounted",(function(e,t,n){if("object"===("undefined"==typeof window?"undefined":r(window))&&void 0!==window.pageYOffset){var o=Object.assign({},u,t.value);"string"==typeof o.container&&(o.container=document.querySelector(o.container));var c=function(e){e.preventDefault();var t=i?n.data.attrs.href:n.props.href,r=document.getElementById(t.substring(1));r&&f(Object.assign(o,{scrollTo:r,hash:t}))};e.addEventListener("click",c),e[l]={clickHandler:c}}})),o(n,i?"unbind":"unmounted",(function(e){e.removeEventListener("click",e[l].clickHandler),e[l]=null})),n)),(i?e.prototype:e.config.globalProperties).$smoothScroll=function(e){var t=Object.assign({},u,e);return f(t)}}};t.default=a}])}));
{
"name": "vue3-smooth-scroll",
"version": "0.5.0",
"version": "0.6.0",
"description": "Simple vue smooth scroll",

@@ -33,2 +33,8 @@ "main": "dist/vue-smooth-scroll.min.js",

"eslint": "^6.6.0",
"eslint-config-standard": "^14.1.1",
"eslint-loader": "^4.0.2",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.1",
"webpack": "^4.41.2",

@@ -35,0 +41,0 @@ "webpack-cli": "^3.3.5"

# Vue3 Smooth Scroll
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-2-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END -->
[![Vue 3.x](https://img.shields.io/badge/Vue-3.x-brightgreen.svg)](https://vuejs.org/v2/guide/)
[![npm](https://img.shields.io/npm/v/vue3-smooth-scroll.svg)](https://www.npmjs.com/package/vue3-smooth-scroll)
[![npm-downloades](https://img.shields.io/npm/dm/vue3-smooth-scroll.svg)](https://www.npmjs.com/package/vue3-smooth-scroll)
[![license](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/laineus/vue3-smooth-scroll/blob/master/LICENSE)

@@ -17,2 +13,3 @@

- Works on Vue 3
- Directive and programmatic API with global and local config overrides

@@ -23,6 +20,8 @@ - SSR

- Specific scroll containers
- 1.3kB gzipped, 2.9kB min
- 1.4kB gzipped, 3.1kB min
## Installation
### npm:
``` bash

@@ -35,2 +34,3 @@ npm install --save vue3-smooth-scroll

import VueSmoothScroll from 'vue3-smooth-scroll'
const app = createApp(...)

@@ -40,5 +40,19 @@ app.use(VueSmoothScroll)

### CDN:
``` html
<body>
<script src="https://unpkg.com/vue@next"></script>
<script src="https://unpkg.com/vue3-smooth-scroll"></script>
<script>
const app = Vue.createApp(...)
app.use(VueSmoothScroll.default)
</script>
</body>
```
## Usage
### Directive
### Directive:
``` html

@@ -50,3 +64,3 @@ <a href="#sec-3" v-smooth-scroll>Section 3</a>

### Programmatic
### Programmatic:

@@ -58,23 +72,10 @@ ``` js

scrollTo: myEl,
hash: '#sampleHash' // required if updateHistory is true
hash: '#sampleHash' // required if updateHistory is true
})
```
### Direct in `<script>`
## Custom options
``` html
<body>
<script src="https://unpkg.com/vue@next"></script>
<script src="https://unpkg.com/vue3-smooth-scroll"></script>
<script>
const app = Vue.createApp(...)
app.use(VueSmoothScroll.default)
</script>
</body>
```
### Defaults:
## Custom options
### Defaults
``` js

@@ -85,3 +86,3 @@ {

container: '', // selector string or Element for scroll container, default is window
updateHistory: true // whether to push hash to history
updateHistory: true, // whether to push hash to history
easingFunction: null // gives the ability to provide a custom easing function `t => ...`

@@ -93,12 +94,9 @@ // (see https://gist.github.com/gre/1650294 for examples)

### Global
### Global:
``` js
import { createApp } from 'vue'
import VueSmoothScroll from 'vue3-smooth-scroll'
const app = createApp(...)
app.use(VueSmoothScroll, {
duration: 400,
updateHistory: false,
updateHistory: false
})

@@ -117,3 +115,3 @@ ```

### Programmatic
### Programmatic:

@@ -120,0 +118,0 @@ ``` js

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc