├── .babelrc ├── .editorconfig ├── .eslintignore ├── .eslintrc ├── .gitignore ├── README.md ├── build ├── webpack.base.conf.js └── webpack.min.conf.js ├── dist ├── ScrollMagnetContainer.vue ├── ScrollMagnetItem.vue └── vue-scroll-magnet.min.js ├── docs ├── .gitignore ├── _config.yml ├── package.json ├── public │ ├── 2016 │ │ └── 11 │ │ │ └── 29 │ │ │ └── a │ │ │ └── index.html │ ├── archives │ │ └── index.html │ ├── atom.xml │ ├── css │ │ └── apollo.css │ ├── docs │ │ └── index.html │ ├── examples │ │ └── index.html │ ├── favicon.png │ ├── font │ │ ├── sourcesanspro.woff │ │ └── sourcesanspro.woff2 │ ├── index.html │ ├── scss │ │ └── apollo.scss │ └── sitemap.xml ├── scaffolds │ ├── draft.md │ ├── page.md │ └── post.md └── source │ ├── _posts │ └── a.md │ ├── docs │ └── index.md │ └── examples │ └── index.md ├── index.html ├── package.json ├── src ├── ScrollMagnetContainer.vue ├── ScrollMagnetItem.vue └── index.js ├── test └── unit │ ├── .eslintrc │ ├── index.js │ ├── karma.conf.js │ ├── specs │ ├── ScrollMagnetContainer.spec.js │ └── ScrollMagnetItem.spec.js │ └── utils │ └── index.js └── yarn.lock /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["es2015", "stage-2"], 3 | "plugins": ["transform-runtime"], 4 | "comments": false 5 | } 6 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | indent_style = space 6 | indent_size = 2 7 | end_of_line = lf 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | build/*.js 2 | config/*.js 3 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "ssense/client" 3 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules/ 3 | npm-debug.log 4 | test/unit/coverage 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vue-scroll-magnet 2 | 3 | ## What is Vue Scroll Magnet? 4 | 5 | Vue Scroll Magnet is a pair of component wrappers which allow elements to follow the viewport while scrolling and then anchor at the upper and lower extremeties of their parent container. This module is inspired by a jQuery plugin called Sticky kit. 6 | 7 | ## Installation 8 | 9 | > This component relies on ES6 and may not be compatible with Vue 1.x projects. 10 | 11 | ``` bash 12 | npm install -S vue-scroll-magnet 13 | ``` 14 | 15 | ## Usage (Global) 16 | Install the components globally: 17 | ``` js 18 | import Vue from 'vue'; 19 | import VueScrollMagnet from 'vue-scroll-magnet'; 20 | 21 | Vue.use(VueScrollMagnet); 22 | ``` 23 | 24 | ## Usage (Component) 25 | Include the wrappers into your component using import: 26 | ``` js 27 | /* inside your Vue component's script tag */ 28 | 29 | import { ScrollMagnetContainer, ScrollMagnetItem } from 'vue-scroll-magnet'; 30 | 31 | export default { 32 | ... 33 | components: { 34 | ScrollMagnetContainer, 35 | ScrollMagnetItem 36 | } 37 | ... 38 | }; 39 | ``` 40 | 41 | ### HTML structure 42 | The scrollable height boundary will be determined as the direct parent of the <scroll-magnet-container> by default, however it can be configured using an element selector which it can use as a fixed context. 43 | 44 | In the example below, <scroll-magnet-container> will automatically use the top of #app as its upper boundary and its height of 500px as its lower boundary unless a specific element context is provided. 45 | 46 | ``` html 47 |
Vue Scroll Magnet
Vue Scroll Magnet is a pair of component wrappers which allow elements to follow the viewport while scrolling and then anchor at the upper and lower extremeties of their parent container. This module is inspired by a jQuery plugin called Sticky kit.
2 |3 |5 |This component relies on ES6 and may not be compatible with Vue 1.x projects.
4 |
|
|
Install the components globally:1234import Vue from 'vue';import VueScrollMagnet from 'vue-scroll-magnet';Vue.use(VueScrollMagnet);
Include the wrappers into your component using import:123456789101112/* inside your Vue component's script tag */import { ScrollMagnetContainer, ScrollMagnetItem } from 'vue-scroll-magnet';export default { ... components: { ScrollMagnetContainer, ScrollMagnetItem } ...};
The scrollable height boundary will be determined as the direct parent of the <scroll-magnet-container> by default, however it can be configured using an element selector which it can use as a fixed context.
9 |In the example below, <scroll-magnet-container> will automatically use the top of #app as its upper boundary and its height of 500px as its lower boundary unless a specific element context is provided.
10 |
|
|
To run unit tests & code coverage:1npm test
Vue Scroll Magnet
|
|
|
|
Vue Scroll Magnet