@enso-ui/scroll-to-top 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +44 -0
- package/.github/issue_template.md +28 -0
- package/LICENSE +21 -0
- package/README.md +30 -0
- package/bulma/index.js +3 -0
- package/package.json +45 -0
- package/renderless/index.js +3 -0
- package/src/bulma/ScrollToTop.vue +59 -0
- package/src/renderless/CoreScrollToTop.vue +62 -0
package/.eslintrc.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
'root': true,
|
|
3
|
+
extends: [
|
|
4
|
+
'airbnb-base',
|
|
5
|
+
'plugin:vue/recommended'
|
|
6
|
+
],
|
|
7
|
+
plugins: [
|
|
8
|
+
'vue',
|
|
9
|
+
],
|
|
10
|
+
globals: {
|
|
11
|
+
axios: true,
|
|
12
|
+
route: true,
|
|
13
|
+
},
|
|
14
|
+
parserOptions: {
|
|
15
|
+
parser: 'babel-eslint',
|
|
16
|
+
sourceType: 'module',
|
|
17
|
+
'ecmaVersion': 2017,
|
|
18
|
+
allowImportExportEverywhere: true
|
|
19
|
+
},
|
|
20
|
+
rules: {
|
|
21
|
+
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
|
|
22
|
+
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
|
|
23
|
+
indent: ['error', 4],
|
|
24
|
+
'vue/html-indent': 0,
|
|
25
|
+
'vue/attributes-order': 0,
|
|
26
|
+
'no-plusplus': 0,
|
|
27
|
+
'no-debugger': 0,
|
|
28
|
+
'no-param-reassign': 0,
|
|
29
|
+
'no-mixed-operators': 0,
|
|
30
|
+
'func-names': 0,
|
|
31
|
+
'no-shadow': 0,
|
|
32
|
+
'vue/max-attributes-per-line': 0,
|
|
33
|
+
'no-return-assign': ['error', 'except-parens'],
|
|
34
|
+
'vue/html-closing-bracket-newline': ['error', {
|
|
35
|
+
'singleline': 'never',
|
|
36
|
+
'multiline': 'never'
|
|
37
|
+
}],
|
|
38
|
+
'vue/html-closing-bracket-spacing': ['error', {
|
|
39
|
+
'startTag': 'never',
|
|
40
|
+
'endTag': 'never',
|
|
41
|
+
'selfClosingTag': 'never'
|
|
42
|
+
}]
|
|
43
|
+
},
|
|
44
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<!-- Choose one of the following: -->
|
|
2
|
+
This is a **bug | feature request**.
|
|
3
|
+
|
|
4
|
+
<!-- Make sure that everything is checked below: -->
|
|
5
|
+
### Prerequisites
|
|
6
|
+
* [ ] Are you running the latest version?
|
|
7
|
+
* [ ] Are you reporting to the correct repository?
|
|
8
|
+
(enso is made of many specialized packages: https://github.com/laravel-enso)
|
|
9
|
+
* [ ] Did you check the documentation?
|
|
10
|
+
* [ ] Did you perform a cursory search?
|
|
11
|
+
|
|
12
|
+
### Description
|
|
13
|
+
<!-- Description of the bug or feature -->
|
|
14
|
+
|
|
15
|
+
### Steps to Reproduce
|
|
16
|
+
<!--
|
|
17
|
+
1. First Step
|
|
18
|
+
2. Second Step
|
|
19
|
+
3. and so on...
|
|
20
|
+
-->
|
|
21
|
+
|
|
22
|
+
### Expected behavior
|
|
23
|
+
<!-- What you expected to happen -->
|
|
24
|
+
|
|
25
|
+
### Actual behavior
|
|
26
|
+
<!-- What actually happened -->
|
|
27
|
+
|
|
28
|
+
<!-- when the issue is resolved, don't forget to **CLOSE** it -->
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017 laravel-enso
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Loader
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
Simple loader
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
The component can be used outside of the Enso ecosystem.
|
|
13
|
+
|
|
14
|
+
### Demo
|
|
15
|
+
|
|
16
|
+
For live examples and demos, you may visit [laravel-enso.com](https://www.laravel-enso.com)
|
|
17
|
+
|
|
18
|
+
### Installation, Configuration & Usage
|
|
19
|
+
|
|
20
|
+
Be sure to check out the full documentation for this package available at [docs.laravel-enso.com](https://docs.laravel-enso.com/frontend/scroll-to-top.html)
|
|
21
|
+
|
|
22
|
+
## Contributions
|
|
23
|
+
|
|
24
|
+
are welcome. Pull requests are great, but issues are good too.
|
|
25
|
+
|
|
26
|
+
Thank you to all the people who already contributed to Enso!
|
|
27
|
+
|
|
28
|
+
## License
|
|
29
|
+
|
|
30
|
+
[ISC](https://opensource.org/licenses/ISC)
|
package/bulma/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@enso-ui/scroll-to-top",
|
|
3
|
+
"version": "2.0.4",
|
|
4
|
+
"description": "Scroll To Top",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/enso-ui/scroll-to-top.git"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"scroll-to-top",
|
|
15
|
+
"vue",
|
|
16
|
+
"bulma"
|
|
17
|
+
],
|
|
18
|
+
"author": "Adrian Ocneanu <aocneanu@gmail.com>",
|
|
19
|
+
"license": "ISC",
|
|
20
|
+
"bugs": {
|
|
21
|
+
"url": "https://github.com/enso-ui/scroll-to-top/issues"
|
|
22
|
+
},
|
|
23
|
+
"homepage": "https://github.com/enso-ui/scroll-to-top#readme",
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
|
|
26
|
+
"@vue/cli-plugin-babel": "^4.0.5",
|
|
27
|
+
"@vue/cli-plugin-eslint": "^4.0.5",
|
|
28
|
+
"@vue/cli-service": "^4.0.5",
|
|
29
|
+
"@vue/eslint-config-airbnb": "^5.0.0",
|
|
30
|
+
"autoprefixer": "^9.6.1",
|
|
31
|
+
"babel-eslint": "^10.0.1",
|
|
32
|
+
"cross-env": "^6.0.0",
|
|
33
|
+
"eslint": "^6.8.0",
|
|
34
|
+
"eslint-import-resolver-alias": "^1.1.2",
|
|
35
|
+
"eslint-plugin-vue": "^6.0.0"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@enso-ui/transitions": "^1.0",
|
|
39
|
+
"@fortawesome/fontawesome-svg-core": "^1.2.2",
|
|
40
|
+
"@fortawesome/free-solid-svg-icons": "^5.2.0",
|
|
41
|
+
"@fortawesome/vue-fontawesome": "^0.1.1",
|
|
42
|
+
"bulma": "^0.9.0",
|
|
43
|
+
"vue": "^2.5.16"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<core-scroll-to-top v-bind="$attrs">
|
|
3
|
+
<template v-slot:default="{ visible, type, controlEvents }">
|
|
4
|
+
<zoom>
|
|
5
|
+
<div class="button scroll-control"
|
|
6
|
+
:class="type"
|
|
7
|
+
v-on="controlEvents"
|
|
8
|
+
v-if="visible">
|
|
9
|
+
<slot>
|
|
10
|
+
<span class="icon is-large">
|
|
11
|
+
<fa icon="arrow-alt-circle-up"/>
|
|
12
|
+
</span>
|
|
13
|
+
</slot>
|
|
14
|
+
</div>
|
|
15
|
+
</zoom>
|
|
16
|
+
</template>
|
|
17
|
+
</core-scroll-to-top>
|
|
18
|
+
</template>
|
|
19
|
+
|
|
20
|
+
<script>
|
|
21
|
+
import { Zoom } from '@enso-ui/transitions';
|
|
22
|
+
import { library } from '@fortawesome/fontawesome-svg-core';
|
|
23
|
+
import { faArrowAltCircleUp } from '@fortawesome/free-solid-svg-icons';
|
|
24
|
+
import CoreScrollToTop from '../renderless/CoreScrollToTop.vue';
|
|
25
|
+
|
|
26
|
+
library.add(faArrowAltCircleUp);
|
|
27
|
+
|
|
28
|
+
export default {
|
|
29
|
+
name: 'ScrollToTop',
|
|
30
|
+
|
|
31
|
+
components: { CoreScrollToTop, Zoom },
|
|
32
|
+
};
|
|
33
|
+
</script>
|
|
34
|
+
|
|
35
|
+
<style lang="scss">
|
|
36
|
+
.scroll-control {
|
|
37
|
+
z-index: 3;
|
|
38
|
+
position: fixed;
|
|
39
|
+
bottom: 3em;
|
|
40
|
+
|
|
41
|
+
@media screen and (min-width: 769px) {
|
|
42
|
+
[dir='ltr'] & {
|
|
43
|
+
right: 1.5em;
|
|
44
|
+
}
|
|
45
|
+
[dir='rtl'] & {
|
|
46
|
+
left: 1.5em;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
@media screen and (max-width: 768px) {
|
|
50
|
+
[dir='ltr'] & {
|
|
51
|
+
right: 0.5em;
|
|
52
|
+
}
|
|
53
|
+
[dir='rtl'] & {
|
|
54
|
+
left: 0.5em;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
</style>
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
export default {
|
|
3
|
+
name: 'CoreScrollToTop',
|
|
4
|
+
|
|
5
|
+
props: {
|
|
6
|
+
type: {
|
|
7
|
+
type: String,
|
|
8
|
+
default: null,
|
|
9
|
+
},
|
|
10
|
+
},
|
|
11
|
+
|
|
12
|
+
data: () => ({
|
|
13
|
+
visible: false,
|
|
14
|
+
requestId: null,
|
|
15
|
+
position: null,
|
|
16
|
+
}),
|
|
17
|
+
|
|
18
|
+
mounted() {
|
|
19
|
+
const onScroll = () => {
|
|
20
|
+
const position = Math.max(
|
|
21
|
+
document.body.scrollTop,
|
|
22
|
+
document.documentElement.scrollTop,
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
if (position > this.position) {
|
|
26
|
+
window.cancelAnimationFrame(this.requestId);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
this.position = position;
|
|
30
|
+
|
|
31
|
+
this.visible = this.position > 100;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
window.addEventListener('scroll', onScroll);
|
|
35
|
+
|
|
36
|
+
this.$once('hook:destroyed', () => {
|
|
37
|
+
window.removeEventListener('scroll', onScroll);
|
|
38
|
+
});
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
methods: {
|
|
42
|
+
scroll() {
|
|
43
|
+
const height = document.documentElement.scrollTop || document.body.scrollTop;
|
|
44
|
+
|
|
45
|
+
if (height > 0) {
|
|
46
|
+
window.scrollTo(0, height - height / 10);
|
|
47
|
+
this.requestId = window.requestAnimationFrame(this.scroll);
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
render() {
|
|
53
|
+
return this.$scopedSlots.default({
|
|
54
|
+
visible: this.visible,
|
|
55
|
+
type: this.type,
|
|
56
|
+
controlEvents: {
|
|
57
|
+
click: this.scroll,
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
</script>
|