diff --git a/cypress/integration/home_page_spec.js b/cypress/integration/home_page_spec.js index 93e456d..9b20ff6 100644 --- a/cypress/integration/home_page_spec.js +++ b/cypress/integration/home_page_spec.js @@ -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); + }); }); }); diff --git a/demo/index.html b/demo/index.html index ad1a3b9..b584797 100644 --- a/demo/index.html +++ b/demo/index.html @@ -41,22 +41,20 @@ margin: 1rem; } - body, - html { - scroll-behavior: smooth; - } +
-

Basic scroll-to-top demo

+

Basic scroll-to-top demo

- +
+ diff --git a/package-lock.json b/package-lock.json index 44629da..ce6a9b1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "scroll-to-top-wc", - "version": "0.3.6", + "version": "0.3.9", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 8b6c045..bc19712 100644 --- a/package.json +++ b/package.json @@ -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" @@ -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", diff --git a/polymer.json b/polymer.json deleted file mode 100644 index 712ffe8..0000000 --- a/polymer.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "npm": true, - "moduleResolution": "node", - "entrypoint": "./src/index.js", - "builds": [ - { - "name": "mybuild", - "bundle": false, - "js": { - "minify": true - } - } - ] -} diff --git a/src/index.ts b/src/index.ts index cd30bcc..bd691f5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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" }); } }