Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/components/button/scrollbutton.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div class="scroll-button-container" ng-show="isButtonVisible" ng-click="scrollToTop()">
<span class="scroll-button" ><i class="fas fa-arrow-circle-up"></i></span>
</div>
30 changes: 30 additions & 0 deletions app/components/button/scrollbutton.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import angular from 'angular';

import "./scrollbutton.scss"

export default angular.module("rhGitHub.scrollbutton", []).component("scrollbutton", {
template: require("./scrollbutton.html"),
controller: "scrollCtrl"
}).controller("scrollCtrl", ["$scope", function($scope) {

$scope.isButtonVisible = false;

// Function to update the button visibility based on the scroll position
const updateButtonVisibility = () => {
$scope.isButtonVisible = window.scrollY > 500;
$scope.$apply(); // Manually trigger a digest cycle to update the view
};

// Attach the scroll event listener to update the button visibility
angular.element(window).on("scroll", updateButtonVisibility);

$scope.scrollToTop = () => {
window.scrollTo({ top: 0, behavior: "smooth" }); // Smooth scroll to the top
};

// Clean up the event listener when the controller is destroyed
$scope.$on("$destroy", () => {
angular.element(window).off("scroll", updateButtonVisibility);
});
}]);

25 changes: 25 additions & 0 deletions app/components/button/scrollbutton.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@


.scroll-button-container {
background-color: #007bff;
color: #fff;
padding: 10px 10px;
border: none;
border-radius: 50%;
cursor: pointer;
width: 30px;
height: 30px;
display: flex;
align-items: center;
justify-content: center;

}
.scroll-button{
background: none;
border: none;
cursor: pointer;
&:hover {
background-color: none;
}
}

5 changes: 3 additions & 2 deletions app/pages/main/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,16 @@ import bandheader from "../../components/bandheader/bandheader";
import card from "../../components/card/card";
import group from "../../components/group/group";
import dynamictable from "../../components/dynamictable/dynamictable";

import scrollbutton from "../../components/button/scrollbutton";
export default angular.module("rhGitHub.main", [
"ngRoute",
"rhGitHub.hero",
"rhGitHub.band",
"rhGitHub.bandheader",
"rhGitHub.card",
"rhGitHub.group",
"rhGitHub.dynamictable"
"rhGitHub.dynamictable",
"rhGitHub.scrollbutton"
])
.config(["$routeProvider", ($routeProvider) => {
$routeProvider.when("/main", {
Expand Down
12 changes: 12 additions & 0 deletions app/pages/main/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,15 @@
}
}
}

.scroll{

position: fixed;
bottom: 80px;
right: 20px;
z-index: 5;
place-items: center;
border-radius: 50%;
cursor: pointer;

}
1 change: 1 addition & 0 deletions app/pages/main/mainView.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
<div class="band-container" data-layout="2-up">
<group ng-repeat="item in ctrl.content" item="item"></group>
</div>
<scrollbutton class="scroll"></scrollbutton>
</section>
</main>