项目
在 GitHub 查看
apertureless/vue-parallax
关于
🌌 用于实现图像视差滚动效果的 Vue.js 组件
网站与应用开发实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- 0
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文vue-parallaxy
Is a component for fast 60fps parallax scroll effects in Vue 3.
Demo
Install
npm install vue-parallaxy or yarn add vue-parallaxy
Peer dependency: vue ^3.2.0
Vue 2 projects should stay on vue-parallaxy@1.
Usage
vue-parallax works with slots. So you can pass an image or even srcsets for better mobile experiences.
<!-- Image.vue -->
<template>
<parallax>
<img src="path/cool-background-image.jpg" alt="very cool bg">
</parallax>
</template>
<script>
import Parallax from 'vue-parallaxy'
import 'vue-parallaxy/style.css'
export default {
components: {
Parallax
}
}
</script>
Props
| Prop | Type | Default Value | Description |
|---|---|---|---|
| parallax | Boolean | true | Activates parallax effect |
| speedFactor | Number | 0.15 | factor on how strong the effect is |
| direction | String | 'up' | Either 'up' or 'down', determines scroll direction of image |
| fixed | Boolean | false | Other parallax effect. Image is fixed in position |
| sectionHeight | Number | 70 | section height for mobile |
| breakpoint | String | '(min-width: 968px)' | Media query for mobile deactivation |
| sectionClass | String | 'Masthead' | CSS class of the outer section tag |
| containerClass | String | 'Masthead__image' | CSS class of the container holding the image |
| parallaxClass | String | 'is-parallax' | Modifier class for the parallax effect |
| fixedClass | String | 'is-fixed' | Modifier class for the fixed parallax effect |
Customizing
You can change some of the behavior by changing the css classes. To be more clean, you can change them over the props. No need to overwrite or !important the existing classes.
Build Setup
# install dependencies
npm install
# serve with hot reload at localhost:5173
npm run dev
# build library for production
npm run build
# run unit tests
npm run unit
# run all tests
npm test
Contributing
- Fork it ( https://github.com/apertureless/vue-parallax/fork )
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
License
This software is distributed under MIT license.
探索相关项目
加载中…