├── public ├── favicon.ico └── index.html ├── babel.config.js ├── src ├── assets │ └── logo.png ├── main.js ├── components │ ├── tilt.vue │ └── HelloWorld.vue └── App.vue ├── .gitignore ├── package.json └── README.md /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThatNerdUKnow/vanilla-tilt-vue/HEAD/public/favicon.ico -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | '@vue/cli-plugin-babel/preset' 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /src/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThatNerdUKnow/vanilla-tilt-vue/HEAD/src/assets/logo.png -------------------------------------------------------------------------------- /src/main.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import App from './App.vue' 3 | 4 | Vue.config.productionTip = false 5 | 6 | new Vue({ 7 | render: h => h(App), 8 | }).$mount('#app') 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | /dist 4 | 5 | 6 | # local env files 7 | .env.local 8 | .env.*.local 9 | 10 | # Log files 11 | npm-debug.log* 12 | yarn-debug.log* 13 | yarn-error.log* 14 | pnpm-debug.log* 15 | 16 | # Editor directories and files 17 | .idea 18 | .vscode 19 | *.suo 20 | *.ntvs* 21 | *.njsproj 22 | *.sln 23 | *.sw? 24 | -------------------------------------------------------------------------------- /src/components/tilt.vue: -------------------------------------------------------------------------------- 1 | 6 | 24 | 25 | 30 | 31 | -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | <%= htmlWebpackPlugin.options.title %> 9 | 10 | 11 | 14 |
15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/App.vue: -------------------------------------------------------------------------------- 1 | 14 | 15 | 31 | 32 | 50 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vanilla-tilt-vue", 3 | "version": "0.1.3", 4 | "description": "A Vuejs wrapper for vanilla-tilt", 5 | "main": "src/components/tilt.vue", 6 | "keywords": [ 7 | "Vue", 8 | "tilt.js", 9 | "tilt", 10 | "vanilla-tilt" 11 | ], 12 | "repository": { 13 | "type": "git", 14 | "url": "https://github.com/Withenex/vanilla-tilt-vue" 15 | }, 16 | "private": false, 17 | "scripts": { 18 | "serve": "vue-cli-service serve", 19 | "lint": "vue-cli-service lint" 20 | }, 21 | "dependencies": { 22 | "vanilla-tilt": "^1.7.0", 23 | }, 24 | "devDependencies": { 25 | "vue": "^2.6.11", 26 | "core-js": "^3.6.5", 27 | "@vue/cli-plugin-babel": "~4.5.0", 28 | "@vue/cli-plugin-eslint": "~4.5.0", 29 | "@vue/cli-service": "~4.5.0", 30 | "babel-eslint": "^10.1.0", 31 | "eslint": "^6.7.2", 32 | "eslint-plugin-vue": "^6.2.2", 33 | "vue-template-compiler": "^2.6.11" 34 | }, 35 | "eslintConfig": { 36 | "root": true, 37 | "env": { 38 | "node": true 39 | }, 40 | "extends": [ 41 | "plugin:vue/essential", 42 | "eslint:recommended" 43 | ], 44 | "parserOptions": { 45 | "parser": "babel-eslint" 46 | }, 47 | "rules": {} 48 | }, 49 | "browserslist": [ 50 | "> 1%", 51 | "last 2 versions", 52 | "not dead" 53 | ] 54 | } 55 | -------------------------------------------------------------------------------- /src/components/HelloWorld.vue: -------------------------------------------------------------------------------- 1 | 32 | 33 | 41 | 42 | 43 | 59 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | # vanilla-tilt-vue 5 | 6 | 7 | 8 | 9 | 10 | ## Installation 11 | 12 | 13 | 14 | `npm i vanilla-tilt-vue` 15 | 16 | 17 | 18 | 19 | 20 | ## Usage 21 | 22 | 23 | 24 | ```js 25 | 26 | Import Tilt from 'vanilla-tilt-vue' 27 | 28 | ``` 29 | 30 | And inside your template... 31 | 32 | ```html 33 | 34 | 43 | 44 | ``` 45 | 46 | The options prop must be a JavaScript object. The options available are identical to the ones required by vanilla-tilt 47 | 48 | 49 | 50 | ```js 51 | 52 | { 53 | 54 | reverse: false, // reverse the tilt direction 55 | 56 | max: 35, // max tilt rotation (degrees) 57 | 58 | startX: 0, // the starting tilt on the X axis, in degrees. 59 | 60 | startY: 0, // the starting tilt on the Y axis, in degrees. 61 | 62 | perspective: 1000, // Transform perspective, the lower the more extreme the tilt gets. 63 | 64 | scale: 1, // 2 = 200%, 1.5 = 150%, etc.. 65 | 66 | speed: 300, // Speed of the enter/exit transition 67 | 68 | transition: true, // Set a transition on enter/exit. 69 | 70 | axis: null, // What axis should be disabled. Can be X or Y. 71 | 72 | reset: true, // If the tilt effect has to be reset on exit. 73 | 74 | easing: "cubic-bezier(.03,.98,.52,.99)", // Easing on enter/exit. 75 | 76 | glare: false, // if it should have a "glare" effect 77 | 78 | "max-glare": 1, // the maximum "glare" opacity (1 = 100%, 0.5 = 50%) 79 | 80 | "glare-prerender": false, // false = VanillaTilt creates the glare elements for you, otherwise 81 | 82 | // you need to add .js-tilt-glare>.js-tilt-glare-inner by yourself 83 | 84 | "mouse-event-element": null, // css-selector or link to HTML-element what will be listen mouse events 85 | 86 | // you need to add .js-tilt-glare>.js-tilt-glare-inner by yourself 87 | 88 | gyroscope: true, // Boolean to enable/disable device orientation detection, 89 | 90 | gyroscopeMinAngleX: -45, // This is the bottom limit of the device angle on X axis, meaning that a device rotated at this angle would tilt the element as if the mouse was on the left border of the element; 91 | 92 | gyroscopeMaxAngleX: 45, // This is the top limit of the device angle on X axis, meaning that a device rotated at this angle would tilt the element as if the mouse was on the right border of the element; 93 | 94 | gyroscopeMinAngleY: -45, // This is the bottom limit of the device angle on Y axis, meaning that a device rotated at this angle would tilt the element as if the mouse was on the top border of the element; 95 | 96 | gyroscopeMaxAngleY: 45, // This is the top limit of the device angle on Y axis, meaning that a device rotated at this angle would tilt the element as if the mouse was on the bottom border of the element; 97 | 98 | } 99 | 100 | ``` 101 | To enable the parallax effect simply use 102 | ```html 103 | 104 |
105 | Your content here 106 |
107 |
108 | ``` 109 | And add the CSS property `transform: translateZ(20px)` to the element that you want to float. --------------------------------------------------------------------------------