{"id":21582076,"url":"https://github.com/sudo-self/elevator.js","last_synced_at":"2025-03-18T08:21:18.496Z","repository":{"id":196312215,"uuid":"695720915","full_name":"sudo-self/elevator.js","owner":"sudo-self","description":"elevator.js","archived":false,"fork":false,"pushed_at":"2023-09-24T05:08:48.000Z","size":802,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-24T14:47:01.343Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://elevator.jessejesse.com","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sudo-self.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-09-24T02:22:13.000Z","updated_at":"2023-09-24T23:25:45.000Z","dependencies_parsed_at":null,"dependency_job_id":"969cbbcb-6635-4959-aba0-73b3fbee7df4","html_url":"https://github.com/sudo-self/elevator.js","commit_stats":null,"previous_names":["sudo-self/elevator.js"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sudo-self%2Felevator.js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sudo-self%2Felevator.js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sudo-self%2Felevator.js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sudo-self%2Felevator.js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sudo-self","download_url":"https://codeload.github.com/sudo-self/elevator.js/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244181300,"owners_count":20411605,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-24T14:14:49.240Z","updated_at":"2025-03-18T08:21:18.480Z","avatar_url":"https://github.com/sudo-self.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# \u003ca href=\"https://elevator.jessejesse.com\"\u003eelevator.js\u003c/a\u003e \u003c---- try me\nFinally, a \"back to top\" button that behaves like a real elevator, by adding elevator music to quietly soothe the awkwardness that can ensue when being smoothly scrolled to the top of the screen.\n\n\n\n# \u003cimg width=\"1005\" alt=\"Screenshot 2023-09-23 at 10 24 06 PM\" src=\"https://github.com/sudo-self/elevator.js/assets/119916323/1a72365e-78e0-4548-b55e-df18aebcea33\"\u003e\n\n\n\n### Instructions\n\n`Elevator.js` is a stand alone library (no jquery, or the likes) so usage is pretty straight forward. All styling of elements is up to you. `Elevator.js` only handles the audio management, and the scroll functionality!\n\n#### JS\n\n`Elevator.js` lives entirely within the js realm, which makes things fairly simple to use.\n\nYou'll need to create a new instance of `Elevator`, and pass it some audio elements.\n\n```html\n\u003cscript\u003e\n// Elevator script included on the page, already.\n\nwindow.onload = function() {\n  var elevator = new Elevator({\n    mainAudio: '/src/to/audio.mp3',\n    endAudio: '/src/to/end-audio.mp3'\n  });\n}\n\n// You can run the elevator, by calling.\nelevator.elevate();\n\u003c/script\u003e\n```\n\nYou can also add an \"element\" option, clicking this element will invoke the \"Scroll to top\" functionality, we all love and crave.\n```html\n\u003cdiv class=\"elevator-button\"\u003eBack to Top\u003c/div\u003e\n\n\u003cscript\u003e\n// Elevator script included on the page, already.\n\nwindow.onload = function() {\n  var elevator = new Elevator({\n    element: document.querySelector('.elevator-button'),\n    mainAudio: '/src/to/audio.mp3',\n    endAudio: '/src/to/end-audio.mp3'\n  });\n}\n\u003c/script\u003e\n```\n\nIf you don't want to scroll to the top, a custom target can be specified by adding a \"targetElement\" option:\n```html\n\u003cdiv class=\"elevator-button\"\u003eTake the elevator to the target\u003c/div\u003e\n\n\u003cscript\u003e\n// Elevator script included on the page, already.\n\nwindow.onload = function() {\n  var elevator = new Elevator({\n    element: document.querySelector('.elevator-button'),\n    targetElement: document.querySelector('#elevator-target'),\n    mainAudio: '/src/to/audio.mp3',\n    endAudio: '/src/to/end-audio.mp3'\n  });\n}\n\u003c/script\u003e\n```\n\nIf you want to scroll to a point on the page with some extra padding on the top, simply add the \"verticalPadding\" option:\n\n```html\n\u003cdiv class=\"elevator-button\"\u003eTake the elevator to the target\u003c/div\u003e\n\n\u003cscript\u003e\n// Elevator script included on the page, already.\n\nwindow.onload = function() {\n  var elevator = new Elevator({\n    element: document.querySelector('.elevator-button'),\n    targetElement: document.querySelector('#elevator-target'),\n    verticalPadding: 100,  // in pixels\n    mainAudio: '/src/to/audio.mp3',\n    endAudio: '/src/to/end-audio.mp3'\n  });\n}\n\u003c/script\u003e\n```\n\nIf you're really serious (boring), you don't have to use audio... and can also set a fixed time to scroll to the top\n```html\n\u003cdiv class=\"elevator-button\"\u003eBack to Top\u003c/div\u003e\n\n\u003cscript\u003e\n// Elevator script included on the page, already.\n\nwindow.onload = function() {\n  var elevator = new Elevator({\n    element: document.querySelector('.elevator-button'),\n    duration: 1000 // milliseconds\n  });\n}\n\u003c/script\u003e\n```\n\nIf you use elevator.js in combination with other code, you might want to use callbacks\n```html\n\u003cscript\u003e\nwindow.onload = function() {\n   new Elevator({\n       element: document.querySelector('.elevator-button'),\n       mainAudio: '/src/to/audio.mp3',\n       endAudio: '/src/to/end-audio.mp3',\n       duration: 5000,\n       startCallback: function() {\n         // is called, when the elevator starts moving\n       },\n       endCallback: function() {\n         // is called, when the elevator reached target level\n       }\n   });\n}\n\u003c/script\u003e\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsudo-self%2Felevator.js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsudo-self%2Felevator.js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsudo-self%2Felevator.js/lists"}