All Projects → lpreterite → vpin

lpreterite / vpin

Licence: MIT license
基于 vue 的钉子组件,把你的内容固定到屏幕中📌。

Programming Languages

javascript
184084 projects - #8 most used programming language
Vue
7211 projects
HTML
75241 projects

Projects that are alternatives of or similar to vpin

vue-icon
Maybe it is the smallest vue component that contains all the feather icons
Stars: ✭ 44 (+266.67%)
Mutual labels:  vue2, vue2-component
vue-editor
This is a powerful and based on the 'Vue' Markdown editor.😂😂
Stars: ✭ 31 (+158.33%)
Mutual labels:  vue2
Vue2 Scrollbar
The Simplest Pretty Scroll Area Component with custom scrollbar for Vue 2. https://bosnaufal.github.io/vue2-scrollbar
Stars: ✭ 233 (+1841.67%)
Mutual labels:  vue2
PinCodeView
No description or website provided.
Stars: ✭ 29 (+141.67%)
Mutual labels:  pin
Login
Vue + Vue-router + Vuex 实现前端页面及逻辑,Express 实现注册登录登出的RestFul API 。
Stars: ✭ 246 (+1950%)
Mutual labels:  vue2
vue-toast
vue.js toast tips 提示文本 Vue1.0&2.0
Stars: ✭ 17 (+41.67%)
Mutual labels:  vue2
Vue Echo
Vue integration for the Laravel Echo library.
Stars: ✭ 229 (+1808.33%)
Mutual labels:  vue2
vue-china-map
vue+vuex+axios+echarts画一个动态更新的中国地图
Stars: ✭ 64 (+433.33%)
Mutual labels:  vue2
vue-input-autowidth
A Vue.js directive that automatically resizes an input's width to fit its contents.
Stars: ✭ 94 (+683.33%)
Mutual labels:  vue2
flutter sticky and expandable list
粘性头部与分组列表Sliver实现 Build a grouped list, which support expand/collapse section and sticky headers, support use it with sliver widget.
Stars: ✭ 116 (+866.67%)
Mutual labels:  pin
Vue Form Json Schema
Create forms using JSON schema. Bring your components!
Stars: ✭ 253 (+2008.33%)
Mutual labels:  vue2
Vue Firebase Auth Vuex
Vue Firebase🔥 Authentication with Vuex
Stars: ✭ 248 (+1966.67%)
Mutual labels:  vue2
vue-string-filter
✂️ Vue 2.x lightweight string manipulation filter
Stars: ✭ 38 (+216.67%)
Mutual labels:  vue2
Vue Mapbox Gl
A Vue.js component for Mapbox GL JS
Stars: ✭ 242 (+1916.67%)
Mutual labels:  vue2
vue-tinymce-editor
This a component provides use of tinymce for vue developers
Stars: ✭ 221 (+1741.67%)
Mutual labels:  vue2
Vue 2 3
↔️ Interop Vue 2 components in Vue 3 apps and vice versa
Stars: ✭ 231 (+1825%)
Mutual labels:  vue2
Vue Cnode
🔥Vue.js打造一个开源的CNode社区。CNode by Vue.js
Stars: ✭ 249 (+1975%)
Mutual labels:  vue2
vue-ray
Debug your Vue 2 & 3 code with Ray to fix problems faster
Stars: ✭ 48 (+300%)
Mutual labels:  vue2
vue-insta-stories
Vue 2 & 3 library for Instagram like stories.
Stars: ✭ 45 (+275%)
Mutual labels:  vue2
generator-vue-plugin
Yeoman generator generating vue plugin 🚀
Stars: ✭ 29 (+141.67%)
Mutual labels:  vue2

vpin

npm version vue2 NPM downloads

介绍

基于 vue 的钉子组件,帮助你把内容固定到屏幕中 📌

具体效果与功能

  • 核心功能就是把块固定于屏幕,滚动时不会随着内容滚动。
  • 支持动态计算定位,参照物默认为窗口。
  • 支持粘性定位,会根据范围对象开启固定效果。1
  • 可选择基于css实现效果,性能消耗低和效果更好。

线上例子

如何安装

npm install -S vpin

引入项目

import Vue from "vue"
import vpin from "vpin"

Vue.use(vpin())

使用

<template>
    <section class="container">
        <header>
            <div class="brand"></div>
            <div class="account"></div>
        </header>
        <div class="inner">
            <nav>
              <!-- 根据容器范围开启定位,定位后需要保留原位置空位 -->
              <div class="nav" v-pin.sticky.cssEffect="{ container:'.inner>nav', top:0, left:0 }">
                <ul>
                  <li><a href="#学而篇">学而篇</a></li>
                  <li><a href="#为政篇">为政篇</a></li>
                  <li><a href="#里仁篇">里仁篇</a></li>
                </ul>
              </div>
            </nav>
            <div class="main">内容</div>
        </div>
        <!-- 页脚基于样式的定位作为参考,来进行后续滚动跟随。 -->
        <footer class="footer" v-pin.cssEffect="{bottom:0}">
          &copy; 2022 PackyTang
        </footer>
    </section>
</template>

包含属性(Props)

名称 限制 描述
v-pin.sticky [Boolean] 默认值为false,是否开启粘性定位效果,设置后开启。
v-pin.cssEffect [Boolean] 默认值为false,是否使用CSS效果代替动态计算,设置后开启。
开启后,默认搬运定位对象至body的行为会取消,定位对象的DOM结构不变。
v-pin="{ container:document.documentElement }" [String, Element] 范围对象,默认值为HTML DOM对象,范围对象用于计算生效范围,一般与粘性定位效果共同使用 。
v-pin="{ reference:document.documentElement }" [String, Element] 参照对象,默认值为HTML DOM对象,参照对象用于监听滚动事件,通过动态实现定位。滚动视窗不是浏览器窗口本身时,指定此对象可实现元素内滚动定位。
v-pin="{ top:0,left:0,right:0,bottom:0 }" [Number] 偏移量,默认值为Number.NaN

例子1

使用CSS实现的使用粘性定位。推荐!

<template>
    <section class="container">
        <header>
            <div class="brand"></div>
            <div class="account"></div>
        </header>
        <div class="inner">
            <nav>
              <!-- 根据容器范围开启定位,定位后需要保留原位置空位 -->
              <div class="nav" v-pin.sticky.cssEffect="{ container:'.inner>nav', top:0, left:0 }">
                <ul>
                  <li><a href="#学而篇">学而篇</a></li>
                  <li><a href="#为政篇">为政篇</a></li>
                  <li><a href="#里仁篇">里仁篇</a></li>
                </ul>
              </div>
            </nav>
            <div class="main">内容</div>
        </div>
    </section>
</template>

例子2

使用CSS实现的固定至底部效果。

<template>
    <section class="container">
        <header>
            <div class="brand"></div>
            <div class="account"></div>
        </header>
        <div class="inner">
            <nav>
              <!-- 根据容器范围开启定位,定位后需要保留原位置空位 -->
              <div class="nav" v-pin.sticky="{ container:'.inner>nav', top:0, left:0 }">
                <ul>
                  <li><a href="#学而篇">学而篇</a></li>
                  <li><a href="#为政篇">为政篇</a></li>
                  <li><a href="#里仁篇">里仁篇</a></li>
                </ul>
              </div>
            </nav>
            <div class="main">内容</div>
        </div>
        <!-- 页脚基于样式的定位作为参考,来进行后续滚动跟随。 -->
        <footer class="footer" v-pin.cssEffect="{bottom:0}">
          &copy; 2022 PackyTang
        </footer>
    </section>
</template>

Develop

本地调试

$ npm run serve
# or
$ yarn serve

Footnotes

  1. 粘性定位见position: sticky;

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].