Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkJamesHoward committed Aug 28, 2019
2 parents 44d0343 + 93ef68e commit ca97a7c
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 29 deletions.
10 changes: 7 additions & 3 deletions cypress/integration/home_page_spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
describe("The Home Page", function() {
it("successfully loads", function() {
cy.visit("/").scrollTo('bottom');
cy.pause();
cy.get('#ScrollToTopWC').click();
cy.visit("/").scrollTo("bottom", { duration: 1000 });

cy.contains("top").click();

cy.window().then($window => {
expect($window.scrollY).to.be.closeTo(0, 30);
});
});
});
10 changes: 4 additions & 6 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,20 @@
margin: 1rem;
}

body,
html {
scroll-behavior: smooth;
}

</style>
<script src="../src/index.ts"></script>
</head>

<body>
<div class="vertical-section-container centered">
<h3>Basic scroll-to-top demo</h3>
<h3 id="MainHeading">Basic scroll-to-top demo</h3>
<div class="container1"></div>
<div class="container2"></div>
<div class="container3"></div>
<div class="container4"></div>
<scroll-to-top-wc id="ScrollToTopWC" activateWhen="500"></scroll-to-top-wc>
<scroll-to-top-wc id="ScrollToTopWC" activateWhen="500"></scroll-to-top-wc>
</div>
</body>

</html>
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 18 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
{
"name": "scroll-to-top-wc",
"version": "0.3.6",
"version": "0.3.9",
"description": "scroll page up",
"main": "src/index.ts",
"license": "MIT",
"browserslist": [
"Chrome > 70 "
],
"scripts": {},
"scripts": {
"version": "npx @pika/pack"
},
"@pika/pack": {
"pipeline": [
[
"@pika/plugin-tsp-standard-pkg"
"@pika/plugin-ts-standard-pkg"
],
[
"@pika/plugin-build-web"
Expand All @@ -24,6 +27,18 @@
"dependencies": {
"lit-element": "^2.2.1"
},
"keywords": [
"scroll",
"top",
"scrolltop",
"scroll to top",
"scroll top",
"scroll up",
"move to top",
"move top",
"scrollTo",
"smooth scroll"
],
"devDependencies": {
"@pika/cli": "^0.2.0",
"@pika/pack": "^0.5.0",
Expand Down
14 changes: 0 additions & 14 deletions polymer.json

This file was deleted.

3 changes: 1 addition & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ export class ScrollToTop extends LitElement {
//When the user clicks on the button, scroll to the top of the document
topFunction() {
console.log("called top function");
document.body.scrollTop = 0; // For Chrome, Safari and Opera
document.documentElement.scrollTop = 0; // For IE and Firefox
window.scrollTo({ top: 0, behavior: "smooth" });
}
}

0 comments on commit ca97a7c

Please sign in to comment.